Commit Graph
125 Commits
Author SHA1 Message Date
Isaac ConnorandClaude Opus 4.8 b806de5e76 fix: restrict image proxy to non-reserved addresses and monitor editors
web/views/image.php exposes an outbound fetch via ?view=image&proxy=.
It validated only the URL scheme, so any user with canView('Events')
could make the server issue HTTP requests to arbitrary hosts and, on a
401 Digest challenge, replay credentials taken from the URL's user-info.
view=image is also exempt from CSRF handling in index.php, so the fetch
could be triggered from an attacker page via a plain <img> tag.

Camera discovery legitimately proxies cameras on the local LAN, so
private ranges stay reachable. Reject only loopback, link-local and
other reserved addresses via FILTER_FLAG_NO_RES_RANGE, which covers
127.0.0.0/8, ::1, fe80::/10 and 169.254.0.0/16 (cloud metadata) without
excluding 10/8, 172.16/12, 192.168/16 or fc00::/7. Resolve the host
first so a hostname cannot point at those ranges.

Also require canEdit('Monitors') — the only consumer is the discovery
thumbnail in add_monitors, which already demands that right — and stop
reading $url_parts['user'] without an isset() guard.

Refs GHSA-g28p-q36w-h3c5, GHSA-rq9f-p634-rrpg.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 11:45:54 -04:00
Isaac ConnorandClaude Opus 4.7 ad1e9c23a6 fix: enforce per-event ACL on direct media endpoints (GHSA-vj5r-pc2v-gfwv)
image.php, view_video.php and view_hls.php previously checked only the
coarse canView('Events') / canView('Snapshots') role before streaming
media for a user-supplied event id. An authenticated user denied access
to a monitor could still fetch event snapshots, captured frames,
recorded MP4s and HLS manifests for events belonging to that monitor by
calling the direct endpoints with the event id.

Call Event->canView() after loading the event and return 404 on denial
so the event id cannot be enumerated. view_video also validates
Event->Id() so unknown ids return 404 instead of an empty 200 body.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-03 08:45:20 -04:00
IgorA100 c6843b389e Fix: Annoying error getting $file_path due to ".$file" (image.php) 2026-05-09 16:59:37 +03:00
IgorA100 bcdaae1d4a Fix: Display snapshot for incomplete event file (Update image.php) 2026-05-05 15:54:09 +03:00
IgorA100andCopilot Autofix powered by AI 8f8274e86e Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-04-29 14:25:33 +03:00
IgorA100 a38c41a499 Update image.php 2026-04-28 20:07:42 +03:00
IgorA100 a1ff19c9d7 Update image.php 2026-04-28 19:01:10 +03:00
IgorA100 8957dcee56 Prevent an error from being generated when processing the file "index.m3u8" (image.php)
This is a very quick fix: https://github.com/ZoneMinder/zoneminder/issues/4763
2026-04-28 17:36:33 +03:00
Daniel Caujolle-Bert 1913208c7a Force memory release of GDImage for PHP >= 8.0. 2026-04-11 17:31:59 +02:00
Daniel Caujolle-Bert 7fa6059ae9 Conditionally calls imagedestroy() as it was deprecated since PHP 8.0 doing nothing except logging errors. 2026-04-11 06:31:07 +02:00
Isaac ConnorandClaude Opus 4.6 ffe6362dc3 fix: harden web interface against injection and SSRF vulnerabilities
FilterTerm.php:
- Replace eval() with safe compare() method for SystemLoad, DiskPercent,
  and DiskBlocks filter conditions (RCE via crafted op/val)
- Validate operator against allowlist in constructor
- Sanitize collate field to alphanumeric/underscore only (SQLi)

onvifprobe.php:
- Use escapeshellarg() on interface, device_ep, soapversion, username,
  and password arguments passed to execONVIF() (command injection)

Event.php:
- Use escapeshellarg() on all arguments to zmvideo.pl instead of
  escapeshellcmd() on the whole command (command injection via format)
- Anchor scale regex with ^ and $ to prevent partial matches

