Skip to content

feat(java): detect FilePath.toURI().resolve without containment (CWE-22) - #191

Open
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/jenkins-filepath-uri-resolve-uncontained
Open

ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/jenkins-filepath-uri-resolve-uncontained

Conversation

@ai-anant

Copy link
Copy Markdown

Summary

Detects FilePath.toURI().resolve(...) with a non-literal argument.

URI.resolve treats a leading slash as an absolute URI path and collapses .. segments, so a job-configured folder string can escape the intended workspace. Callers often pass the resulting path to java.io.File, which resolves on the Jenkins controller rather than the agent that owns the FilePath.

Pattern (generic)

  • workspace.toURI().resolve(rel) where rel is not a string literal
  • Literal resolve("...") is excluded

Test

  • Positive: workspace.toURI().resolve(outputFolder) fires
  • Negative: workspace.toURI().resolve("features") does not fire

No vendor, plugin, file path, or exploit details.

Generic path-construction shape: FilePath.toURI().resolve(non-literal) can escape the workspace via leading-slash or .. segments, and is commonly followed by controller-side java.io.File I/O.
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