fix(security): resolve SSRF bypass via 0.0.0.0 routing to localhost#3218
Open
desireddymohithreddy0925 wants to merge 6 commits into
Open
Conversation
… for stargazers API
desireddymohithreddy0925
requested a review
from Priyanshu-byte-coder
as a code owner
July 19, 2026 15:52
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
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
This PR fixes an SSRF vulnerability where a domain resolving to
0.0.0.0bypassed the private IP check. It also removes the unrelated workflow andpackage.jsonchurn from the previous PR attempt.Closes #3199
Type of Change
What Changed
src/lib/ssrf-protection.ts: Added0.0.0.0/8(This network) to thePRIVATE_RANGESblocklist.src/lib/ssrf-protection.test.ts: Created a new test file with explicit cases demonstrating that0.0.0.0(both direct IP and DNS-resolved) is correctly blocked.How to Test
npm run test -- src/lib/ssrf-protection.test.tsin your terminal.http://0.0.0.0/and any mocked DNS resolution pointing to0.0.0.0.npm run lintandnpm run type-checkto verify no unrelated files were touched and the build remains clean.Expected result: The SSRF protection mechanism should successfully reject URLs resolving to
0.0.0.0, preventing routing tolocalhoston Linux/macOS systems.Checklist
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)Additional Context
While the original issue stated that
ipToNumberwas overflowing, that function was actually correctly coercing standard IPs to unsigned 32-bit integers. The true bypass occurred becauseipToNumber("0.0.0.0")evaluates to0, which was entirely missing from the blockedPRIVATE_RANGES. This PR is highly focused and only modifies the SSRF protection logic and tests.