Document ASGI-only requirement for BedrockAgentCoreContext
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- Half a day
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- documentation, security
Research direction
Start with src/bedrock_agentcore/runtime/context.py:16-21 and then review request-context setup in src/bedrock_agentcore/runtime/app.py:299-347. Document that BedrockAgentCoreContext is intended for ASGI use and explain the ContextVar isolation risk with WSGI; update the README or main documentation location identified during that review. Done means users can clearly see the ASGI-only requirement and security consequence.
Written by the indexing model from the issue text.
Description
Summary
BedrockAgentCoreContext uses ContextVar for storing request-scoped sensitive data (workload access tokens, OAuth2 callback URLs, authorization headers). While this is safe for ASGI web frameworks, it creates a critical security vulnerability if used with WSGI frameworks.
Problem
ContextVar isolation behavior:
- ✅ ASGI frameworks (Starlette, FastAPI, Quart): Automatically isolated per async task (each HTTP request)
- ❌ WSGI frameworks (Flask, Django WSGI): NOT automatically isolated - threads are reused across requests
Security risk with WSGI:
# WSGI thread pool scenario
# Request A (Thread 1) → BedrockAgentCoreContext.set_workload_access_token("USER_A_TOKEN")
# Request B (Thread 1) → BedrockAgentCoreContext.get_workload_access_token()
# → Returns "USER_A_TOKEN" ❌ (LEAKED!)
This causes:
- Token leakage between requests
- Authorization bypass vulnerabilities
- Data access from one user by another
Current Status
The AgentCore SDK correctly uses Starlette (ASGI), making it safe. However, there's no documentation warning against using BedrockAgentCoreContext in non-ASGI environments.
Recommendation
Add documentation to explicitly state:
-
In
src/bedrock_agentcore/runtime/context.pydocstring:- BedrockAgentCoreContext is designed for ASGI web frameworks only
- Using with WSGI frameworks creates security vulnerabilities
- ContextVars rely on async task isolation, not thread isolation
-
In README or main documentation:
- Note that the SDK requires ASGI (already uses Starlette)
- If users want to integrate with Flask/WSGI, they need alternative approaches (Flask's
gobject, thread-local storage with manual cleanup)
-
Consider adding a runtime check (optional):
- Detect if running in WSGI context
- Emit warning about unsafe usage
References
- BedrockAgentCoreContext implementation:
src/bedrock_agentcore/runtime/context.py:16-21 - Context initialization in request handler:
src/bedrock_agentcore/runtime/app.py:299-347 - Python ContextVar documentation: https://docs.python.org/3/library/contextvars.html
Impact
- Severity: High (security vulnerability if misused)
- Likelihood: Low (SDK uses Starlette, but users might try to reuse context pattern)
- Action: Documentation update to prevent misuse
- Dominant language
- Python
- Stars
- 786
- Forks
- 163
- Avg merge
- 4h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/bedrock-agentcore-sdk-python
-
bug high-severity
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 reaction ·
Maintainers usually reply within 1 day
-
delete_all_long_term_memories_in_namespace deletes only the first 10 recordsPossibly taken @Fire162 claimed this 18 days ago. Openbug high-severity
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
aws/bedrock-agentcore-sdk-python#727 ·
Maintainers usually reply within 1 day
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challengePossibly taken @abhiramshaji-cyber claimed this 24 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
aws/bedrock-agentcore-sdk-python#702 ·
Maintainers usually reply within 1 day
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexPossibly taken @citizen204 claimed this 144 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Maintainers usually reply within 1 day
All issues in aws/bedrock-agentcore-sdk-python
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
snap-stanford/Biomni#380 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
microsoft/playwright-python#3361 ·
Maintainers usually reply within 1 day
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainers usually reply within 1 day
-
documentation priority: low size: S status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cubrid-lab/pycubrid#1307 ·
Maintainers usually reply within 1 day
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainers usually reply within 1 day