mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
Translated ['src/linux-hardening/privilege-escalation/vmware-tools-servi
This commit is contained in:
parent
88bc05a9e7
commit
9361b37fbb
@ -110,6 +110,7 @@
|
||||
- [Checklist - Linux Privilege Escalation](linux-hardening/linux-privilege-escalation-checklist.md)
|
||||
- [Linux Privilege Escalation](linux-hardening/privilege-escalation/README.md)
|
||||
- [Android Rooting Frameworks Manager Auth Bypass Syscall Hook](linux-hardening/privilege-escalation/android-rooting-frameworks-manager-auth-bypass-syscall-hook.md)
|
||||
- [Vmware Tools Service Discovery Untrusted Search Path Cve 2025 41244](linux-hardening/privilege-escalation/vmware-tools-service-discovery-untrusted-search-path-cve-2025-41244.md)
|
||||
- [Arbitrary File Write to Root](linux-hardening/privilege-escalation/write-to-root.md)
|
||||
- [Cisco - vmanage](linux-hardening/privilege-escalation/cisco-vmanage.md)
|
||||
- [Containerd (ctr) Privilege Escalation](linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,146 @@
|
||||
# VMware Tools service discovery LPE (CWE-426) via regex-based binary discovery (CVE-2025-41244)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
Esta técnica explora pipelines de descoberta de serviços dirigidas por regex que analisam as linhas de comando dos processos em execução para inferir versões dos serviços e então executar um binário candidato com uma flag de "version". Quando padrões permissivos aceitam caminhos não confiáveis controlados pelo atacante (por exemplo, /tmp/httpd), o coletor privilegiado executa um binário arbitrário de um local não confiável, resultando em elevação de privilégio local. A NVISO documentou isso na Service Discovery do VMware Tools/Aria Operations como CVE-2025-41244.
|
||||
|
||||
- Impacto: Elevação de privilégio local para root (ou para a conta de descoberta privilegiada)
|
||||
- Causa raiz: Untrusted Search Path (CWE-426) + correspondência regex permissiva das linhas de comando dos processos
|
||||
- Afetado: open-vm-tools/VMware Tools on Linux (credential-less discovery), VMware Aria Operations SDMP (credential-based discovery via Tools/proxy)
|
||||
|
||||
## Como funciona a descoberta de serviços do VMware (visão geral)
|
||||
|
||||
- Credential-based (legado): Aria executa scripts de descoberta dentro do guest via VMware Tools usando credenciais privilegiadas configuradas.
|
||||
- Credential-less (moderno): A lógica de descoberta roda dentro do VMware Tools, já com privilégios no guest.
|
||||
|
||||
Ambos os modos acabam executando lógica de shell que escaneia processos com sockets de escuta, extrai um caminho de comando correspondente via uma regex e executa o primeiro token argv com uma flag de versão.
|
||||
|
||||
## Causa raiz e padrão vulnerável (open-vm-tools)
|
||||
|
||||
No open-vm-tools, o script do plugin serviceDiscovery get-versions.sh casa binários candidatos usando expressões regulares amplas e executa o primeiro token sem qualquer validação de caminho confiável:
|
||||
```bash
|
||||
get_version() {
|
||||
PATTERN=$1
|
||||
VERSION_OPTION=$2
|
||||
for p in $space_separated_pids
|
||||
do
|
||||
COMMAND=$(get_command_line $p | grep -Eo "$PATTERN")
|
||||
[ ! -z "$COMMAND" ] && echo VERSIONSTART "$p" "$("${COMMAND%%[[:space:]]*}" $VERSION_OPTION 2>&1)" VERSIONEND
|
||||
done
|
||||
}
|
||||
```
|
||||
Ele é invocado com padrões permissivos contendo \S (sem espaços em branco) que irão corresponder facilmente a caminhos fora do sistema em locais graváveis pelo usuário:
|
||||
```bash
|
||||
get_version "/\S+/(httpd-prefork|httpd|httpd2-prefork)($|\s)" -v
|
||||
get_version "/usr/(bin|sbin)/apache\S*" -v
|
||||
get_version "/\S+/mysqld($|\s)" -V
|
||||
get_version "\.?/\S*nginx($|\s)" -v
|
||||
get_version "/\S+/srm/bin/vmware-dr($|\s)" --version
|
||||
get_version "/\S+/dataserver($|\s)" -v
|
||||
```
|
||||
- A extração usa grep -Eo e pega o primeiro token: ${COMMAND%%[[:space:]]*}
|
||||
- Não há whitelist/allowlist de trusted system paths; qualquer discovered listener com um nome correspondente é executado com -v/--version
|
||||
|
||||
This creates an untrusted search path execution primitive: arbitrary binaries located in world-writable directories (e.g., /tmp/httpd) get executed by a privileged component.
|
||||
|
||||
## Exploitation (both credential-less and credential-based modes)
|
||||
|
||||
Pré-requisitos
|
||||
- Você pode executar um processo sem privilégios que abra um listening socket no guest.
|
||||
- A discovery job está habilitada e roda periodicamente (historicamente ~5 minutos).
|
||||
|
||||
Etapas
|
||||
1) Coloque (stage) um binário em um caminho que corresponda a um dos regexes permissivos, e.g. /tmp/httpd or ./nginx
|
||||
2) Execute-o como um usuário com poucos privilégios e assegure-se de que ele abra qualquer listening socket
|
||||
3) Espere pelo ciclo de discovery; o privileged collector executará automaticamente: /tmp/httpd -v (or similar), rodando seu programa como root
|
||||
|
||||
Minimal demo (using NVISO’s approach)
|
||||
```bash
|
||||
# Build any small helper that:
|
||||
# - default mode: opens a dummy TCP listener
|
||||
# - when called with -v/--version: performs the privileged action (e.g., connect to an abstract UNIX socket and spawn /bin/sh -i)
|
||||
# Example staging and trigger
|
||||
cp your_helper /tmp/httpd
|
||||
chmod +x /tmp/httpd
|
||||
/tmp/httpd # run as low-priv user and wait for the cycle
|
||||
# After the next cycle, expect a root shell or your privileged action
|
||||
```
|
||||
Linagem típica de processo
|
||||
- Com credenciais: /usr/bin/vmtoolsd -> /bin/sh /tmp/VMware-SDMP-Scripts-.../script_...sh -> /tmp/httpd -v -> /bin/sh -i
|
||||
- Sem credenciais: /bin/sh .../get-versions.sh -> /tmp/httpd -v -> /bin/sh -i
|
||||
|
||||
Artefatos (com credenciais)
|
||||
SDMP wrapper scripts recuperados em /tmp/VMware-SDMP-Scripts-{UUID}/ podem mostrar a execução direta do caminho malicioso:
|
||||
```bash
|
||||
/tmp/httpd -v >"/tmp/VMware-SDMP-Scripts-{UUID}/script_-{ID}_0.stdout" 2>"/tmp/VMware-SDMP-Scripts-{UUID}/script_-{ID}_0.stderr"
|
||||
```
|
||||
## Generalizando a técnica: regex-driven discovery abuse (portable pattern)
|
||||
|
||||
Muitos agentes e pacotes de monitoramento implementam descoberta de versão/serviço por:
|
||||
- Enumerar processos com listening sockets
|
||||
- Grep em argv/linhas de comando com regexes permissivas (p.ex., padrões contendo \S)
|
||||
- Executar o caminho correspondente com uma flag benigna como -v, --version, -V, -h
|
||||
|
||||
Se a regex aceitar caminhos não confiáveis e o caminho for executado a partir de um contexto privilegiado, obtém-se CWE-426 Untrusted Search Path execution.
|
||||
|
||||
Abuse recipe
|
||||
- Nomeie seu binário como daemons comuns que a regex provavelmente corresponderá: httpd, nginx, mysqld, dataserver
|
||||
- Coloque-o em um diretório gravável: /tmp/httpd, ./nginx
|
||||
- Assegure que ele corresponda à regex e abra qualquer porta para ser enumerada
|
||||
- Espere pelo coletor agendado; você obtém uma invocação privilegiada automática de <path> -v
|
||||
|
||||
Masquerading note: This aligns with MITRE ATT&CK T1036.005 (Match Legitimate Name or Location) to increase match probability and stealth.
|
||||
|
||||
Reusable privileged I/O relay trick
|
||||
- Construa seu helper de forma que, quando invocado com privilégios (-v/--version), ele se conecte a um rendezvous conhecido (p.ex., um Linux abstract UNIX socket como @cve) e faça a ponte do stdio para /bin/sh -i. Isso evita artefatos no disco e funciona em muitos ambientes onde o mesmo binário é reinvocado com uma flag.
|
||||
|
||||
## Detection and DFIR guidance
|
||||
|
||||
Hunting queries
|
||||
- Uncommon children of vmtoolsd or get-versions.sh such as /tmp/httpd, ./nginx, /tmp/mysqld
|
||||
- Any execution of non-system absolute paths by discovery scripts (look for spaces in ${COMMAND%%...} expansions)
|
||||
- ps -ef --forest to visualize ancestry trees: vmtoolsd -> get-versions.sh -> <non-system path>
|
||||
|
||||
On Aria SDMP (credential-based)
|
||||
- Inspect /tmp/VMware-SDMP-Scripts-{UUID}/ for transient scripts and stdout/stderr artifacts showing execution of attacker paths
|
||||
|
||||
Policy/telemetry
|
||||
- Alert when privileged collectors execute from non-system prefixes: ^/(tmp|home|var/tmp|dev/shm)/
|
||||
- File integrity monitoring on get-versions.sh and VMware Tools plugins
|
||||
|
||||
## Mitigations
|
||||
|
||||
- Patch: Apply Broadcom/VMware updates for CVE-2025-41244 (Tools and Aria Operations SDMP)
|
||||
- Disable or restrict credential-less discovery where feasible
|
||||
- Validate trusted paths: restrinja a execução a diretórios em lista de permitidos (/usr/sbin, /usr/bin, /sbin, /bin) e apenas binários exatos conhecidos
|
||||
- Avoid permissive regexes with \S; prefer anchored, explicit absolute paths and exact command names
|
||||
- Drop privileges for discovery helpers where possible; sandbox (seccomp/AppArmor) to reduce impact
|
||||
- Monitor for and alert on vmtoolsd/get-versions.sh executing non-system paths
|
||||
|
||||
## Notes for defenders and implementers
|
||||
|
||||
Padrão mais seguro de correspondência e execução
|
||||
```bash
|
||||
# Bad: permissive regex and blind exec
|
||||
COMMAND=$(get_command_line "$pid" | grep -Eo "/\\S+/nginx(\$|\\s)")
|
||||
[ -n "$COMMAND" ] && "${COMMAND%%[[:space:]]*}" -v
|
||||
|
||||
# Good: strict allowlist + path checks
|
||||
candidate=$(get_command_line "$pid" | awk '{print $1}')
|
||||
case "$candidate" in
|
||||
/usr/sbin/nginx|/usr/sbin/httpd|/usr/sbin/apache2)
|
||||
"$candidate" -v 2>&1 ;;
|
||||
*)
|
||||
: # ignore non-allowlisted paths
|
||||
;;
|
||||
esac
|
||||
```
|
||||
## Referências
|
||||
|
||||
- [NVISO – You name it, VMware elevates it (CVE-2025-41244)](https://blog.nviso.eu/2025/09/29/you-name-it-vmware-elevates-it-cve-2025-41244/)
|
||||
- [Broadcom advisory for CVE-2025-41244](https://support.broadcom.com/web/ecx/support-content-notification/-/external/content/SecurityAdvisories/0/36149)
|
||||
- [open-vm-tools – serviceDiscovery/get-versions.sh (stable-13.0.0)](https://github.com/vmware/open-vm-tools/blob/stable-13.0.0/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh)
|
||||
- [MITRE ATT&CK T1036.005 – Match Legitimate Name or Location](https://attack.mitre.org/techniques/T1036/005/)
|
||||
- [CWE-426: Untrusted Search Path](https://cwe.mitre.org/data/definitions/426.html)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
@ -1,14 +1,28 @@
|
||||
# VMware ESX / vCenter Pentesting
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
# Enumeração
|
||||
## Enumeração
|
||||
```bash
|
||||
nmap -sV --script "http-vmware-path-vuln or vmware-version" -p <PORT> <IP>
|
||||
msf> use auxiliary/scanner/vmware/esx_fingerprint
|
||||
msf> use auxiliary/scanner/http/ms15_034_http_sys_memory_dump
|
||||
```
|
||||
# Força Bruta
|
||||
## Bruteforce
|
||||
```bash
|
||||
msf> auxiliary/scanner/vmware/vmware_http_login
|
||||
```
|
||||
Se você encontrar credenciais válidas, pode usar mais módulos de scanner do metasploit para obter informações.
|
||||
|
||||
|
||||
|
||||
### Veja também
|
||||
|
||||
Linux LPE via VMware Tools service discovery (CWE-426 / CVE-2025-41244):
|
||||
|
||||
{{#ref}}
|
||||
../../linux-hardening/privilege-escalation/vmware-tools-service-discovery-untrusted-search-path-cve-2025-41244.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
Loading…
x
Reference in New Issue
Block a user