Skip to content

fix: reject invalid/expired stream authSig with 403 (avoid HA IP bans) - #956

Open
joyjit wants to merge 1 commit into
AlexxIT:masterfrom
joyjit:fix/authsig-403-no-ip-ban
Open

joyjit wants to merge 1 commit into
AlexxIT:masterfrom
joyjit:fix/authsig-403-no-ip-ban

Conversation

@joyjit

@joyjit joyjit commented Jul 17, 2026

Copy link
Copy Markdown

Summary

  • Invalid/expired authSig (and bad HLS session cookie) previously raised HTTPUnauthorized (401).
  • Home Assistant's ban middleware treats every 401 as a failed login, so sleeping WebRTC card tabs could IP-ban the client after login_attempts_threshold hits — including a household WAN address behind use_x_forwarded_for.
  • Raise HTTPForbidden (403) instead: stream still rejected, login ban counter untouched.

Fixes #955

Test plan

  • Open a Lovelace view with custom:webrtc-camera, confirm live stream still works (fresh auth/sign_path → websocket upgrade).
  • With login_attempts_threshold ≥ 1, send multiple /api/webrtc/ws requests with garbage authSig (optionally via X-Forwarded-For through a trusted proxy): expect 403, no Login attempt or request with invalid authentication log lines, IP not added to ip_bans.yaml.
  • Confirm real unauthenticated API access (e.g. /api/states without token) still increments failed logins / can ban — protection unchanged.
  • (Optional) Leave a cameras dashboard tab sleeping past the 30s signature lifetime; reconnects should not ban the client IP.

Verified locally on HA with WebRTC v3.6.1 using the above probe pattern before opening this PR.

Home Assistant's HTTP ban middleware counts every HTTPUnauthorized as a
failed login. Sleeping dashboard tabs that reconnect with an expired
authSig were self-banning client IPs (especially behind
use_x_forwarded_for). Raise HTTPForbidden so the stream is still denied
without touching the login ban counter.

Fixes AlexxIT#955
davidcoulson added a commit to davidcoulson/WebRTC that referenced this pull request Sep 11, 2026
Cherry-picked 5 unmerged bug-fix PRs from upstream AlexxIT/WebRTC
(stale since 2025-11-26):
- PR AlexxIT#938 (vinnybad): fix InvalidStateError crash in MSE updateend handler
- PR AlexxIT#956 (joyjit): reject expired/invalid stream authSig with 403 instead
  of 401, avoiding HA's own login-ban middleware locking out the household
- PR AlexxIT#961 (skircr115): prevent TypeError in ws_poster when image is None
- PR AlexxIT#942 (mayerwin): fix media_player.play_media via go2rtc /api/ffmpeg
- PR AlexxIT#951 (daveyijzermans): only fall back to muted playback on
  NotAllowedError, not on every transient play() rejection
@AlexxIT AlexxIT self-assigned this Oct 8, 2026
@AlexxIT AlexxIT added the enhancement New feature or request label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid/expired stream authSig raises HTTPUnauthorized (401), which HA counts as failed logins and can IP-ban clients

2 participants