Skip to content
RCE Write-up Advanced

CVE-2019-1003040: Jenkins Script Security plugin sandbox escape

The Jenkins Script Security plugin whitelisted two static methods that performed type coercion by automatically invoking constructors, allowing a Groovy script to build a gadget chain. An attacker with script execution could escape the sandbox and achieve remote code execution.

amlw.dev

Published on amlw.dev

Website: https://wiki.jenkins.io/display/JENKINS/Script+Security+Plugin

The author, on amlw.dev

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The sandbox whitelisted static methods that automatically invoke constructors during type coercion, enabling a gadget chain.

Impact

An attacker with the ability to run scripts in Jenkins could escape the sandbox and execute arbitrary code on the server.

What the attacker needed

Ability to run Groovy scripts in Jenkins

The fix

The plugin was fixed in version 1.56 by removing the dangerous methods from the default whitelist.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Jenkins lets users run Groovy scripts, but normally a sandbox stops them from doing dangerous things. The sandbox allowed two helper methods that could turn a simple value into a powerful object by calling its constructor automatically. By chaining these conversions, an attacker could break out of the sandbox and run their own code on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.