Skip to content
RCE Write-up Advanced

Hacking Jenkins Part 2 - Abusing Meta Programming for Unauthenticated RCE!

Jenkins validates Pipeline scripts by parsing them with Groovy's GroovyClassLoader.parseClass, which processes annotations such as @Grab and @GrabResolver at compile time. An attacker can use these annotations to make Jenkins download a malicious JAR and execute code via the Runner service, achieving unauthenticated remote code execution.

blog.orange.tw

Published on blog.orange.tw

📌 [繁體中文 | English ]

The author, on blog.orange.tw

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

What the attacker needed

Jenkins with Pipeline plugin; ability to submit Pipeline script for validation; network access from Jenkins to attacker's repository

How it was found

  1. Craft a Pipeline script that uses the @GrabResolver annotation to point to a malicious repository.
  2. Use the @Grab annotation to make Jenkins download a malicious JAR from that repository.
  3. Include a service entry in the JAR that specifies a class to be instantiated as a Runner.
  4. Submit the script to Jenkins, which parses it and triggers the download and instantiation, leading to code execution.

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 write Pipeline scripts, which are written in a language called Groovy. Before running a script, Jenkins checks its syntax by parsing it. The parser processes special annotations (like @Grab) that can download and load code from the internet. The attacker abuses this to make Jenkins download a malicious file and run it, without needing to log in.

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.