Commit Graph
96 Commits
Author SHA1 Message Date
Isaac Connor 9f3f6c6770 fix: only trust X-Forwarded-For from configured proxies for auth hash IPs
With ZM_AUTH_HASH_IPS on, the client address bound into the auth hash was
taken from the left-most X-Forwarded-For value whenever the header was
present, both when PHP generated the hash (getRemoteAddr()) and when PHP or
zms validated it (getAuthUser(), zmLoadAuthUser()). The header is client
controlled, so anyone holding a leaked hash could replay it from anywhere by
sending the address it was bound to.

Add ZM_AUTH_TRUSTED_PROXIES, a list of exact reverse proxy addresses.
X-Forwarded-For is now used only when REMOTE_ADDR is one of them, and is read
from the right, skipping hops that are themselves listed proxies, so values a
client prepends are never chosen. With the option empty, the default, the
header is ignored and REMOTE_ADDR is used.

PHP (web/includes/Network.php getRemoteAddr()) and C++ (ClientAddress() in
zm_utils, used by zmLoadAuthUser()) implement the same rule so generation and
validation continue to agree. Every PHP caller already routes through
getRemoteAddr(), so session.php and auth.php need no change.

Reverse proxy users who enable ZM_AUTH_HASH_IPS must list their proxy in the
new option; until they do, hashes bind to the proxy address, which still
validates but no longer distinguishes clients. This is the behaviour change
that the #4921 work avoided by trusting the header.

The option is added through ConfigData only, like other recent options;
zmupdate.pl --freshen inserts it, zms falls back to the compiled-in default and
PHP treats an undefined constant as empty, so no schema migration is needed.

Tests: ClientAddress Catch2 case; tests/php/test_remote_addr.php updated for
the trusted-proxy rule.

refs GHSA-72rf-54rm-798c

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit acea5889dec0826f595cb736147a5fdc9c94a2a9)
2026-09-24 19:51:27 -04:00
Jash 1e7d8e1dd9 fix: cast tv_usec for %jd so armhf varargs stay aligned refs #4580 2026-08-26 11:23:11 +05:30
Jash bd3097be58 fix: escape JSON strings in a single pass so quotes are not double-escaped 2026-08-17 04:39:24 +05:30
Jash 3983db5357 fix: percent-encode non-ASCII bytes in UriEncode and escape go2rtc JSON fields 2026-08-16 15:37:21 +05:30
Isaac ConnorandClaude Opus 4.8 7cd4be5cfb feat: add nph-zms memory diagnostics refs #5006
Add instrumentation to trace which stream type and workload precede the
occasional runaway memory growth in nph-zms.

- zm_utils: add zm_get_rss_kb() reading resident set size from
  /proc/self/statm
- zms: log a one-shot Debug summary of the decoded request (source, mode,
  monitor/event, connkey, scale, buffer, ttl, rss) so a runaway process
  can be tied to its stream parameters
- MonitorStream/EventStream: emit a periodic Debug RSS trace every 30s.
  The EventStream trace includes frames-vector size and frame_count,
  which scale with reloaded event length and will show whether the
  in-process event reload path drives the growth

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 09:48:44 -04:00
Isaac Connor 334994bd3f Fix appending %% instead of % when uri decoding. Add test for URIEncode 2026-02-04 20:45:46 -05:00
Isaac Connor 548991ea3c Move escape_json_string and remove_newlines to zm_utils 2025-06-26 14:53:38 -04:00
Aaron Kling c4683d90a9 Format code using astyle google format
Commands used:
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.cpp
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.h
2024-03-26 13:43:58 -05:00
Alejandro Criado-Pérez 543683aa4c Corrections on cpp and h files 2023-08-13 01:27:19 +02:00
Isaac Connor a62f4b2e77 Use snprintf instead of sprintf to quieten codeql 2023-02-23 16:52:19 -05:00
Isaac Connor 594649605c Slightly smarted UriEncode, which doens't include numbers and a few other valid characters. Needs more work and tests. 2022-09-07 09:31:50 -04:00
parvit (Vittorio Parrella) a94d74143e support for ffmpeg type camera authentication with special characters 2022-08-20 10:01:14 -04:00
Isaac Connor 365830a9ae Rough in remove_password function + tests 2022-07-04 09:53:50 -04:00
Isaac Connor 8674b32a15 Introduce mask_authentication function to replace username and password with * in url like strings 2022-04-18 13:33:10 -04:00
Isaac Connor cb30f7639f revert broken commit. Isaac doesn't know what he's doing. 2022-01-10 18:47:26 -05:00
Isaac Connor 78a10b6095 cppcheck fixes 2022-01-10 17:36:49 -05:00
pkubaj 74a2276671 Fix build on FreeBSD/armv7
1. FreeBSD uses elf_aux_info instead of getauxval.
2. FreeBSD uses HWCAP_NEON macro for Neon.
2021-11-29 00:03:45 +00:00
Peter Keresztes Schmidt eaf2e51b0c utils: Make sure the compiler can emit format warnings for stringtf
Unfortunately the compilers can't emit Wformat warnings for variadic templates
and those can't be annotated with the format attribute.
Use a variadic function which can be annotated and thus warns on format string-args mismatches.

