Security: SSRF denylist at the capture URL seams - #4
Merged
Conversation
Server-side capture could be steered at internal addresses (cloud metadata 169.254.169.254, localhost admin panels, RFC1918) — pre-existing and app-wide, reachable from every create path (POST /items, /share, assign, refetch) plus archival snapshots. Add assertCapturableUrl() and call it at the two seams every server user-URL fetch routes through: dispatchCapture (url-screenshot + url-readable) and the snapshot capture(). Buffer (manual-upload) sources fall through; operator CLIs (add.ts) are out of scope. Guard = scheme allowlist (http/https) + private/loopback/link-local/ULA/CGNAT ranges via net.BlockList (IPv4, IPv6 ::1, IPv4-mapped) + numeric-encoded IPv4 (decimal/hex) + localhost-family hostnames + a DNS-resolve-and-recheck (the real evil.com→10.0.0.5 vector). Fail-closed/clean: a blocked URL throws → the item's capture-error path marks it `error`, no crash. Zero new deps (node:net/dns). Residuals (documented): DNS-rebinding TOCTOU (puppeteer/fetch re-resolve at connect time); octal-per-octet / mixed numeric encodings; IPv6 forms net.isIP rejects. Table-driven bypass test (userinfo, [::ffff:127.0.0.1], 2130706433, 0x7f000001, scheme, DNS→private). Suite 508 pass / 0 fail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Re-opens the SSRF work from #3 (auto-closed when its stacked base branch was deleted on PR #2's merge). Same change, now based directly on
main.Adds
capture/net-guard.ts#assertCapturableUrl, called at the two seams every server user-URL fetch routes through (dispatchCapture+ the snapshotcapture()): scheme allowlist + private/loopback/link-local/ULA ranges (net.BlockList, IPv4-mapped IPv6, numeric-encoded IPv4) + localhost-family hostnames + a DNS-resolve-and-recheck (the realevil.com → 10.0.0.5vector). Fail-closed: a blocked URL throws → the item's capture-error path marks iterror. Zero new deps.Residuals documented: DNS-rebinding TOCTOU; octal/mixed numeric encodings; IPv6 forms
net.isIPrejects. Table-driven bypass test + two seam tests. Full suite green.