# AWS Bedrock AgentCore Sandbox Escape via DNS Tunneling and Metadata Service Exploitation

> Unit 42 researchers discovered critical weaknesses in Amazon Bedrock AgentCore's Sandbox Mode isolation that enable DNS tunneling for bidirectional data exfiltration and C2 communication, legacy MMDSv1 exploitation for IAM credential theft, and infrastructure information disclosure including pre-signed S3 URLs and KMS Key IDs. AWS enforced MMDSv2 defaults for new agents on February 14, 2026, but legacy agents remain vulnerable unless manually updated.

- **Published:** 2026-04-07T12:00:00Z
- **Last reviewed:** 2026-04-07T12:00:00Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-0331
- **Card image:** https://intel.threadlinqs.com/og/threat/threat-intel-agentcore-sandbox-escape-tl-2026-0331.webp?v=882b7741 (Threadlinqs threat intel: AWS Bedrock AgentCore Sandbox Escape: Detection & IOCs (TL-2026-0331) — High severity, 15 IOCs, 9 detection rules.)
- **ID:** TL-2026-0331
- **Severity:** HIGH
- **Category:** CLOUD
- **Status:** MONITORING
- **Detections:** 9 (1 shown free below) · **IOCs:** 15 (2 shown free below)

## Description

Unit 42 researcher Ori Hadad discovered multiple sandbox isolation bypasses in Amazon Bedrock AgentCore's Code Interpreter running in Sandbox Mode. The vulnerabilities chain together to defeat the sandbox's core isolation promise of "no external network access."

**DNS Tunneling Bypass (Primary Vector)**

Despite AgentCore's Sandbox Mode documentation claiming no external network access, the sandbox permitted DNS resolution to arbitrary external domains. Researchers demonstrated this by resolving both internal AWS services (s3.us-east-1.amazonaws.com) and external domains (google.com) from within the sandbox using Python's socket.gethostbyname_ex() function.

This DNS resolution capability was weaponized into a full bidirectional covert channel. By encoding sensitive data as subdomains of an attacker-controlled domain (e.g., base64-encoded-secret.dnshook.site), the sandbox's internal DNS resolver would recursively forward queries to the attacker's authoritative nameserver, effectively exfiltrating data encoded in DNS query labels. The reverse channel enables command-and-control by embedding instructions in DNS response records.

**MicroVM Metadata Service (MMDS) Exploitation**

The AgentCore sandbox runs on Firecracker microVMs, each with an ephemeral per-session lifecycle. The microVM's metadata service endpoint at 169.254.169.254 was configured with legacy MMDSv1 behavior — accepting standard HTTP GET requests without requiring a session token. This contrasts with EC2's IMDSv2 which mandates a PUT-based token exchange before metadata access.

This misconfiguration allowed direct retrieval of temporary IAM role credentials (Access Key ID, Secret Access Key, and Session Token) associated with the sandbox execution context. Combined with the DNS tunneling channel, these credentials could be exfiltrated to an attacker-controlled server.

**Infrastructure Information Disclosure**

Researchers discovered undocumented MMDS tag endpoints that exposed operational infrastructure details:
- http://169.254.169.254/latest/meta-data/tags/instance/aws_presigned-log-url returned pre-signed S3 URLs with scoped write access to internal AWS logging buckets
- http://169.254.169.254/latest/meta-data/tags/instance/aws_presigned-log-kms-key revealed KMS Key IDs used for backend infrastructure encryption

Additionally, malformed S3 requests triggered error responses containing the AWSAccessKeyID of the signing identity (beginning with ASI...X6L) and the owning AWS account number (209...9), enabling infrastructure reconnaissance.

**Attack Chain**

The complete exploitation chain proceeds as follows: (1) Confirm DNS resolution capability from sandbox, (2) Enumerate MMDS endpoints to harvest IAM credentials and infrastructure metadata, (3) Establish DNS tunneling channel to attacker-controlled nameserver, (4) Exfiltrate stolen credentials and infrastructure details via DNS subdomain encoding, (5) Use exfiltrated credentials externally for lateral movement within the victim's AWS environment.

**Sandbox Mode vs VPC Mode**

AWS Bedrock AgentCore offers two network isolation modes. Sandbox Mode provides limited isolation with DNS access and S3 connectivity for logging. VPC Mode deploys into customer-controlled subnets with full network control including Route 53 Resolver DNS Firewall capability. Unit 42 recommends VPC Mode for production and sensitive workloads.

**Remediation**

AWS responded by enforcing MMDSv2 as the default for all new AgentCore agents as of February 14, 2026, and providing an API option for customers to disable IMDSv1 on existing agents. AWS also updated documentation to more accurately describe Sandbox Mode's network capabilities as "limited external network access" rather than implying complete isolation.

## MITRE ATT&CK

