Skip to content

feat(java): detect System.getenv cloned into HashMap for launcher env (CWE-200) - #194

Open
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-controller-getenv-to-launcher
Open

ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-controller-getenv-to-launcher

Conversation

@ai-anant

Copy link
Copy Markdown

Adds one Java rule for the Jenkins plugin ruleset (java/jenkins/info-exposure/):

codevigilant.java.jenkins.info-exposure.controller-getenv-to-launcher (ERROR, CWE-200)

Detects the generic vulnerable shape new HashMap<>(System.getenv()) (and the explicit HashMap<String, String> form). Plugin perform() / descriptor code runs on the Jenkins controller JVM, so cloning the process environment and later passing that map to Launcher/ProcStarter.envs (or a remoting callable) copies controller secrets onto the agent-side child. The fix is to build a fresh env map containing only the variables the tool needs.

Validated with semgrep --validate --config java/. Positive repro (HashMap clone of System.getenv) fires 2/2; sanitized negative (empty HashMap populated with explicit keys, then .envs) stays silent.

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