feat(java): detect Kong Unirest HTTP requests to a non-literal URL (CWE-918) - #139
Open
ai-anant wants to merge 2 commits into
Open
feat(java): detect Kong Unirest HTTP requests to a non-literal URL (CWE-918)#139ai-anant wants to merge 2 commits into
ai-anant wants to merge 2 commits into
Conversation
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
Add a Java/Jenkins rule that flags a Kong Unirest HTTP request (
Unirest.get/post/put/patch/delete/head/options/request) whose URL argument is not a string literal.Pattern
Unirest.$METHOD($URL)where the argument is a variable, field, method result, or expression (non-literal) — an SSRF sink when that URL derives from configurable or attacker-influenced input with no host allowlist.Why it matters
Unirest is a fluent HTTP client used by many Jenkins plugins. A non-literal URL combines a configurable base endpoint with a path, letting an authenticated user redirect the request to internal services (127.0.0.1, cloud metadata 169.254.169.254, other nodes) or an attacker-controlled host — and any Authorization/basic-auth credential attached to the request is disclosed to that destination.
Validation
semgrep --validate --config java/passes.Closes nothing. Rule ID:
codevigilant.java.jenkins.ssrf.unirest.nonliteral-url.