fix(review): close trailing dot and *.localhost SSRF host bypasses#1382
Open
Dexterity104 wants to merge 1 commit into
Open
fix(review): close trailing dot and *.localhost SSRF host bypasses#1382Dexterity104 wants to merge 1 commit into
Dexterity104 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1382 +/- ##
=======================================
Coverage 95.35% 95.36%
=======================================
Files 191 191
Lines 20711 20712 +1
Branches 7488 7489 +1
=======================================
+ Hits 19750 19751 +1
Misses 380 380
Partials 581 581
🚀 New features to boost your workflow:
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
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.
Summary
The SSRF host guard in
src/review/content-lane/safe-url.tsreturned a public verdict for several named loopback hosts, because its checks only matched the bare forms. Two gaps let an untrusted URL passisSafeHttpUrlwhile still resolving to loopback or an internal address:new URL("https://localhost./").hostnamekeeps the dot aslocalhost., which never equalslocalhostand never ends with.local, so the guard read it as public. The parser strips the dot for IP literals, so only named hosts leaked. The same held forfoo.local.andbar.internal..*.localhostnamespace. The guard matched barelocalhostbut notdb.localhostorfoo.bar.localhost, which systemd-resolved and browsers (including the visual lane headless Chrome) resolve to loopback.The fix normalizes the host once at the shared chokepoint
hostIsPrivateOrLocal: lowercase, strip the trailing dot run, then rejectlocalhost, the*.localhostnamespace,.local, and.internal. BothisSafeHttpUrlandisSafeEndpointUrlinherit the hardening through that single function, and the duplicate.toLowerCase()at both call sites was removed so normalization lives in one place.Scope note: the trailing dot case was the reported gap. The
*.localhostcase is the same class of named loopback bypass on the same line, so both are closed together. The behavior was confirmed in Node and in the Workers runtime, and public hosts such asexample.com.stay allowed.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragenpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
npm run test:ciplusnpm audit --audit-level=moderate.npm run test:coveragereports 100% lines and branches onsafe-url.ts, with every changed line and branch arm exercised. Two negative path regression tests were added (the*.localhostnamespace and the trailing dot forms); each fails before the fix and passes after.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
Not applicable. This change is backend only and has no visible UI surface, so no screenshots are required.
Notes
source-evidence.ts(rechecked per redirect hop) and the screenshot navigation guard invisual/shot.ts, so the hardening covers both the HTTPS fetch path and the secure WebSocket endpoint path.hostIsPrivateOrLocal, which keeps a single defensive point for the lowercase plus trailing dot strip and avoids the duplicate host normalization that existed at the two call sites.