T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/audit-system.mjs:902
- Finding
- Unconditional Access to the Cloud Instance Metadata Service<![CDATA[ ## Vulnerability Details **File Location**: `scripts/audit-system.mjs:902-916` **Equivalent Implementation**: `scripts/audit-system-full-async.mjs:934-948` **Vulnerability Type**: Active access to a credential-bearing cloud metadata boundary **Risk Level**: Medium ### Complete Code Snippet ```js function auditNetworkSegmentation() { addCheck(); // SYS-100: Check if running in cloud/VM with metadata service exposed const metadataReachable = run("timeout", ["2", "curl", "-s", "http://169.254.169.254/latest/meta-data/"]); if (metadataReachable) { // Check if iptables blocks it const blocked = runShell("iptables -L OUTPUT -n | grep 169.254.169.254 || sudo -n iptables -L OUTPUT -n | grep 169.254.169.254"); if (!blocked) { addFinding( "warning", "SYS-100", "Cloud metadata service accessible without firewall rules", "Instance metadata API (169.254.169.254) is reachable. Compromised OpenClaw agent could steal IAM credentials.", "Block metadata API: sudo iptables -A OUTPUT -d 169.254.169.254 -j REJECT" ); } } ``` ### Technical Analysis Every invocation of the full system audit actively sends an HTTP request to the link-local cloud instance metadata service. This endpoint is a sensitive trust boundary because cloud platforms may expose instance identity information and temporary role credentials through related metadata paths. The current request targets `/latest/meta-data/`, rather than a specific IAM credential path, and the inspected code does not print or transmit the returned response. Nevertheless, it unnecessarily retrieves the response body and places it in the auditor process. A passive security audit can determine configuration state without consuming metadata content. This behavior is especially concerning when the auditor runs with broader permissions, is incorporated into another automation pipeline, or is later modified or compromised. It creates a ready-made met ...[truncated 1159 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Disable cloud metadata probing by default and require an explicit option such as `--check-cloud-metadata`. 2. Prefer inspection of local routing and firewall configuration over an HTTP request. 3. If an active probe is essential, perform a connection-only or headers-only test and discard all response content immediately. 4. Use cloud-specific protections such as IMDSv2, strict hop limits, and workload-level metadata restrictions. 5. Do not request credential-bearing metadata paths. 6. Clearly document that this check performs a network request to a sensitive link-local endpoint. 7. Add tests proving that the default audit never contacts the metadata service. ]]>
