fix: close SSRF IPv6 bypass and replace Math.random() session IDs with crypto.randomUUID()#1
Merged
HugoWong528 merged 1 commit intomainfrom Mar 23, 2026
Conversation
…ssion IDs with crypto.randomUUID() Co-authored-by: HugoWong528 <267603037+HugoWong528@users.noreply.github.com> Agent-Logs-Url: https://github.com/HugoWong528/OpenMAIC/sessions/11d0af47-a7c4-419c-bb94-639f2f7b95cb
Copilot created this pull request from a session on behalf of
HugoWong528
March 23, 2026 01:04
View session
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
Two security vulnerabilities in the SSRF guard and session ID generation. The SSRF filter missed IPv4-mapped IPv6 addresses entirely, and session IDs relied on
Math.random()— a non-CSPRNG source.Related Issues
Changes
lib/server/ssrf-guard.tsextractIPv4FromMappedIPv6()to unwrap both dotted-decimal (::ffff:127.0.0.1) and hex-encoded (::ffff:7f00:1) IPv4-mapped IPv6 addresses, then validates the embedded IPv4 against existing private-range rulesfc00::/7, link-localfe80::/10, loopback) to hostnames containing:— prevents false-positive blocks on domain names likefdomain.comisBlockedHostnameintoisBlockedIPv4+isBlockedHostnamefor clarity and reusecomponents/chat/use-chat-sessions.ts\session-${Date.now()}-${Math.random()...}`session ID patterns with`session-${crypto.randomUUID()}``Type of Change
Verification
Steps to reproduce / test
http://[::ffff:127.0.0.1]/as a custom base URL — previously bypassed the SSRF guard, now blockedhttp://[::ffff:7f00:1]/— same bypass, now blockedhttps://api.openai.com— passes through correctlyhttp://fdomain.com— passes through (no false positive onfd-prefixed domain)What you personally verified
fd,fc,fe80, etc.crypto.randomUUID()is available in both browser and Node.js (Next.js) runtimesEvidence
pnpm check && pnpm lint && npx tsc --noEmit)Checklist