Skip to content

Validate webhook target hostname Unicode/homograph normalization in src/webhooks/ssrfGuard.ts #513

Description

@Jagadeeshftw

📌 Description

src/webhooks/ssrfGuard.ts validates webhook targets, but its hostname handling does not normalize internationalized/Unicode hostnames (IDNA/punycode) before the safety checks. A homograph or non-normalized Unicode hostname could be presented that bypasses string-based checks while resolving to an unexpected host.

💡 Why it matters: SSRF guards that compare raw (non-normalized) hostnames can be evaded with Unicode look-alikes; normalization to punycode before validation closes that gap.

🧩 Requirements and context

  • Normalize the hostname to ASCII/punycode (IDNA) before applying allow/deny and private-range checks.
  • Reject hostnames that fail normalization or contain disallowed characters.
  • Ensure the normalized hostname is what gets resolved/connected to (consistency between check and use).
  • Add tests with Unicode/IDN and homograph hostnames alongside normal ASCII hosts.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b fix/ssrf-idna-normalization

2. Implement changes

  • Write/modify the relevant source: src/webhooks/ssrfGuard.ts
  • Write comprehensive tests: a new spec under tests/webhooks/
  • Add documentation: inline TSDoc on normalization rules
  • Include TSDoc doc comments
  • Validate security assumptions: check-vs-use consistency

3. Test and commit

  • Run tests:
npm test
  • Cover edge cases: IDN host, homograph host, invalid Unicode, normal host
  • Include test output and security notes in the PR description.

Example commit message

fix(ssrf): normalize hostnames to punycode before validation

✅ Acceptance criteria

  • Hostnames normalized to ASCII/punycode before checks
  • Non-normalizable/disallowed hostnames rejected
  • The validated hostname is the one used to connect
  • Tests cover IDN/homograph cases

🔒 Security notes

Confirm there is no check-then-use mismatch that lets a different host be contacted than validated.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issueStellar WaveIssues in the Stellar wave programbackendBackend service worksecuritySecurity hardening

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions