Skip to content

feat(java): detect setAccessible(true) reflective access on non-local members (CWE-284) - #129

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

feat(java): detect setAccessible(true) reflective access on non-local members (CWE-284)#129
ai-anant wants to merge 1 commit into
CodeVigilant:mainfrom
ai-anant:rule/java-jenkins-reflective-setaccessible

Conversation

@ai-anant

Copy link
Copy Markdown

New rule in a new java/jenkins tree: detects reflective access switched on via setAccessible(true) (Java) or the Groovy property-assignment form accessible = true.

Why it matters: setAccessible(true) suppresses the language access checks, letting plugin code reach protected/private members of other classes - typically used to reach into framework internals and bypass the access-control/safety guardrails (permission checks, async isolation, timeouts, synchronization) that protect those APIs. Also breaks under the Java module system (InaccessibleObjectException).

Rule id: codevigilant.java.jenkins.reflection.setaccessible.true

  • generic-mode rule so both the Java method-call and the Groovy property-assignment shapes are caught
  • severity HIGH, confidence MEDIUM, metadata cwe/owasp/technology/references/license
  • validated with semgrep 1.172 (semgrep --validate --config java/ clean)
  • pos repro fires (2 matches incl. the Groovy form), neg repro (setAccessible(false) only) does not
  • 4 hits across 30+ cloned Jenkins plugin sources, all genuine reflective-access instances, 0 false positives

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