Wildcard Inference Roles and Metadata SSRF on Managed AI

How overly permissive IAM roles and an unvalidated artifact_uri escalate an inference caller to cross-tenant model weights and instance metadata credentials.

Managed AI deployments routinely ship with a single convenience Identity and Access Management (IAM) role attached to inference endpoints. Pair a Resource: "*" storage policy with an unvalidated artifact-fetch parameter on the inference server, and a low-privilege caller can pivot straight into raw training corpora, another tenant's weights, and instance metadata credentials.

Cloud AI IAM Lab emulates this cloud failure class locally in zero-dependency Python (github.com/ghostintheprompt/cloud_ai_iam_lab) using a deterministic Allow/Deny policy evaluator (shared/iam.py) and synthetic Amazon Resource Name (ARN) fixtures.

How one wildcard role opens three lateral paths

In vulnerable/server.py, inference_caller carries Allow for ai:* and storage:GetObject on Resource: "*":

  • Training-corpus exposure (CWE-269, MITRE ATT&CK T1530): Calling get_storage_object directly reads arn:local:storage:tenant-a/training_data/customers.jsonl, exposing raw fine-tuning records that an inference consumer never needed to touch.
  • Cross-tenant weight theft (CWE-284, MITRE ATT&CK T1078.004): Without a tenant-prefix condition on the storage grant, the same tenant-a caller pulls arn:local:storage:tenant-b/models/proprietary.json.
  • Instance metadata credential theft (CWE-918, OWASP API8:2023, MITRE ATT&CK T1552.005): Supplying artifact_uri="http://169.254.169.254/latest/meta-data/iam/security-credentials/inference-runtime-role" on invoke_endpoint tricks the inference host into fetching and returning its own runtime role token.

Separating caller and runtime roles with explicit Deny

fixed/server.py splits the caller identity from the compute runtime identity and relies on explicit Deny precedence inside evaluate_policy so accidental policy attachments cannot reopen storage access:

FIXED_POLICIES = {
    "inference_caller": (
        PolicyStatement("Allow", ("ai:InvokeEndpoint",), ("arn:local:ai:tenant-a/endpoints/support-bot",)),
        PolicyStatement("Deny", ("storage:*", "iam:*"), ("*",)),
    ),
}

The separate inference_runtime_role is scoped strictly to arn:local:storage:tenant-a/models/support-bot.json, with explicit Deny statements on training_data/* and tenant-b/*. Every request verifies _extract_tenant(resource_arn) == caller_tenant and rejects caller-supplied artifact_uri overrides with HTTP 403. In detect/rule.py, JSONL audit rules CLD-001 (T1552.005 metadata SSRF), CLD-002 (T1078.004 cross-tenant ARN mismatch), and CLD-003 (T1530 caller reading /training_data/) flag all three escalation attempts with zero false positives on normal inference traffic.

Local policy evaluation results

Running make test verifies legitimate endpoint invocation and model loading alongside all three blocked pivots:

Path                           | Vulnerable   | Fixed
------------------------------------------------------------
Benign Inference Call          | PASS         | PASS
Read Tenant-A Training Data    | REACHABLE    | BLOCKED
Cross-Tenant Model Read (B)    | REACHABLE    | BLOCKED
IMDS Credential SSRF           | REACHABLE    | BLOCKED
Ran 5 tests in 0.001s (OK)

Everything runs against a local Python policy engine on synthetic ARNs; no live AWS, GCP, or Azure account is contacted, and no claim is made about any specific cloud vendor's hosted defaults.

GhostInThePrompt.com // Scope the inference caller to the endpoint, and deny storage explicitly.