fix: disable redirect following in OAuth picture fetch (SSRF) (#24809)
_process_picture_url validated the initial picture URL with validate_url() but then aiohttp followed 3xx redirects without re-validating the target, so a validate_url-passing public URL could 302 to an internal address and the body was base64-stored in the user's profile_image_url. This is the sixth call site of the CVE-2026-45401 redirect-bypass cohort; the other five already pass allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS. Apply the same.
This commit is contained in:
1 parent
854440f703
commit
d07fd7d6d8
1 file changed
+7
-1
@@ -1448,7 +1448,13 @@ class OAuthManager:
|
|||||||
'Authorization': f'Bearer {access_token}',
|
'Authorization': f'Bearer {access_token}',
|
||||||
}
|
}
|
||||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||||
async with session.get(picture_url, **get_kwargs, ssl=AIOHTTP_CLIENT_SESSION_SSL) as resp:
|
# allow_redirects=False prevents redirect-based SSRF: validate_url() only vetted the initial URL (CVE-2026-45401 cohort).
|
||||||
|
async with session.get(
|
||||||
|
picture_url,
|
||||||
|
**get_kwargs,
|
||||||
|
ssl=AIOHTTP_CLIENT_SESSION_SSL,
|
||||||
|
allow_redirects=AIOHTTP_CLIENT_ALLOW_REDIRECTS,
|
||||||
|
) as resp:
|
||||||
if resp.ok:
|
if resp.ok:
|
||||||
picture = await resp.read()
|
picture = await resp.read()
|
||||||
base64_encoded_picture = base64.b64encode(picture).decode('utf-8')
|
base64_encoded_picture = base64.b64encode(picture).decode('utf-8')
|
||||||
|
|||||||
Reference in new issue
Block a user