image.php:
- Restrict proxy URL scheme to http/https only (SSRF via file:// etc)

filterdebug.php:
- Use already-sanitized $fid instead of raw $_REQUEST['fid'] (XSS)

MonitorsController.php:
- Use escapeshellarg() on token, username, password, and monitor id
  in zmu shell command instead of escapeshellcmd() on whole command

HostController.php:
- Use escapeshellarg() on path in du command (command injection via mid)
- Remove space from daemon name allowlist (argument injection)

EventsController.php:
- Remove single quotes from interval expression regex (SQLi)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:30:49 -04:00
Simpler1 d51870ddcc fix: Change ffmpeg errors to warnings for incomplete.mp4 2026-03-06 11:04:25 -05:00
Isaac ConnorandClaude Opus 4.6 b036408a5b Fix RCE vulnerability via API config edit privilege escalation
Add RBAC checks to ConfigsController edit() and delete() requiring
System=Edit permission, matching the pattern used by other controllers.
Harden System/Readonly column checks with !empty() to handle missing
columns gracefully. Fix command injection in Event.php by using
ZM_PATH_FFMPEG constant with escapeshellarg() instead of hardcoded
unsanitized ffmpeg call. Add is_executable() validation at all exec()
sites using ZM_PATH_FFMPEG as defense-in-depth against poisoned config
values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 13:51:30 -05:00
Isaac ConnorandClaude Opus 4.5 7592fd933c Fix command injection vulnerability in image.php (CVE-2025-65791)
Add input validation and shell argument escaping to prevent OS command
injection via the 'show' parameter in web/views/image.php. The parameter
is now validated against an allowlist and all values passed to exec()
are wrapped with escapeshellarg().

Also fix PHP operator precedence bug in shutdown.php where 'and' was
used instead of '&&', causing the 'when' parameter validation to not
work as intended.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 16:39:38 -05:00
Simpler1 f6f7bf8f77 Fix: Deprecated format from ${ to {$ 2026-01-07 12:04:01 -05:00
Isaac Connor d51fb62e26 apache_setenv is only available when running under apache. So test for it instead of crashing. 2024-04-10 07:15:09 -04:00
Isaac Connor 1bd94308b1 Make no alarm.jpg a debug instead of error, because continuous events don't have them. 2024-03-15 12:09:31 -04:00
Isaac Connor 43c3937b87 Fix image proxy broken due to imagecreatefromstream=>imagecreatefromstring 2024-02-02 11:50:03 -05:00
Isaac Connor f62f1529f5 Try to prevent XSS by verifying valid image data 2024-01-24 19:18:22 -05:00
Isaac Connor 3d2fa3172f Fix im => i. Typo in variable name. 2024-01-22 15:41:00 -05:00
Isaac Connor 69383316aa If the video file doesn't exist, don't try ffmpeg etc and log all those errors. 2024-01-18 13:16:22 -05:00
Isaac Connor a9997b943a Use new event::find_virtual_frame when loading frames 2023-09-08 14:19:01 -04:00
Isaac Connor e5d125c4ef Handle when no linefeed found 2023-08-31 12:46:12 -04:00
Isaac Connor 56999da3eb Check for existence of path before scanning it generating a lot of erros 2023-08-30 14:38:43 -04:00
Isaac Connor b48702c96c Fix lack of ZM on Warning 2023-08-02 13:36:26 -04:00
Isaac Connor bb625ab237 nonce can contain =, so parse that properly. Use a betr nonce. 2023-07-25 12:32:13 -04:00
Isaac Connor c7259fdc14 Implement read locks when accessing jpgs. Implement locking on creating scaled jpegs. 2023-07-13 17:20:18 -04:00
Isaac Connor 37b571a58a Handle no password specified and make testing for www-authenticate header non case sensitive 2023-07-05 15:51:16 -04:00
Isaac Connor 2cb697f0e9 Debug alarm.jpg path when not found. Spacing. Remove unused Monitor variable 2023-06-09 10:40:34 -04:00
Isaac Connor 847e803e82 If failed to open image, send a test jpeg explaining 2023-05-15 10:05:06 -04:00
Isaac Connor e3a77876c0 Remove deprecated code for loading image by path. 2023-04-23 10:27:56 -04:00
Isaac Connor 1638869982 If mp4 is not found, look for any other mp4s to use. Handles care where db has not been updated 2023-04-22 10:30:25 -04:00
Isaac Connor c36be30e2a Rough in an image proxy 2023-04-22 10:29:27 -04:00
Isaac Connor dedff86511 Allow caching of images 2023-02-13 16:15:12 -05:00
Isaac Connor ecf790b1d6 Diskspace(null) updates the db record so no need to call save as well 2023-01-25 12:27:59 -05:00
Isaac Connor 874119c04d Event->Diskspace(null) automatically updates the db. So don't do a second save 2023-01-25 11:50:16 -05:00
Martin Tiernan 237a95a415 If no next bulk. Use Event data to estimate the delta. 2022-11-21 10:23:08 -06:00
Martin Tiernan 047d109d59 Added potentially missing 404 header 2022-11-18 15:27:52 -06:00
Isaac Connor 1072a8aa69 When scaling frame images, apparently a float value for height is no good. So use intval to fix. 2022-09-21 13:23:16 -04:00
Isaac Connor bcd0b6430b Convert Fatal()s to Errors() which is really more appropriate anyways. Maybe Fixes #3426 2022-02-08 18:12:06 -05:00
Isaac Connor 7dc36f67db output an error message image when we can't load a jpeg 2021-08-05 13:30:52 -04:00
Isaac Connor b10b2932ee Code spacing and doc 2021-05-03 15:20:11 -04:00
Isaac Connor b125b5d370 Allow users with snapshot::view to view the snapshot image of an event 2021-04-12 15:59:31 -04:00
Isaac Connor feec631ca5 Only save updated DiskSpace if event is finished 2021-03-15 15:02:43 -04:00
Isaac Connor 671d58f0d0 bump version and put back ZM_MIN_RTSP_PORT setting 2021-01-26 12:35:17 -05:00
Isaac Connor c8392feba3 Merge branch 'master' of github.com:/ZoneMinder/zoneminder 2020-10-22 16:35:44 -04:00
Isaac Connor 10c0a6617c Return Debug to a regular function to match other logging functions. Since we switched to using namespaces we no longer clash with cake_php. 2020-10-14 10:39:25 -04:00
Isaac Connor a118e52f30 Add 2>&1 to ffmpeg command line to get stderr as well 2020-09-28 16:13:06 -04:00
Pliable Pixels 921c4c5bbd don't return mp4 if objdetect is used 2020-03-14 15:00:33 -04:00
Pliable Pixels 4342506e5b fix media type allocations 2020-03-14 14:24:39 -04:00