Ref 0796a2262e
2021-07-06 10:33:17 +02:00
Peter Keresztes Schmidt ff8c9f67c1 Image: Convert API to std::chrono
Utils: Remove TimespecDiff. It is not used anymore
2021-06-13 14:50:16 +02:00
Peter Keresztes Schmidt 46155942c1 Misc: Rename namespace ZM to zm
We had a mixture of both spellings. Unify it according to our code-style.
2021-06-06 19:11:11 +02:00
Peter Keresztes Schmidt d2932b5d68 Utils: Add a ByteArrayToHexString helper 2021-05-30 22:53:05 +02:00
Isaac Connor b37aa35085 improve scope of a,b 2021-04-20 17:07:07 -04:00
Peter Keresztes Schmidt e92125afd9 utils: remove unused curl include 2021-04-04 01:18:34 +02:00
Peter Keresztes Schmidt b5f3682d4e utils: some more reshuffling/grouping and formatting 2021-04-04 01:18:34 +02:00
Peter Keresztes Schmidt 545f0dbb96 utils: cleanup Base64Encode 2021-04-04 00:39:40 +02:00
Peter Keresztes Schmidt e330f8553d utils: cleanup Split and Join 2021-04-04 00:30:18 +02:00
Peter Keresztes Schmidt 39a896f5b6 utils: cleanup StartsWith 2021-04-03 23:51:12 +02:00
Peter Keresztes Schmidt 3dbf13e00b utils: cleanup ReplaceAll 2021-04-03 23:50:35 +02:00
Peter Keresztes Schmidt 664cd649f8 utils: cleanup Trim (was trimSet) and TrimSpaces 2021-04-03 23:30:59 +02:00
Isaac Connor 3f8b9db3d9 fix UriEncode returning a string that is longer than the c_str 2021-03-24 13:29:17 -04:00
Peter Keresztes Schmidt 7e86e1ef40 utils: Make TimevalToString thread-safe 2021-03-21 21:42:02 +01:00
Isaac Connor 5d968358f7 Need to use ZM::make_unique because std::make_unique is c++14 2021-03-10 16:35:03 -05:00
Isaac Connor 000df68f72 include memory 2021-03-10 16:17:26 -05:00
Isaac Connor aadee4ea65 add a Query String parse in zm_utils
add an authenticator to use with RtspServer
2021-03-10 13:20:14 -05:00
Peter Keresztes Schmidt 0796a2262e Utils: Replace stringtf with a type-safe version that can't overflow 2021-03-06 00:12:18 +01:00
Isaac Connor 8f783c0ec4 Must also include cstdarg for va_start etc al 2021-02-09 23:32:27 -05:00
Isaac Connor 9879a40c4b Must include cstring 2021-02-09 23:32:27 -05:00
Peter Keresztes Schmidt 0dbc39ee25 Cleanup and reorganize includes
With this commit a unified structure for includes is introduced.
The general rules:
 * Only include what you need
 * Include wherever possible in the cpp and forward-declare in the header

 The includes are sorted in a local to global fashion. This means for the include order:
  0. If cpp file: The corresponding h file and an empty line
  1. Includes from the project sorted alphabetically
  2. System/library includes sorted alphabetically
  3. Conditional includes
2021-02-04 18:02:01 +01:00
Peter Keresztes Schmidt 5a57efdfe2 Replace deprecated C header includes with the C++ ones. 2021-02-04 05:39:03 +01:00
Isaac Connor 2eda49333f Merge branch 'master' into zma_to_thread 2020-10-20 16:20:29 -04:00
Isaac Connor 7d1598ae50 Merge branch 'master' into gcc_cpuid 2020-10-09 08:47:30 -04:00
Isaac Connor a39a656373 Merge branch 'master' into zma_to_thread 2020-09-29 11:02:40 -04:00
Peter Keresztes Schmidt 8f980a1168 Convert NULL/0 to nullptr
The 0 -> nullptr changes should definitely improve readability.
2020-08-26 22:03:40 +02:00
Isaac Connor 2773737e54 Use gcc builtin functions for cpuid 2020-08-19 16:57:20 -04:00
Isaac Connor 5fb56c9f57 Merge branch 'master' into zma_to_thread 2020-08-07 17:52:43 -04:00
Isaac Connor f4a0f91d7f nothing 2020-07-24 15:27:05 -04:00
Isaac Connor 869860bb26 Merge branch 'master' into zma_to_thread 2020-07-21 17:49:39 -04:00
Isaac Connor 7575afc8d5 Merge branch 'master' into zma_to_thread 2020-07-21 17:38:32 -04:00
Isaac Connor d716d1d686 Merge branch 'release-1.34' 2020-07-20 16:25:41 -04:00
Isaac Connor 01892352da rename sseversion to sse_version 2020-07-19 17:50:47 -04:00