Commit Graph
3281 Commits
Author SHA1 Message Date
Jash 16ddc64101 fix: keep the perl logger writing to the database after a connection outage refs #5818 2026-11-14 18:46:22 +05:30
Jash 4972813b13 fix: apply the term log level option and ZM_LOG_LEVEL_TERM in the perl logger refs #5818 2026-11-14 18:46:22 +05:30
Isaac Connor a6b073c8f5 Merge pull request #5555 from AJ0070/5554-delete-path-no-shell
fix: delete event paths with File::Path instead of an unquoted rm -rf
2026-11-12 19:50:38 -05:00
Isaac Connor 4d474ded4e Merge pull request #5567 from AJ0070/5563-zmaudit-batch-event-rows
perf: load the events zmaudit checks in batches of 1000 instead of one query each
2026-11-12 08:36:25 -05:00
Isaac Connor 600414089d Merge pull request #5542 from AJ0070/5541-zmfilter-object-cache
fix: clear the object cache on every zmfilter pass so handled events are freed
2026-11-11 21:45:12 -05:00
Isaac Connor 06c093c44b Merge pull request #5572 from AJ0070/5568-zmaudit-lazy-start-time
perf: work out a filesystem event's start time in zmaudit only when it is needed
2026-11-11 19:14:48 -05:00
Isaac Connor 7dd72fd1c2 Merge pull request #5576 from AJ0070/5574-upload-failure
fix: stop zmfilter treating a failed FTP or SFTP upload as done
2026-11-11 19:14:20 -05:00
Jash ba59be7c19 fix: remove the upload archive when the FTP or SFTP connection cannot be made refs #5574 2026-11-12 04:24:39 +05:30
Jash eb6890911b fix: stop zmfilter treating a failed FTP or SFTP upload as done fixes #5574 2026-11-12 02:26:49 +05:30
Jash e6597da6be perf: work out a filesystem event's start time in zmaudit only when it is needed fixes #5568 2026-11-12 02:18:34 +05:30
Jash 7266e2717b perf: load the events zmaudit checks in batches of 1000 instead of one query each fixes #5563 2026-11-12 02:02:24 +05:30
Isaac Connor cf0d054f76 Merge pull request #5562 from AJ0070/5560-delete-analysis-jpegs
fix: delete analysis jpegs by file name instead of an absolute glob result
2026-11-11 15:30:14 -05:00
Isaac Connor 467c41ddfa Merge pull request #5559 from AJ0070/5558-zmaudit-object-cache
fix: clear the object cache on every zmaudit pass so looked up events are freed
2026-11-11 15:29:20 -05:00
Jash f31fe09959 fix: delete analysis jpegs by file name instead of an absolute glob result fixes #5560 2026-11-12 01:47:19 +05:30
Jash 7efeaf6809 fix: clear the object cache on every zmaudit pass so looked up events are freed fixes #5558 2026-11-12 01:35:01 +05:30
Isaac ConnorandClaude Opus 5.5 a36a2d239f fix: install only the generated Perl modules from the build tree
After installing the Perl modules from the source tree, the install copied
every .pm in the build tree's lib/ over them, though only Base, Config,
Memory, ConfigData and ONVIF are generated there. Copies of other modules
left in a build directory by an older build replaced current ones on
install: a stale ZoneMinder/Server.pm without systemdRunning() left
zoneminder.service failing in zmpkg.pl. The five generated modules are now
named one by one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 15:02:59 -05:00
Jash 90993466a4 fix: quote storage paths passed to df, du, ffprobe and AutoExecute refs #5556 2026-11-12 01:07:48 +05:30
Jash 90210ee3cc fix: delete event paths with File::Path instead of an unquoted rm -rf fixes #5554 2026-11-12 00:35:27 +05:30
Jash 43fde1a551 perf: load Data::Dumper when Dump() is called instead of at startup fixes #5547 2026-11-11 23:16:30 +05:30
Jash b9cb8e02de perf: import only the POSIX names zmdc.pl uses and none where nothing is used refs #5547 2026-11-11 23:16:30 +05:30
Jash 24a75775d2 perf: load ConfigData only in the functions that write the Config table refs #5547 2026-11-11 23:16:20 +05:30
Jash 76542990a7 fix: clear the object cache on every zmfilter pass so handled events are freed fixes #5541 2026-11-11 22:49:33 +05:30
Isaac Connor 2660411af1 Merge branch 'master' into remove-fast-delete 2026-11-03 08:32:58 -05:00
Isaac ConnorandClaude Opus 5.5 9e3885e8fd refactor: remove ZM_OPT_FAST_DELETE
With fast deletes on, deleting an event in the web interface removed only
its Events row and left its Frames and Stats rows and its files for
zmaudit, and deleting a monitor left all of its events. zmaudit only runs
when ZM_RUN_AUDIT is on, and both options default to off independently,
so with fast deletes on and the audit off nothing ever removed them and
the Frames table grew without bound. In the Perl Event::delete the option
also kept zmfilter from removing the files of the events it purged.

