Skip to content

feat(java): detect FilePath.copyFrom called with a non-literal URL (CWE-918) - #124

Open
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:rule/java-filepath-copyfrom-url
Open

feat(java): detect FilePath.copyFrom called with a non-literal URL (CWE-918)#124
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:rule/java-filepath-copyfrom-url

Conversation

@ai-anant

Copy link
Copy Markdown

Detects hudson.FilePath.copyFrom(...) invoked with a non-literal URL argument (e.g. a URL parsed from a remote response, job configuration, or env-expanded build parameter).

copyFrom(URL) opens an outbound connection to the argument URL and writes the response body into the FilePath on the local node, so an attacker-influenced value turns into a server-side request forgery plus an arbitrary-content write to a path the plugin chose.

The rule matches the copyFrom sink only when the argument is a URL expression (new URL(...) or a URL-typed value), and excludes literal URLs. Positive/negative repro cases are included under testcases/java/.

Validated with semgrep --validate; fires on the vulnerable shape (1 hit) and stays silent on the literal/FilePath-to-FilePath negative repros.

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.

1 participant