Skip to content

fix(security): resolve SSRF bypass via 0.0.0.0 routing to localhost#3218

Open
desireddymohithreddy0925 wants to merge 6 commits into
Priyanshu-byte-coder:mainfrom
desireddymohithreddy0925:fix/ssrf-0-0-0-0-bypass
Open

fix(security): resolve SSRF bypass via 0.0.0.0 routing to localhost#3218
desireddymohithreddy0925 wants to merge 6 commits into
Priyanshu-byte-coder:mainfrom
desireddymohithreddy0925:fix/ssrf-0-0-0-0-bypass

Conversation

@desireddymohithreddy0925

Copy link
Copy Markdown
Contributor

Summary

This PR fixes an SSRF vulnerability where a domain resolving to 0.0.0.0 bypassed the private IP check. It also removes the unrelated workflow and package.json churn from the previous PR attempt.

Closes #3199


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only (or added test coverage)

What Changed

  • src/lib/ssrf-protection.ts: Added 0.0.0.0/8 (This network) to the PRIVATE_RANGES blocklist.
  • src/lib/ssrf-protection.test.ts: Created a new test file with explicit cases demonstrating that 0.0.0.0 (both direct IP and DNS-resolved) is correctly blocked.

How to Test

  1. Run the newly added test suite by executing npm run test -- src/lib/ssrf-protection.test.ts in your terminal.
  2. Verify that the test passes, successfully blocking http://0.0.0.0/ and any mocked DNS resolution pointing to 0.0.0.0.
  3. (Optional) Run npm run lint and npm run type-check to 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 to localhost on Linux/macOS systems.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Additional Context

While the original issue stated that ipToNumber was overflowing, that function was actually correctly coercing standard IPs to unsigned 32-bit integers. The true bypass occurred because ipToNumber("0.0.0.0") evaluates to 0, which was entirely missing from the blocked PRIVATE_RANGES. This PR is highly focused and only modifies the SSRF protection logic and tests.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:devops GSSoC type bonus: devops (+15 pts) type:security GSSoC type bonus: security (+20 pts) type:testing GSSoC type bonus: tests (+10 pts) labels Jul 19, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:security GSSoC type bonus: security (+20 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant