All hands-on labs

Premium Hands-on labintermediatered teamAWS

Bedrock AgentCore Privilege Escalation via Code Interpreters

Learn how a limited user can escalate privileges in AWS Bedrock AgentCore by abusing an overprivileged code interpreter role. Exploit a misconfigured custom code interpreter by directly invoking arbitrary Python and shell commands that execute with the interpreter's IAM role permissions rather than their own limited credentials, enabling unauthorized S3 data exfiltration and control plane access. The lab teaches the security implications of overprivileged AI infrastructure, proper least-privilege controls for execution roles, and how Public vs Sandbox network modes affect the attack surface.

  • 6 guided tasks
  • Capture the flag
  • Terminal in the browser

Scenario

This lab is based on [Nigel Sood's research](https://sonraisecurity.com/blog/aws-agentcore-privilege-escalation-bedrock-scp-fix/).

Amazon Bedrock is Amazon's fully managed service for building and deploying generative AI applications using foundation models. AgentCore is a component of Bedrock that enables AI agents to perform tasks by orchestrating multiple tools and APIs. Code interpreter, a feature within AgentCore, provides isolated execution environments where agents can run arbitrary code (Python, shell commands, etc.) to analyze data, perform calculations, or interact with AWS services. Like everything else in AWS, these interpreters execute code using an IAM execution role, which determines what AWS resources and actions the code can access.

This lab demonstrates how these privileges can unintentionally create PrivEscs that provide access to AWS services and data when agents use custom code interpreters with overprivileged execution roles.

You are a security consultant conducting a penetration test for a company using AWS Bedrock for AI-powered data analysis. During your assessment, you discover that the custom code interpreters used by their AI agents have been configured with overprivileged execution roles - a common misconfiguration when teams prioritize speed to market.

Your mission: demonstrate how a threat actor with stolen developer credentials can exploit this AI feature to break through security boundaries and hijack AWS S3 resources for data theft.

What you will learn

  • Set up CLI access to the lab account with the provided credentials
  • Find an overprivileged code interpreter execution role and read its S3 permissions
  • Create a custom Bedrock AgentCore code interpreter that uses that role
  • Invoke the code interpreter to run commands with the role's permissions
  • Read customer data from S3 that your own user cannot reach, and capture the flag
Hands-on lab

Bedrock AgentCore Privilege Escalation via Code Interpreters

Included in Cybr Premium.