Fix uppercase-scheme bypass in LLM tool-input guard#13
Merged
Conversation
JsonToolInputGuard.looksLikeUrl matched http:// and https:// prefixes case-sensitively, so a tool-input URL with an uppercase scheme (HTTP://169.254.169.254/, HtTpS://evil.com/) was never collected as a candidate and skipped policy validation entirely, bypassing the host allowlist and IP-literal checks. URI schemes are case-insensitive (RFC 3986 3.1) and the downstream scheme check already used equalsIgnoreCase, so the case-sensitive match in the collection step was an unintended inconsistency. Lower-case before the prefix test. Adds regression tests for uppercase/mixed-case blocked URLs and confirms an uppercase whitelisted URL still passes. Affects ssrf-guard-springai and ssrf-guard-langchain4j, which both route tool input through this guard. Same class of bug fixed in the JS sibling ssrf-guard-js.
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.
Security fix
JsonToolInputGuard.looksLikeUrlcollected candidate URLs with a case-sensitivehttp:///https://prefix test:A tool-input URL with an uppercase scheme (
HTTP://169.254.169.254/…,HtTpS://evil.com/) was never collected as a candidate, so it skipped policy validation entirely — bypassing the host allowlist and IP-literal checks. URI schemes are case-insensitive (RFC 3986 §3.1) and the downstream scheme check already usedequalsIgnoreCase, so the case-sensitive collection step was an unintended inconsistency. Detection is now case-insensitive.Blast radius
JsonToolInputGuardis the single tool-input scanner; bothssrf-guard-springaiandssrf-guard-langchain4jroute tool input through it, so both LLM-framework adapters were affected.Changes
JsonToolInputGuard.looksLikeUrlHTTP://metadata URL and mixed-caseHtTpS://nested URL blocked; uppercaseHTTPS://whitelisted URL still passesdocs/changelog.md+ root mirror) under[Unreleased]→ SecurityVerification
Full CI-equivalent build green locally:
./gradlew build jacocoTestReport→ BUILD SUCCESSFUL, all module tests pass.Context
Same bug found and fixed in the JS sibling
ssrf-guard-js(shipped in@devslab/ssrf-guard-js@0.1.2). Suggest a v3.1.1 patch release after merge.보안 수정 (한국어)
looksLikeUrl가 URL 수집을 대소문자 구분으로 해서 대문자 스킴 URL(HTTP://…)이 정책 검증을 건너뛰던 우회를 수정. 스킴은 대소문자 무시(RFC 3986)이고 다음 코드가 이미equalsIgnoreCase를 쓰므로 수집 단계만 case-sensitive였던 불일치. springai·langchain4j 둘 다 영향. 로컬 전체 빌드 green. JS 형제와 동일 버그 → 머지 후 v3.1.1 권장.