Skip to content

fix(security): harden IPv6 SSRF checks, maxResponseSizeBytes, WebP magic bytes, and path sanitization - #7

Merged
SH20RAJ merged 1 commit into
SopKit:mainfrom
playlikeboy:fix/ssrf-ipv6-and-file-validation
Nov 27, 2026
Merged

SH20RAJ merged 1 commit into
SopKit:mainfrom
playlikeboy:fix/ssrf-ipv6-and-file-validation

Conversation

@playlikeboy

Copy link
Copy Markdown
Contributor

Summary

  • Normalize IPv6 brackets ([::1]), zone IDs, and trailing DNS dots in src/server/security/ssrf.ts, block fc00::/7 (ULA), fe80::/10 (link-local), unspecified ::, and IPv4-mapped IPv6 addresses (::ffff:127.0.0.1, ::ffff:7f00:1, ::ffff:169.254.169.254), and enforce SafeFetchOptions.maxResponseSizeBytes against both Content-Length and streamed response bodies.
  • Validate both RIFF (bytes 0–3) and WEBP (bytes 8–11) magic bytes for image/webp in src/server/security/file-validation.ts so RIFF-WAV/AVI files cannot spoof WebP, and make sanitizeFileName iteratively strip dot-traversal segments (.., ....//, trailing /..) and control characters.
  • Add regression tests in tests/security/ssrf.test.ts and tests/security/file-validation.test.ts.

Verification

  • bun run test:arch (213 passed, 0 failed)
  • bun run typecheck (exit code 0)

SH20RAJ commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for the security hardening. The patch expands IPv6 private/link-local/mapped-address handling, enforces response-size limits, validates both RIFF and WEBP signatures, and strengthens filename traversal cleanup. The regression tests target the relevant SSRF and file-validation cases. GitHub currently shows no CI check runs on this head.

@SH20RAJ
SH20RAJ merged commit d3e94e5 into SopKit:main Nov 27, 2026
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.

2 participants