Repository navigation
fix: escape realm in WWW-Authenticate challenges - #920
Conversation
butonic
left a comment
There was a problem hiding this comment.
IMO yes, let's get this in. RFC 9110 requires the realm to be sent quoted, and inside it only " and \ need a backslash, which is exactly what Challenge does:
For historical reasons, a sender MUST only generate the quoted-string syntax.
A sender SHOULD NOT generate a quoted-pair in a quoted-string except where necessary to quote DQUOTE and backslash octets occurring within that string.
AFAICT the r.Host fallback can't be abused today, because the HTTP/1 server already rejects a Host header containing " or \ with a 400 (httpguts.ValidHostHeader in net/http/server.go). So in practice this hardens the configured realm. It's still the right thing to do and costs nothing.
Not a blocker IMO: params ...string gets appended unescaped. That's fine for charset="UTF-8", but the signature makes it easy to pass something unescaped later. Taking key/value pairs and quoting them inside Challenge would avoid that ... or we just keep the comment as is.
👍
Don't really know if this is really needed, but both me and @dragotin couldn't find any escaping of the host on any higher level. Is this a good idea then?