Remove the option. ZM\Event::delete() always removes the Stats and Frames
rows and the files in one transaction with the Events row,
ZM\Monitor::destroy() always deletes the monitor's events, and the Perl
Event::delete deletes the files unless the storage area has DoDelete off.
zmupdate.pl rebuilds the Config table from ConfigData, so the option's row
goes away on upgrade without a migration. Drop the option from the docs,
from the zmaudit option help, and from the es_la, ro_ro and ru_ru
translations.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:50:01 -05:00
Isaac ConnorandClaude Opus 5.5 f47033ec27 fix: warn at start when fast deletes are on and zmaudit is off
With ZM_OPT_FAST_DELETE on, deleting an event in the web interface
removes only its Events row and leaves its Frames and Stats rows and its
files for zmaudit to remove. zmaudit only runs when ZM_RUN_AUDIT is on,
and both options default to off independently, so with fast deletes on
and the audit off nothing ever removes them and the Frames table grows
without bound.

Have zmpkg.pl log one Warning at start for that combination, naming both
options, next to the ZM_AUTH_RELAY=plain warning. Say in the fast delete
option's help that it depends on ZM_RUN_AUDIT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:23:03 -05:00
Isaac ConnorandClaude Opus 5.5 960d8feef7 fix: make Current Weekday filter terms run in the web UI and zmfilter.pl refs #5418
FilterTerm::sql_attr() returned 'weekday(NOW()' without its closing
parenthesis, so any filter with a Current Weekday term failed with
"Database query failed". FilterTerm::valid() treated the value 0 (Monday) as
missing, so a Monday term was dropped and the filter matched every event.

ZoneMinder::Filter had no CurrentWeekday case at all and emitted
E.CurrentWeekday, a column Events does not have, so zmfilter.pl could not run
such a filter either. Emit weekday(NOW()) there as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 17:29:02 -05:00
Nic BoetandClaude Opus 5.5 2625b53108 fix: let the PSIA control module compile
PSIA.pm has not compiled since it was added: move() built an unused
command string from undeclared $panSteps/$tiltSteps, and the PUT and
DELETE error paths logged an undeclared $cmd. zmcontrol.pl loads the
module when a PSIA camera is moved, so every PSIA PTZ command died.

Drop the unused line and log the request path on failure. A new test
compiles every control module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 6beb62c9ee fix: stop logging camera passwords in the PTZ control modules
Control.pm's get(), put() and credential parsing, and the HikVision,
Netcat, PSIA, Serial_HEX_PelcoD, TapoC520WS_ONVIF, Instar720p,
Vivotek_ePTZ, Keekoon, M8640, FI8908W, IPCC7210W, DericamP2,
WanscamHW0025, Dahua and Grandstream modules logged the camera's
password: as a separate field ("username X password Y", which no
pattern in the logger can recognise), or inside the ControlAddress, Path
or request URL. Some of these are Info or Error lines, which reach the
Logs table at the default settings (Instar720p, IPCC7210W, DericamP2,
WanscamHW0025 on every command; FI8908W, M8640, Vivotek_ePTZ,
Grandstream on failures). Reolink_HTTP logged its API session token.

