feat(java): detect Jenkins Secret credential getter returning plaintext via getPlainText() (CWE-522) - #153
Open
ai-anant wants to merge 1 commit into
Conversation
…xt via getPlainText() (CWE-522)
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.
Detects a data-bound getter that returns a
hudson.util.Secretcredential's plaintext viaSecret.getPlainText().Pattern (generic): a
get*method (public or package-private) whose body isreturn <expr>.getPlainText();.Why it matters: in a Jenkins extension model class, a getter that returns
Secret.getPlainText()instead of theSecretobject itself defeats Jenkins' secret masking. The value is embedded in the rendered configuration page source, replayed verbatim by the config form on every submit, and surfaced through Stapler property binding — exposing the credential to anyone who can view/exchange that page or property.Rule:
codevigilant.java.jenkins.credentials.secret-getter-plaintext(HIGH, CWE-522/CWE-200) —java/jenkins/credentials/secret-getter-plaintext.yaml.Validated with
semgrep --validate --config java/and tested against positive/sanitized negatives:$\{receiver\}.getPlainText()fireSecretobject (correct), non-secret getters do not fireGeneric guidance only; no specific project referenced.