Skip to content

Production hardening: toolchain, SFU, moderation, config, frontend fixes - #9

Merged
davidtorcivia merged 5 commits into
masterfrom
audit/production-hardening
Sep 3, 2026
Merged

davidtorcivia merged 5 commits into
masterfrom
audit/production-hardening

Conversation

@davidtorcivia

Copy link
Copy Markdown
Owner

Go 1.26.8 and pion/x dependency bump (govulncheck reachable count 13 to 0), with the loopback ICE setting the new pion/ice needs in test mode.

SFU: allocation-free header extension strip on the relay path, no spurious stream-paused broadcast on OBS reconnect, renegotiation of other viewers when a sharer's connection fails abruptly, stream key no longer logged in full.

Rooms: kicked participants get kicked_at and are excluded from every waiting-room query (migration 011); rescheduling or clearing scheduledAt re-arms or runs the lobby open flow; admin flag is atomic; connection-building signaling is rate limited per client.

Config and deploy: PRODUCTION_MODE parsing is case-insensitive and rejects typos; TRUSTED_PROXIES has no wide default; TURN denylist covers link-local and IPv6.

Frontend: a failed mic track swap keeps the working mic; glass renderer caches layout reads instead of getBoundingClientRect per frame; laser pointer resets cursor and touch-action on unmount.

Each commit body has the mechanism and the tests.

…aths

govulncheck reported 13 reachable vulnerabilities in golang.org/x/image, golang.org/x/net, pion/dtls, pion/stun and the Go 1.24 standard library. go.mod, both Dockerfiles and CI now use Go 1.26.8; pion/webrtc moves to 4.2.19 (dtls 3.1.5, stun 3.1.7, ice 4.4.0), x/image to 0.45.0, x/net to 0.58.0, x/crypto to 0.56.0. Reachable count is now 0.

pion/ice 4.4 skips the loopback interface unless IncludeLoopbackCandidate is set, so the ICELoopbackOnly test mode gathered no candidates and TestPreStreamJoin timed out. The SettingEngine now sets it in that mode only.

stripHeaderExtensions set Header.Extensions to nil, which discarded the backing array that rtp.Header.Unmarshal appends into, so every extension-bearing relayed packet allocated. It now truncates to [:0]. TestStripHeaderExtensions_ReusesCapacity asserts 0 allocs per unmarshal+strip cycle (was 2).

On an OBS reconnect SetIngest replaced the session and closed the old PeerConnection; the old session's teardown then called onStreamEnd and every viewer saw "Stream disconnected" just before the new session went live. teardown now skips onStreamEnd when ingestSuperseded reports another session owns the token. If the replacement never connects, its replacedLive flag makes it deliver the stream-end broadcast instead.

Two abrupt subscriber-removal paths (PeerConnection Failed/Closed callback, AbortSubscriberRenegotiation) discarded the list of subscribers whose senders for the departed participant's relay tracks were removed, so those viewers kept a torn-out m-line. removeSubscriberAndRenegotiate now flushes a renegotiation for each affected subscriber, as the handler-side leave path already did.

The SDP validation failure log printed the full WHIP stream key; it now uses keyPrefix. BindIngestToRoom sliced the token with [:8] unguarded; it now uses min(8, len).
…dmin flag, signaling rate limit

handleAdminKick cleared is_admitted, which made the kicked row identical to a pending join request: it appeared in ListWaiting, counted toward the participant cap in countWaiting, and AdmitWaitingParticipant, AdmitAll and handleRoomOpen readmitted it. Migration 011 adds participants.kicked_at; kick sets it and every waiting-room query adds kicked_at IS NULL. The is_admitted gate on reconnect is unchanged. TestRoomHandler_KickedNotReadmitted verifies the kicked row is not listed and Admit All leaves it unadmitted.

ensureOpenTimer arms one timer per slug and returns early if one exists, and Update never touched it, so a PATCH to scheduledAt left the timer firing at the old time. Update now cancels the timer and re-arms it for the new value; a past value fires immediately. TestRoomHandler_RescheduleResetsOpenTimer covers an auto-admit room moved earlier; TestRoomHandler_RescheduleToPast_WaitingRoom verifies a waiting-room lobby viewer receives the open event.

requireAdmin wrote Client.IsAdmin from the read pump while broadcast filters read it from other goroutines. The field is now a private atomic.Bool behind IsAdmin() and SetAdmin().

signal:offer, signal:ice-restart, signal:resubscribe and publish:offer each build or replace a PeerConnection and had no server-side limit. handleMessage now gates them through Client.AllowSignal, 30 per minute per client, and logs drops.
…, extend TURN denylist

getEnvBool compared against the exact strings true, 1 and yes, so PRODUCTION_MODE=True read as false and the server ran in dev mode: join tokens accepted from the query string, Secure cookie flag off, HSTS off. parseBool now matches case-insensitively with surrounding whitespace trimmed, and Load returns an error for any PRODUCTION_MODE value it does not recognise. TestLoad_RejectsMalformedProductionMode covers both.

docker-compose.yml defaulted TRUSTED_PROXIES to 172.16.0.0/12,10.0.0.0/8. With network_mode host, any container on the machine falls in that range and can forge X-Forwarded-For past the per-IP rate limiters. The default is removed; compose refuses to start with the variable unset and names the reverse proxy subnet as the expected value.

turnserver.conf denied the RFC1918 ranges and 127.0.0.0/8 but not 169.254.0.0/16 (cloud metadata endpoints), 0.0.0.0/8, 100.64.0.0/10, or any IPv6 range. Those are added.
…, reset laser cursor on unmount

acquireMic called installMicStream, which disposed the previous cleanup chain and repointed rawMicStream at the new capture, before attempting audioSender.replaceTrack. When replaceTrack rejected, the catch stopped previousRaw, the stream still feeding the sender in every no-chain configuration, so the mic went silent while state still reported it on. The previous chain is now held until the swap succeeds; on failure the new capture is stopped and the previous chain, raw stream and local stream are reinstalled. The denoiser fallback retry restores the same state while the second capture runs. reapplyAudioSettings stops when acquireMic returns false instead of tuning and renegotiating a sender that did not change. The test stubs a rejecting replaceTrack and verifies the first track is not stopped, the second is, and localStream still points at the first stream.

videoGlassGroup called getBoundingClientRect on the bar, up to 10 items and the video element on every animation frame while the controls were visible. Rects are now cached and re-read only when a ResizeObserver on the bar, items or video fires, a class/style/childList mutation under the bar occurs, a transitionrun or animationstart event is seen within the last 600ms, the window resizes, or the item set changes.

LaserPointerOverlay set cursor and touch-action on the video element while enabled but only cleared them through the enabled=false branch, so unmounting while active (the component is conditional on the autoplay gate) left touch-action none on the persistent video. The effect cleanup now resets both.
golangci-lint v2.6.2 is built with Go 1.25 and refuses to load a config targeting Go 1.26 ("the Go language version used to build golangci-lint is lower than the targeted Go version"). v2.13.2 is built with Go 1.27 and reports 0 issues on this tree.
@davidtorcivia

Copy link
Copy Markdown
Owner Author

CI Lint failed: golangci-lint v2.6.2 is built with Go 1.25 and cannot lint a Go 1.26 module. Pinned the action to v2.13.2, which ran clean locally on this tree.

@davidtorcivia
davidtorcivia merged commit 28c864d into master Sep 3, 2026
7 checks passed
@davidtorcivia
davidtorcivia deleted the audit/production-hardening branch September 3, 2026 19:54
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.

1 participant