- T1190 Exploit Public-Facing Application
- T1059 Command and Scripting Interpreter
- T1552 Unsecured Credentials
- T1580 Cloud Infrastructure Discovery
- T1082 System Information Discovery
- T1619 Cloud Storage Object Discovery
- T1530 Data from Cloud Storage
- T1071 Application Layer Protocol
- T1572 Protocol Tunneling
- T1048 Exfiltration Over Alternative Protocol
- T1078 Valid Accounts

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**AWS Bedrock AgentCore DNS Tunneling Detection** (`TL-2026-0331-SPL-001`)

Detects high-volume DNS TXT/CNAME queries indicative of DNS tunneling from AWS Bedrock AgentCore sandbox environments, targeting data exfiltration and C2 communication channels.

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1071.004, T1572, T1048.003
- **Data sources:** DNS logs, AWS CloudTrail, Route53 query logs
- **Severity:** critical
- **Confidence:** high

### Splunk SPL

```spl
index=dns sourcetype=stream:dns OR sourcetype=aws:cloudtrail (query_type=TXT OR query_type=CNAME) | eval subdomain_len=len(mvindex(split(query, "."), 0)) | where subdomain_len > 40 OR len(query) > 100 | stats count dc(query) as unique_queries sum(subdomain_len) as total_encoded_len by src_ip | where count > 50 AND unique_queries > 20 | lookup aws_bedrock_instances ip AS src_ip OUTPUT instance_id | where isnotnull(instance_id) | table _time src_ip instance_id count unique_queries total_encoded_len
```

### Microsoft KQL

```kql
DnsEvents | where QueryType in ('TXT', 'CNAME') | extend SubdomainLength = strlen(tostring(split(Name, '.')[0])) | where SubdomainLength > 40 or strlen(Name) > 100 | summarize QueryCount = count(), UniqueQueries = dcount(Name), TotalEncodedLen = sum(SubdomainLength) by ClientIP, bin(TimeGenerated, 5m) | where QueryCount > 50 and UniqueQueries > 20 | join kind=inner (AzureActivity | where ResourceProviderValue == 'MICROSOFT.MACHINELEARNINGSERVICES') on $left.ClientIP == $right.CallerIpAddress
```

### Sigma

```yaml
title: AWS Bedrock AgentCore DNS Tunneling
id: a1b2c3d4-0331-4001-a001-detectorrule01
status: experimental
author: Threadlinqs Team
date: 2026/04/08
description: Detects DNS tunneling activity from AWS Bedrock sandbox environments via high-entropy subdomain queries
logsource:
  category: dns
  product: aws
  service: route53
detection:
  selection:
    query_type:
      - TXT
      - CNAME
  filter_length:
    query|re: '^[a-zA-Z0-9]{40,}\..+'
  condition: selection and filter_length
falsepositives:
  - Legitimate DNS-based services with long subdomains
  - CDN domain validation
level: critical
tags:
  - attack.command_and_control
  - attack.t1071.004
  - attack.exfiltration
  - attack.t1048.003
```

**Known false positives:**

- Low

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- PowerShell DNS Exfiltration via Resolve-DnsName (locked: unlock with TL Creds)
- Linux dig/nslookup DNS Tunneling from Cloud Sandbox (locked: unlock with TL Creds)
- Python requests to Cloud Metadata Endpoints (locked: unlock with TL Creds)
- AWS Bedrock API Anomalous InvokeAgent Calls (locked: unlock with TL Creds)
- Cloud Sandbox Environment Discovery Commands (locked: unlock with TL Creds)
- Outbound Connection to Known DNS Tunneling Domains (locked: unlock with TL Creds)
- IMDS Metadata Service Credential Theft from Sandbox (locked: unlock with TL Creds)
- Suspicious Pre-Signed S3 URL Generation from Bedrock Agent (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sample indicators (2 of 15)

Defanged, TLP:CLEAR.

- Domain: `dnshook[.]site`
- Domain: `s3[.]us-east-1[.]amazonaws[.]com`

Full set of 15 indicators unlocks with TL Creds: https://threadlinqs.com/tl-creds

## Sources

- [Cracks in the Bedrock: Escaping the AWS AgentCore Sandbox](https://unit42.paloaltonetworks.com/bypass-of-aws-sandbox-network-isolation-mode/)
- [Amazon Bedrock AgentCore Documentation - Network Isolation](https://docs.aws.amazon.com/bedrock/latest/userguide/agentcore-network-isolation.html)
- [AWS Instance Metadata Service Version 2 (IMDSv2) Documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html)
- [MITRE ATT&CK T1552.005 - Unsecured Credentials: Cloud Instance Metadata API](https://attack.mitre.org/techniques/T1552/005/)
- [MITRE ATT&CK T1071.004 - Application Layer Protocol: DNS](https://attack.mitre.org/techniques/T1071/004/)
- [AWS Firecracker MicroVM Security Overview](https://firecracker-microvm.github.io/)
- [AWS Route 53 Resolver DNS Firewall Documentation](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resolver-dns-firewall.html)
- [Unit 42 - Palo Alto Networks Threat Research](https://unit42.paloaltonetworks.com/)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-0331
