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
Adds a Jenkins/Java rule that flags
java.io.Fileconstructed from a non-literal path and then passed todelete()or GroovydeleteDir().Pattern (generic)
new File($PATH)(job config, env expansion, build parameters).$F.delete()/$F.deleteDir()/(new File($PATH)).delete().This is a different sink than existing non-literal File stream open rules (
FileInputStream/FileOutputStream/FileReader/FileBody): the dangerous operation here is deletion (including recursive directory delete), not read/write of file contents.Why
A caller who can influence the path string can delete arbitrary files or recursively delete directories on the node where the plugin code runs (typically the Jenkins controller) as the service user.
Validation
semgrep --validateon the new rule: passFile f = new File(untrusted); f.delete();and(new File(p)).delete()): firesjava/ruleset: 0 hits on the positive reproNotes
Single rule file, branched from current
upstream/main.