fix(security): token CSPRNG + proxy-trust + og:image hardening (LC-155) #191
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/lc-155-token-csprng-hardening"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Defense-in-depth hardening bundle from the LC-148 audit (S10-S12).
generate_api_token) now draw fromrand::rngs::OsRngexplicitly.thread_rngis already CSPRNG-backed, so this is not a live vuln; the point is to put the guarantee in the source rather than have it be incidental to the default RNG. Scoped to the security tokens the audit named (not the wider set ofthread_rngcallers, which are equally CSPRNG-backed today).extract_session_originonly trusts theX-Forwarded-For/X-Real-IPclient IP when the deployment opts into proxy headers; otherwise the stored session / login-alert IP isNonerather than a forgeable value. New sharedauth::proxy_headers_trustedhelper (readstrust_proxy_headers) used by both the session-origin extractor and the rate limiter, so both honor one switch. User-Agent is still always captured (display-only).og:imageis resolved against the final page URL and kept only when it is an absolute http/https URL, so a page can't put ajavascript:/data:/ other-scheme value into an<img src>. Dropped (not neutralized) when disallowed.Test
sanitize_image_urlunit tests (absolute + relative http(s) accepted;javascript:/data:/vbscript:/file:rejected).just check/just test/just test-saasgreen (theroutes_uploadsflake under concurrent-binary load is pre-existing and passes in isolation; no upload code touched).Completes the security findings in the LC-159 post-audit story (LC-149 through LC-155).
🤖 Generated with Claude Code