Skip to content

Quote the realm in BASIC and DIGEST challenges as a quoted-string - #1256

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:realm-quoted-string
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:realm-quoted-string

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

The realm name is written between double quotes in the WWW-Authenticate challenge without escaping, so a realm containing " or \ produces an invalid quoted-string (RFC 9110, sections 2.2 and 5.6.4).

This has a real effect with DIGEST. Recipients must treat a quoted-pair as the following octet, so for a realm CORP\Intranet curl uses CORPIntranet to compute the response and authentication always fails (401 with the right password). With the realm escaped, the same request returns 200 and a wrong password still returns 401. For BASIC, a realm Test "Realm" was sent as realm="Test "Realm"".

Adds HttpParser.quote() next to the existing unquote(), escaping only DQUOTE and backslash, and uses it in both authenticators. The DIGEST read side already unquotes the realm from the Authorization header.

TestAuthenticatorRealmName fails without the change. Checked on a running Tomcat with curl; the authenticator tests and the smoke profile pass.

The realm name was written between double quotes without escaping, so a
realm containing DQUOTE or backslash produced an invalid quoted-string
(RFC 9110, sections 2.2 and 5.6.4). With a realm such as CORP\Intranet a
client that handles quoted-pair computed the DIGEST response with a
different realm and authentication always failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant