Skip to content

adding SSRF protection - #271

Merged
jshemas merged 12 commits into
masterfrom
oct-26
Oct 29, 2026
Merged

jshemas merged 12 commits into
masterfrom
oct-26

Conversation

@jshemas

@jshemas jshemas commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Summary of changes

  • Added URL and IP validation to block non-HTTP(S) URLs and private, loopback, link-local, reserved, and mapped IP addresses. See lib/isPublicAddress.ts.
  • Updated lib/request.ts to check DNS results at connection time and validate each redirect destination. Caller-provided fetch options can’t restore automatic redirect handling or replace the guarded dispatcher.
  • lib/request.ts: Always uses OGS’s DNS-guarded Undici Agent, rather than switching to a global dispatcher that may have changed after module initialization.
  • tests/unit/openGraphScraper.spec.ts: Added regression coverage for a global dispatcher changed after module load. Updated the test setup to keep requests on the test MockAgent.
  • tests/unit/static.spec.ts: Updated test setup to route requests through the test MockAgent and restore the original global dispatcher after each test.
  • Added tests for IP address validation and public/private redirect behavior in tests/unit/isPublicAddress.spec.ts and tests/unit/openGraphScraper.spec.ts.
  • Documented the SSRF protections in README.md.
  • Blacklist now applies to redirect destinations. Each URL in the redirect chain is checked against the configured blacklist before it is fetched. The existing check on the initial URL remains in place. Matching still uses substring semantics.

@jshemas jshemas changed the title October changes adding SSRF protection Oct 27, 2026
@jshemas
jshemas merged commit 42cbdf4 into master Oct 29, 2026
8 checks passed
@jshemas
jshemas deleted the oct-26 branch October 29, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant