fix(security): harden hooks, watermark, ingest SSRF, and VOD raw (S-2..S-5)#26
Merged
Merged
Conversation
…..S-5) Address the remaining CRITICAL + HIGH findings from the audit. - S-2 (hooks): validate hooks at the REST boundary via a shared domain.Hook.Validate (matching the YAML path, previously the only validated entry); confine file hooks to hooks.file_root_dir (path containment, re-checked at delivery); route the webhook HTTP client through the SSRF dial guard so loopback + link-local / cloud-metadata are blocked (internal webhooks still allowed). - S-3 (watermark): reject non-literal font_color in domain validation and single-quote + escape it in the lavfi filtergraph; escapeLavfiArg now also escapes single quotes, closing the fontfile/movie breakout. - S-4 (ingest SSRF): new internal/netguard dial-time IP guard on the HTTP-TS and HLS pull clients — runs on the resolved IP so it covers DNS-rebind, redirects, and playlist-chosen hosts — plus a cross-host credential-header strip. Gated by ingestor.allow_private_targets (default off; link-local / metadata always blocked). Save-time URL speed-bump in the stream handler. - S-5 (VOD raw): serve only video-allowlisted files (404 otherwise), resolve symlinks before the mount-boundary check, and refuse mounting sensitive dirs. New config: hooks.file_root_dir and ingestor.allow_private_targets, both with backward-compatible defaults. Tests + audit notes included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the remaining CRITICAL + HIGH security findings from the audit. Shared SSRF dial guard in new
internal/netguard.S-2 (CRITICAL) — arbitrary host-file write + SSRF via hooks
domain.Hook.Validate(fileRoot)now runs at the REST boundary (Create/Update) and the YAML path (shared), closing the zero-validation gap.hooks.file_root_dir(path containment, re-checked indeliverFile).http.Client→netguard: loopback + link-local/cloud-metadata blocked (no localhost-admin / IMDS pivot); internal webhooks still allowed.S-3 (HIGH) — lavfi filtergraph injection via watermark
font_colorValidateFontColorrejects anything that isn't a plain color literal.buildTextFiltersingle-quotesfontcolor;escapeLavfiArgnow escapes single-quote too (also closes thefontfile/moviebreakout).S-4 (HIGH) — SSRF via ingest/pull input URLs
netguarddial-time IP guard on the HTTP-TS + HLS clients (resolved-IP → covers DNS-rebind, redirects, playlist-chosen hosts); cross-host credential-header strip.ingestor.allow_private_targets(default off; link-local/metadata always blocked). Save-time URL speed-bump in the stream handler.S-5 (HIGH) — arbitrary host-file read via VOD
/rawRawserves only video-allowlisted files (404 otherwise).ResolvePathresolves symlinks before the mount-boundary check;ValidateStoragerefuses sensitive system dirs.New config (backward-compatible defaults)
hooks.file_root_dir(default empty = legacy absolute-path-only; SSRF + REST-validation apply regardless).ingestor.allow_private_targets(default false → private HTTP/HLS ingest blocked; UDP multicast / RTSP / RTMP / SRT unaffected).Residuals (noted in the audit)
Tests
New
netguardsuite,TestHookValidate,TestValidateFontColor,TestValidateStorageRejectsSensitive,TestRegistry_ResolvePathRejectsSymlinkEscape+ updated existing.go build,go vet,golangci-lint(0 issues),go test -race ./...all green.