jenkinsci / jenkinsci/script-security-plugin

[JENKINS-67956] Missing input validation for signature approvals causing IOException

Open
#872 0 comments 0 reactions 0 assignees View on GitHub
component:script-security-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
76
Forks
181
Avg merge
14h 55m
Merged PRs (30d)
3

Description

If you approve a signature with  scriptApproval.approveSignature that does not have a correct prefix, the invalid signature will make it to the scriptApprovals.xml and cause future approvals to throw IOException.

Not 100% sure but I think that there might be other ways malformed signatures can poison the configuration..

The work-around I have implemented is to remove all approvals not having the correct prefix

Set cleanSignatures(List signatures, String source) {

  def ValidPrefixes = 'field |staticField |method |staticMethod |new ' 

  Set uniqueResults = []

  signatures.each { signature ->

    if (signature.matches("^(${ValidPrefixes}).*\$"))


{
      uniqueResults.add(signature)
    }

else {

      println "WARN: signature ${signature} from ${source} did not contain a valid prefix        ${ValidPrefixes} signature skipped"

    }

 }

return (uniqueResults)

}

 

When all signatures are "clean" I can load them with the 

scriptApproval.setApprovedSignatures(allSignatures as String[])

operation.

The approveSignature method should probably have some sanity check, ensuring prefixes 'field |staticField |method |staticMethod |new ' and throw some InvalidSignatureException if not valid instead of accepting it and create problems for further operations.

 

---
Originally reported by dariof, imported from: Missing input validation for signature approvals causing IOException


  • status: Open
  • priority: Major
  • component(s): script-security-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 2025-12-09

Raw content of original issue

If you approve a signature with  scriptApproval.approveSignature that does not have a correct prefix, the invalid signature will make it to the scriptApprovals.xml and cause future approvals to throw IOException.

Not 100% sure but I think that there might be other ways malformed signatures can poison the configuration..

The work-around I have implemented is to remove all approvals not having the correct prefix

Set cleanSignatures(List<String> signatures, String source) {
  def ValidPrefixes = 'field |staticField |method |staticMethod |new ' 
  Set uniqueResults = []
  signatures.each { signature ->
    if (signature.matches("^(${ValidPrefixes}).*\$"))


{
      uniqueResults.add(signature)
    }

else {
      println "WARN: signature ${signature} from ${source} did not contain a valid prefix        ${ValidPrefixes} signature skipped"
    }
 }
return (uniqueResults)
}

 

When all signatures are "clean" I can load them with the 

scriptApproval.setApprovedSignatures(allSignatures as String[])

operation.

The approveSignature method should probably have some sanity check, ensuring prefixes 'field |staticField |method |staticMethod |new ' and throw some InvalidSignatureException if not valid instead of accepting it and create problems for further operations.

 

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.