fix: validate region parameter to prevent SSRF request redirection#417
fix: validate region parameter to prevent SSRF request redirection#417
Conversation
|
f0e514f to
c388719
Compare
c388719 to
0aa64b2
Compare
|
Re: Breaking Change Warning — all 9 flagged items reviewed: #1-4, #6-9 (attribute value changed): False positives. The #5 ( No breaking changes in this PR. |
0aa64b2 to
24c32ac
Compare
24c32ac to
9355d4f
Compare
The region parameter was interpolated directly into endpoint URL f-strings without validation, allowing crafted values like "x@attacker.com:443/#" to redirect SDK API calls — including SigV4-signed requests with credentials — to non-AWS hosts. Same vulnerability class as CVE-2026-22611. Defense-in-depth fix: 1. validate_region() in endpoints.py checks against regex \A[a-z]{2}(-[a-z]+)+-\d+\Z using \Z anchor to prevent newline bypass. Applied in get_data_plane_endpoint(), build_runtime_url(), AgentCoreRuntimeClient, and BrowserClient. 2. _validate_endpoint_url() verifies constructed URL hostname ends with .amazonaws.com. Also validates env var endpoint overrides. 3. Boto3-based clients (CodeInterpreter, IdentityClient, ResourcePolicyClient, MemoryControlPlaneClient) no longer pass redundant endpoint_url — boto3 resolves identical endpoints natively and includes its own region validation. Ref: V2177374595
9355d4f to
20227b2
Compare
Summary
Fixes SSRF vulnerability where crafted
regionvalues (e.g.,x@attacker.com:443/#) redirect SDK API calls — including SigV4-signed requests with credentials — to non-AWS hosts. Same vulnerability class as CVE-2026-22611.Two-part fix:
1. Region validation for manual URL construction paths (endpoints.py, a2a.py, AgentCoreRuntimeClient, BrowserClient)
validate_region()with regex\A[a-z]{2}(-[a-z]+)+-\d+\Zusing\Zanchor to prevent newline bypass_validate_endpoint_url()verifies constructed URL hostname ends with.amazonaws.comInvalidRegionError(ValueError)for backward compatibility2. Remove redundant
endpoint_urlfrom boto3 clients (CodeInterpreter, IdentityClient, ResourcePolicyClient, MemoryControlPlaneClient)endpoint_urlnow only passed when env var override is explicitly set (BEDROCK_AGENTCORE_DP_ENDPOINT,BEDROCK_AGENTCORE_CP_ENDPOINT)Files changed
_utils/endpoints.pyvalidate_region(),_validate_endpoint_url(),InvalidRegionErrorruntime/a2a.pybuild_runtime_url()(explicit + ARN-extracted region)runtime/agent_core_runtime_client.py__init__()tools/browser_client.py__init__(), removeendpoint_urlfrom boto3 callstools/code_interpreter_client.pyendpoint_urlfrom boto3 callsservices/identity.pyendpoint_urlfrom boto3 callsservices/resource_policy.pyendpoint_urlfrom boto3 callsmemory/controlplane.pyendpoint_urlfrom boto3 callstest_region_validation.pytest_code_interpreter_client.pytest_browser_client.pyTest plan
Ref: V2177374595