Skip to content

fix(security): bound network and resource use, and pin outbound targets - #276

Merged
SteveGilvarry merged 3 commits into
masterfrom
security/3-network-limits
Nov 18, 2026
Merged

SteveGilvarry merged 3 commits into
masterfrom
security/3-network-limits

Conversation

@SteveGilvarry

Copy link
Copy Markdown
Member

Unauthenticated:

  • No listener limited how long a client could take to send request
    headers, so stalled connections were held open (Slowloris). All
    listeners now drop them after 30 seconds; a test with a control shows
    the difference. The plain HTTP listener moves from axum::serve to
    axum_server, which is what lets the timeout be set.
  • A request body that stalls ends after 30 idle seconds.
  • The rate limiter never dropped per-client entries, and counted every
    address in an IPv6 /64 separately.
  • RTSP: one address could hold every connection slot; now 16.
  • ONVIF discovery: a host could answer a probe with unlimited devices;
    now 256.

Outbound:

  • The ONVIF client refuses this server and cloud metadata addresses, no
    longer follows redirects in the event listener, caps response size, and
    connects to the addresses it checked (DNS rebinding).
  • A capture path may not point at a cloud metadata service.
  • The client for the search models and telemetry had no timeout.

Limits for logged-in users:

  • Frame decodes and synopsis stills: one per core. VOD packaging: two.
    Exports: four. On-demand worker commands: two per monitor.
  • WebRTC: 64 ICE candidates per session, SDP up to 64 KiB, WebSocket
    messages up to 256 KiB.
  • Generated videos: 7680 a side. Page numbers: clamped so the offset
    cannot overflow. The synopsis still cache and the probe cache are
    bounded.
  • The request log span records the path, not the query string, which can
    carry ?token= or ?st=.

Notes for review

  • Third of five stacked PRs; based on the leaks and logging PR.
  • The plain HTTP listener now runs on axum_server, like the TLS ones. Its tests start a real listener; the packaging e2e test was not run.
  • Adds hyper-util as a direct dependency (already in the lockfile) and tower-http's timeout feature.
  • The limits queue or refuse with 503. The numbers are first guesses and easy to change.
  • a_connection_must_authorize_before_the_deadline (RTSP, not touched here) fails intermittently on macOS with a connection reset where it expects EOF.

🤖 Generated with Claude Code

SteveGilvarry and others added 2 commits November 18, 2026 09:01
- zmcontrol.pl's stderr went back to whoever sent a PTZ command. A control
  module's errors quote the camera URL, password included.
- `GET /storage` showed view-only System users the S3 secret key in
  `Storage.Url`.
- A recording that could not be probed returned its full path on the
  server.
- A reqwest error names the URL it was sent to; `HttpClientError` now
  returns a generic message, as database errors do.
- `auth_middleware` logged the whole URI at debug, query-string token
  included.
- The login handler logged the username before validating it, so a line
  break in it forged log lines. Same for the server control action.
- `DatabaseConfig`, `TurnConfig` and `SentryConfig` printed their
  password or DSN through `Debug`. Nothing prints them today.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Unauthenticated:
- No listener limited how long a client could take to send request
  headers, so stalled connections were held open (Slowloris). All
  listeners now drop them after 30 seconds; a test with a control shows
  the difference. The plain HTTP listener moves from `axum::serve` to
  `axum_server`, which is what lets the timeout be set.
- A request body that stalls ends after 30 idle seconds.
- The rate limiter never dropped per-client entries, and counted every
  address in an IPv6 /64 separately.
- RTSP: one address could hold every connection slot; now 16.
- ONVIF discovery: a host could answer a probe with unlimited devices;
  now 256.

Outbound:
- The ONVIF client refuses this server and cloud metadata addresses, no
  longer follows redirects in the event listener, caps response size, and
  connects to the addresses it checked (DNS rebinding).
- A capture path may not point at a cloud metadata service.
- The client for the search models and telemetry had no timeout.

Limits for logged-in users:
- Frame decodes and synopsis stills: one per core. VOD packaging: two.
  Exports: four. On-demand worker commands: two per monitor.
- WebRTC: 64 ICE candidates per session, SDP up to 64 KiB, WebSocket
  messages up to 256 KiB.
- Generated videos: 7680 a side. Page numbers: clamped so the offset
  cannot overflow. The synopsis still cache and the probe cache are
  bounded.
- The request log span records the path, not the query string, which can
  carry `?token=` or `?st=`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@SteveGilvarry
SteveGilvarry force-pushed the security/2-leaks-logging branch from 8a19ba1 to c12a976 Compare November 17, 2026 22:03
@SteveGilvarry
SteveGilvarry force-pushed the security/3-network-limits branch from d5cbcf4 to 648706f Compare November 17, 2026 22:03
@SteveGilvarry
SteveGilvarry changed the base branch from security/2-leaks-logging to master November 17, 2026 23:53
@SteveGilvarry
SteveGilvarry merged commit 770e9f3 into master Nov 18, 2026
27 of 29 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant