Document ASGI-only requirement for BedrockAgentCoreContext
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- Nửa ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tài liệu
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- documentation, security
Hướng nghiên cứu
Bắt đầu với src/bedrock_agentcore/runtime/context.py:16-21, sau đó xem xét việc thiết lập request context trong src/bedrock_agentcore/runtime/app.py:299-347. Ghi lại rằng BedrockAgentCoreContext được thiết kế để sử dụng với ASGI và giải thích rủi ro cô lập của ContextVar với WSGI; cập nhật README hoặc vị trí tài liệu chính được xác định trong quá trình xem xét đó. Hoàn tất khi người dùng có thể thấy rõ yêu cầu chỉ sử dụng ASGI và hệ quả về bảo mật.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 786
- Fork
- 163
- Merge trung bình
- 4 giờ
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/bedrock-agentcore-sdk-python
-
bug high-severity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/bedrock-agentcore-sdk-python#752 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
OpenAIConverseConverter restores an empty history when one blob or text payload fails to parseĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/bedrock-agentcore-sdk-python#751 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
delete_all_long_term_memories_in_namespace deletes only the first 10 recordsCó thể đã có người làm @Fire162 đã nhận 18 ngày trước. Đang mởbug high-severity
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
aws/bedrock-agentcore-sdk-python#727 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MPP: credential is always sent in Authorization, ignoring header="Payment-Authorization" in the challengeCó thể đã có người làm @abhiramshaji-cyber đã nhận 24 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/bedrock-agentcore-sdk-python#702 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] update_message fails with parameter validation error when SessionMessage.message_id is a Strands positional integer indexCó thể đã có người làm @citizen204 đã nhận 144 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/bedrock-agentcore-sdk-python#556 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của aws/bedrock-agentcore-sdk-python
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
snap-stanford/Biomni#380 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
microsoft/playwright-python#3361 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
cubrid-lab/sqlalchemy-cubrid#1397 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: low size: S status: needs triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
cubrid-lab/pycubrid#1307 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Installer hides SSL certificate errors as bare URLError, and the suggested fix can't workĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
ShaftHQ/chaosengine-harness#143 ·
Maintainer thường phản hồi trong vòng 1 ngày