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

fix: reject invalid/expired stream authSig with 403 (avoid HA IP bans)#956
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

1 participant