Log the user name without the password, URLs through urlForLog() (host,
port and path kept), and the Reolink token as a fingerprint. The test
scans the Perl modules for log calls that interpolate a password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 9a1fab7514 fix: stop logging the S3 secret key when parsing a storage URL
ZoneMinder::Storage::s3() logged the parsed S3 access key id, secret
key, host and bucket, and the URL they came from, at Debug level 1 in
every process that deletes or uploads events (zmfilter, zmaudit). Log
the key id, host, bucket and subpath, and the URL through urlForLog().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Nic BoetandClaude Opus 5.5 2db3d24d62 fix: redact credentials from every line the Perl logger writes
The PTZ control modules build camera URLs with user:password@ from the
ControlAddress or Path, or pwd= from the ControlDevice, and log them at
Debug, Info or Error. Info and Error reach the Logs table at the default
settings, which every System=View user can read. There are over fifty
modules, most written for one camera and not testable here.

ZoneMinder::Logger gets redactCredentials(), urlForLog() and
logFingerprint() (the same fp: tag as the web and C++ logs), and
logPrint() passes every message through redactCredentials(): userinfo is
removed from URLs and from scheme-less host specs, pass/pwd/secret
parameters are replaced, token= and auth= are fingerprinted, WS-Security
password digests and JSON password fields are replaced. Host, port, path
and the other parameters stay in the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 10:27:39 -05:00
Isaac Connor 9b3caa20b0 Merge branch '5395-xml-libxml-dep' 2026-10-31 18:09:34 -04:00
Isaac ConnorandClaude Opus 5.5 21d2c26127 fix: load XML::LibXML explicitly in HikVision control module refs #5395
HikVision.pm calls XML::LibXML->load_xml and XML::LibXML::Element->new but
never loaded the module, so it only worked when another module had already
pulled it in. Add the missing use line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 18:06:50 -04:00
Isaac Connor ac1e167e6e Merge pull request #5382 from connortechnology/fix/ghsa-2pgc-session-fixation
fix: reject client-chosen session ids and regenerate on auth= / stateful API login (GHSA-2pgc)
2026-10-31 09:34:50 -04:00
Nic Boet b7f9c7631c chore: deprecate ZM_AUTH_RELAY=plain with a warning at start
The plain relay keeps the user's password in the web session and puts
user= and pass= in every stream, video and HLS URL the web UI builds,
in multi-server requests and in zmu command lines. hashed has been the
default for a long time and does none of that.

Mark plain as deprecated in the option's description and help, and
have zmpkg.pl log one Warning at start when authentication is on and
the relay is plain, pointing at hashed with ZM_AUTH_HASH_SECRET set.
The warning is logged once per start rather than per web request so it
does not flood the log. The option's values and behaviour are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9ccb904bca)
2026-10-31 09:04:37 -04:00
Isaac Connor 2e50bdc431 Merge pull request #5360 from connortechnology/8g63-config-secret-oracle
fix: stop the Config API leaking secret values (GHSA-8g63-hqg8-82cv)
2026-10-30 08:51:27 -04:00
Isaac ConnorandClaude Opus 4.8 5f702842a5 fix: stop the Config API leaking secret values refs GHSA-8g63-hqg8-82cv
Two ways a System=View account could read secrets through the Config API.

The oracle: ConfigsController::index() passed the caller's named filter to
buildFilter() and returned the matched rows. redactSecret() blanked a secret
Value in the response but not in the WHERE clause, so a filter such as
Name:ZM_AUTH_HASH_SECRET/Value LIKE:a% returned the row for a correct prefix
and nothing otherwise - the row count leaked the secret a character at a time,
and that secret signs auth tokens. index() now detects a filter on the Value
column and drops the secret rows from the result, so their presence reveals
nothing; a filter on any other column is unaffected.

The flags: ZM_JANUS_SECRET, ZM_UPLOAD_PASS and ZM_MQTT_PASSWORD held secrets
but were not marked Private, so the API returned them to System=View and
skin.js.php wrote them into every page as JavaScript constants. Mark them
private in ConfigData.pm.in (fresh installs) and add a Config UPDATE to the
untagged 1.39.41 migration (existing installs). No web page reads the three;
zmfilter, zmc and the Janus integration read them server side.

Tested: tests/php/test_config_value_filter.php (11 cases) covers the Value
detection, including Model.Value, case, and the DefaultValue non-match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-28 19:20:54 -04:00
Isaac ConnorandClaude Opus 5 0e19f4fb4c feat: set the ntp server, timezone and daylight saving rules on Herospeed cameras
Both cameras found on this network kept accurate UTC with no timezone set, so
their clocks were five hours out on the overlay while the recordings
themselves were correctly stamped. The factory daylight saving rule was also
nonsense everywhere: thirty minutes, March to September.

set_time points the camera at an ntp server and sets its timezone, with
optional summer time rules. The timezone is derived from a UTC offset rather
than hardcoded: the vendor's list starts at GMT-12:00 and steps every thirty
minutes, so -6 becomes index 12, which its own language pack labels
"(GMT-06:00) Central Time (US&Canada)". An offset with no index, a quarter
hour zone say, is refused instead of silently rounded.

These settings live in flash and set_time is meant to be safe to re-run, so
nothing is written unless it differs. Verified against a camera: an unchanged
call issues no write at all, a changed server issues exactly one, and
restoring it issues one more. The comparison recurses into the nested start
and end rules, which would otherwise always differ as hash references, and
compares as strings because the camera returns numbers and JSON booleans
interchangeably.

dstType is deliberately not sent. Supplying week based rules makes the camera
set it itself, and it rewrote the value we sent, so sending one would mean a
read back that never matches what was written.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvTCzCbvGt8xKQRNCSA7o8
2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 5 3a8abce499 feat: add the Herospeed control definition, and fix the id in the unsupported-command message
Controls entry for the Herospeed / LS Vision web api protocol, as both a
migration for existing installs and a controls.sql row for fresh ones.

Capabilities match what /api/image/ptz-ctrl actually offers: continuous move
in eight directions, zoom, focus with autofocus, iris, 255 presets with a home
and the ability to store them, reset and reboot, and the white floodlight.
CanMoveAbs, CanMoveRel and CanMoveMap stay 0 - the api has no absolute,
relative or map move. Speeds are 1-8 because the device advertises no range
anywhere, so the module clamps to the window every optType was observed to
accept.

Also fixes the message added with the can() guard: "monitor $id's" parses as
$id::s, the old package separator, so the monitor id silently vanished from
the one line whose job is to say which monitor to go and look at. Found by
reading the message the running daemon actually emitted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvTCzCbvGt8xKQRNCSA7o8
2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 5 4be5ca4744 feat: drive Herospeed cameras entirely through their own web api
Replaces the ONVIF subclass with a standalone protocol. ONVIF stays as it is
and remains the right choice for these cameras when only pan, tilt, zoom and
imaging are wanted; this exists for what ONVIF cannot reach on them.

The full ptz surface now goes through /api/image/ptz-ctrl, whose optType
values are taken from the web ui's PTZ_CONTROL_CMD_* constants: the eight
move directions and stop, zoom, focus including one-key autofocus, iris, auto
pan, lens initialisation, and presets by index and name. /api/image/ptz-info
adds pan, tilt and zoom position read-back, which ONVIF does not offer here.

The white supplement floodlight is dayNightMode.ledMode in
/api/image/image-param, switched between Warm Light and IR Light. ONVIF
exposes no light at all on this hardware - both GetRelayOutputs and the PTZ
auxiliary Wiper command are accepted and neither does anything measurable.

Login is the camera's five round handshake, with the session cookie returned
in the response body rather than a Set-Cookie header. The rounds are pure
functions and a captured exchange is replayed by a test: each one hashes the
raw bytes the previous hex digest names rather than its text, and getting
that wrong produces an equally plausible digest whose only symptom is a
refused login. Code 101 means the session expired, so every call re-logins
once and retries rather than dropping an operator's keypress.

Speed is clamped: the device advertises no range anywhere in its api or ui.
Preset indexes are validated before being sent for the same reason.

Standing alone also means no imports are inherited. Missing ones are invisible
to perl -c and only fail on the path that uses them, so the tests assert the
required modules are actually loaded.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvTCzCbvGt8xKQRNCSA7o8
2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 5 bcb0fa85a5 feat: add a control module for Herospeed / LS Vision cameras
These identify themselves as Manufacturer "NONE", Model "IPCamera" over
ONVIF; the real name is in the ONVIF scope (name/L5TW), in the vendor api's
/system/device-info, and in the 2C:6F:51 OUI.

PTZ, presets and imaging are inherited from the ONVIF module, which the
camera implements well - absolute, relative and continuous move, 256 presets,
brightness through sharpness, and motion and tamper events.

What ONVIF does not expose is the white supplement floodlight the deterrence
feature uses. GetRelayOutputs and the PTZ auxiliary Wiper command are both
accepted by the camera and both do nothing measurable. The light lives in the
vendor REST api at /api/image/image-param, as dayNightMode.ledMode, switched
between Warm Light and IR Light.

Reaching that api needs its login handshake: sha256 over
username+salt+base64(timestamp)+password, rehashed over the raw digest bytes
with the challenge appended, optionally iterated, with the session cookie
returned in the response body rather than a Set-Cookie header. The rounds are
pure functions so the captured exchange is replayed by a test; the raw-bytes
versus hex-text distinction in particular produces an equally plausible digest
when wrong, so it is pinned rather than trusted.

The section write echoes every field back, since a partial write makes the
camera drop what it was not sent.

Note the supplement light only engages while the camera is in night mode, so
setting it during the day reads back correctly but produces no light.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvTCzCbvGt8xKQRNCSA7o8
2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 5 aed16db997 fix: ignore a control command the protocol does not implement instead of dying
zmcontrol dispatches straight onto the control object with
$control->$command(...). A monitor's actions and ui buttons are configured
independently of its control protocol, so nothing stops a LightOn action
pointing at a protocol with no lightOn, and Perl kills the control server with
"Can't locate object method".

Swapping a camera for a different make produces exactly that. A monitor whose
AMLink camera was replaced by an ONVIF one kept its LightOn and LightOff
actions, and ONVIF has neither, so the first alarm after the protocol change
would have taken the control server down for that monitor.

Check can() before dispatching, log which monitor and command need attention,
and answer a caller that asked for a response rather than leaving it hanging.
Direct protocol mode gets the same check, as a Fatal, since there the command
came from the command line and is a typo worth reporting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvTCzCbvGt8xKQRNCSA7o8
2026-10-28 18:01:26 -05:00
Isaac Connor 7bee4417fa Increase debug level of select timed out 2026-10-28 18:01:26 -05:00
Isaac ConnorandClaude Opus 5 78f389cdea feat: add ZM_ALLOWED_COMMANDS to restrict what filters and tasks may run refs #4957
Two places in ZoneMinder run a command the operator typed: a filter with
"Execute command", and the scheduled tasks added for #4957. Both run it as the
web user through a shell, which is close to shell access on the server. Until
now the only control over that was who may edit, and the answer was anyone
with System rights.

ZM_ALLOWED_COMMANDS names the programs that may be run, comma separated.
Empty is the default and places no restriction, so an upgrade changes nothing
and the filters people already have keep working; setting it narrows both
features at once.

Only the program is matched, because an exact whole-command match could never
work for filters: zmfilter.pl appends the event path to whatever the filter
stored, so no two runs have the same command line. Arguments are therefore
free, which means the program being on the list has to be the whole of the
guarantee -- so while a list is in force a command may not contain the
characters that start another program: semicolon, pipe, ampersand, backtick
and dollar-paren. Without that, "/usr/local/bin/backup.sh; anything" would
pass on the strength of its first word. Redirection is deliberately allowed;
it starts no program, and refusing it would break the ordinary
"... >> /var/log/mine.log".

Refused in three places, because each answers a different question. The
filter and scheduled task editors refuse on save, so the operator is told at
the time rather than by a log line days later. zmfilter.pl refuses at the
moment it runs, because a row can reach the database without passing through
the web ui and because the setting may have been narrowed since. And
cronRebuild leaves a newly disallowed task out of the crontab, so tightening
the setting takes jobs away rather than waiting for somebody to edit each one.

The rule exists twice, in web/includes/Command.php and ZoneMinder::General,
since one is PHP and the other Perl. Rather than hope they stay in step,
tests/php/test_allowed_commands.php puts every case to both and fails if they
disagree. That earned itself immediately: both split the command on
whitespace before handling quotes, so a program path containing a space was
cut in half and compared as the wrong string. The cross-check found it in
both at once.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-28 18:01:25 -05:00
Nic Boet 877342fe2e fix: skip a missing event directory in zmeventtool renumber instead of dying
Perl's continue is not loop control: outside a given/when block it dies with
"Can't \"continue\" outside a when block", so renumber stopped at the first
event whose directory was missing and never handled the ones after it.

fixes #5340
2026-10-24 10:33:16 -05:00
Isaac Connor 3709c423fa Merge pull request #5333 from connortechnology/fix-zmfilter-newline-9v28
fix: quote zmfilter tag values with a trailing newline (GHSA-9v28-c6w5-v8w6)
2026-10-24 10:27:33 -04:00
Isaac ConnorandClaude Opus 4.8 2e7fd06d95 fix: remove dangling monitor links with unlink() instead of a shell rm
zmaudit removes a filesystem monitor link that no longer points to a valid
monitor directory with executeShellCommand("$ZM_PATH_RM \"$link\""). The link
name is the monitor name. The web layer names the link from the raw request
(basename($_REQUEST['newMonitor']['Name'])) rather than the filtered name
stored in the database, so it can contain shell metacharacters that the stored
name cannot. Inside the double-quoted rm argument, $(...) and backticks in the
name are still expanded, so a user with Monitors create/edit can have zmaudit
run arbitrary shell commands when it later cleans up the dangling link.

Use Perl unlink() on the de-tainted link name: it removes the symlink itself
with no shell, so nothing in the name is interpreted.

Addresses GHSA-746p-4622-p3fr.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-23 22:32:04 -04:00
Isaac ConnorandClaude Opus 4.8 463a333a93 fix: anchor the zmfilter plain-value test with \z so a trailing newline is quoted
When building an AutoExecute command, zmfilter treats a substituted tag value
as plain (inserted into the command unquoted) when it matches
/^[\w\/.,:+=@% -]*$/. In Perl $ also matches immediately before a trailing
newline, so a value like "foo\n" is classed plain and inserted bare. The
newline then terminates that shell command line; a second plain tag placed
after it on the template is run as its own command. A user with Events edit
controls event fields that feed tags, so on a filter with an AutoExecute action
this is authenticated command execution.

Anchor with \z (true end of string) instead of $, so any trailing newline fails
the plain test and the value is quoted like other unsafe input.

Addresses GHSA-9v28-c6w5-v8w6.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-23 22:30:47 -04:00
Isaac Connor b7405c58c5 Merge pull request #5288 from nabbi/hard/auth-default
Ask at first run whether to require a login, and refuse the password admin
2026-10-16 19:03:06 -04:00
Isaac ConnorandClaude Opus 5.5 cbc2eaa334 fix: set the Private and System flags of options on fresh installs and on update
zmconfgen.pl wrote zm_create.sql's Config rows without the Private and System
columns, so a database created from it had both at 0 for every option until
zmupdate.pl -f rewrote the table from ConfigData. The web UI relies on Private
to keep a secret out of the browser: skin.js.php exports every option that
isn't Private as a JavaScript constant on every page, the login page
included, and the Options page shows a Private value only to users who can
edit System settings (GHSA-7g3f-93q8-fhwj). So on such a database
ZM_AUTH_HASH_SECRET, which is enough to sign an admin token, was sent to
anyone who loaded the login page. A fresh RPM install is one: the spec runs
zmupdate.pl -f only on upgrade. Debian packages run -f on install.

- zmconfgen.pl writes Private and System like saveConfigToDB() does.
- ZoneMinder::Config::syncConfigFlags() sets each row's Private and System
  flags from ConfigData without touching its value, and zmupdate.pl calls it
  on every update, so an existing database is repaired the next time it is
  updated without needing -f.
- skin.js.php never exports a password option, whatever its flag says.

Tested with zm_create.sql generated from this tree, loaded into a scratch
database: the fresh install has the 3 Private options and 1 System option
ConfigData marks. With every flag zeroed, syncConfigFlags() set those 4 rows
and on a second run changed none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:50:30 -04:00
Nic Boet b631d2efc9 feat: add a minimum length for new passwords refs #5287
Add ZM_PASSWORD_MIN_LENGTH (Options, System; default 8, 0 turns it off).
passwordProblem() refuses a shorter password, so the user page, the API
and both login-page forms apply it alike. Existing passwords keep
working; only a password being set is checked. The length counts
characters, not bytes.

There is no setting for character classes: they push people to
predictable variations (Password1!) and add less than length does.

A database whose Config table doesn't have the option yet (an upgrade
not run with zmupdate.pl -f) gets no minimum. The password inputs carry
minlength so the browser says so before the form is sent; the server
check is the one that counts. The API answers with the English text, as
for the other reasons.

Tests: tests/php/test_default_password.php.
2026-10-16 10:13:53 -05:00