VYPR
Medium severity6.3GHSA Advisory· Published Jun 15, 2026· Updated Jun 15, 2026

aiohttp: DigestAuthMiddleware Applies Credentials to Cross-Origin Redirect Challenges

CVE-2026-54276

Description

Summary

`DigestAuthMiddleware` can send an authentication response after following a cross-origin redirect.

Impact

If the client follows a redirect (the default option) to an attacker controlled domain, the attacker may be able to extract the auth digest.

This likely requires an open redirect vulnerability or similar on the target domain for an attacker to be able to execute. Further, the attacker is only receiving the digest, so should only be able to extract the user's credentials if the cryptography is weak or there is some kind of password reuse.

Workaround

Disable `follow_redirects` if this is a concern.

-----

Patch: https://github.com/aio-libs/aiohttp/commit/38d16060037e1bfcd6d677abababa3c2a4bb58fa

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected products

11

Patches

Vulnerability mechanics

Root cause

"DigestAuthMiddleware did not scope credentials to the origin of the first request, allowing a cross-origin redirect to trigger a digest response to an attacker-controlled server."

Attack vector

An attacker must first have an open redirect or similar vulnerability on the target domain that causes aiohttp's `ClientSession` (with `follow_redirects=True`, the default) to follow a redirect to an attacker-controlled origin. When the attacker's server responds with a `401` Digest challenge, the unpatched middleware computes and sends a digest response using the victim's configured credentials, leaking the digest to the attacker [ref_id=1]. The attacker can then attempt to recover the password from the captured digest if the cryptography is weak or the password is reused.

Affected code

The vulnerability is in `aiohttp/client_middleware_digest_auth.py` in the `DigestAuthMiddleware.__call__` method. Prior to the patch, the middleware would answer a `401` challenge from any origin, including one reached via a cross-origin redirect. The patch adds origin-scoping logic that pins credentials to the first request's origin and skips authentication for other origins unless they fall within an RFC 7616 `domain` protection space.

What the fix does

The patch introduces a `_origin` attribute on the middleware instance, set to the origin of the first request the middleware handles. In `__call__`, before processing the request, the middleware now checks whether the request's origin matches `_origin` or is covered by a previously advertised `domain` directive. If neither condition holds, the request is passed through without adding an `Authorization` header [patch_id=6088948]. This prevents the middleware from answering a cross-origin challenge, whether reached via redirect or direct request, unless the anchor origin explicitly vouched for that origin via RFC 7616's `domain` parameter.

Preconditions

  • configThe target domain must have an open redirect or similar mechanism that allows an attacker to redirect the aiohttp client to an attacker-controlled origin.
  • configThe aiohttp ClientSession must be configured with follow_redirects=True (the default).
  • inputThe attacker's server must respond with a 401 status and a WWW-Authenticate: Digest challenge.

Generated on Jun 15, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

3

News mentions

1