Skip to content

feat(java): detect URLClassLoader construction from a URL list (CWE-94) - #195

Open
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-path-to-urlclassloader
Open

ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-path-to-urlclassloader

Conversation

@ai-anant

Copy link
Copy Markdown

Summary

Generic Semgrep rule for Jenkins/Java plugins that construct a URLClassLoader from a URL list.

In Jenkins, Builder / SimpleBuildStep.perform() runs on the controller JVM. Loading JARs discovered from a job-configured filesystem path via new URLClassLoader(...) is controller-side arbitrary code execution. Empty URL arrays are excluded.

Rule

  • id: codevigilant.java.jenkins.classloader.path-to-urlclassloader
  • file: java/jenkins/classloader/path-to-urlclassloader.yaml
  • sink: new URLClassLoader(...)
  • sanitizer exclusions: new URLClassLoader(new URL[]{}) and new URLClassLoader(new URL[0])

Test

  • positive: new URLClassLoader(urls) fires
  • negative: empty URL array constructors do not fire
  • semgrep --validate --config java/ clean

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