Re: p1: whitespace in request-target

On 18/04/2013 12:49 p.m., Mark Nottingham wrote:
> p1 3.1.1 says:
>
>> Unfortunately, some user agents fail to properly encode hypertext references that have embedded whitespace, sending the characters directly instead of properly encoding or excluding the disallowed characters. Recipients of an invalid request-line SHOULD respond with either a 400 (Bad Request) error or a 301 (Moved Permanently) redirect with the request-target properly encoded. Recipients SHOULD NOT attempt to autocorrect and then process the request without a redirect, since the invalid request-line might be deliberately crafted to bypass security filters along the request chain.
>    http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-22#section-3.1.1
>
> I note that the practice of correcting this is fairly widespread; e.g., in Squid, the default is to strip the whitespace, and IIRC has been for some time:
>
>    http://www.squid-cache.org/Doc/config/uri_whitespace/
>
> I think that the Squid documentation needs to be corrected, because the text in RFC2396 (and later in 3986) is about URIs in contexts like books, e-mail and so forth, not protocol elements:
>
>    http://tools.ietf.org/html/rfc3986#appendix-C

The relevant portion there being:
  "

    For robustness, software that accepts user-typed URI should attempt
    to recognize and strip both delimiters and embedded whitespace.
"
Note that Squid *does* accept user-typed HTTP messages and the software traditionally causing whitespace issues
are usually the specialized clients sending URI through HTTP-compatible messages in the URL field (Outlook and Exchange with RCP, some shockwave ICY clients).

> My question is why this is a SHOULD / SHOULD NOT. We say that SHOULD-level requirements affect conformance unless there's a documented exception here:
>
>    http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-22#section-2.5
>
> ... but these requirements don't mention any exceptions. Is the security risk here high enough to justify a MUST / MUST NOT? If not, they probably need to be downgraded to ought (or an exception needs to be highlighted).

The biggest risk is software truncating portions of the URL, or (like 
Squid when there is a trailing SP on the line) determining that the 
HTTP/1 version label is part of the URL on a HTTP/0.9 syntax GET request 
- which results in any HTTP/1.x header features being ignored. The 
actual security worst-case risk of this undeterminable, but its not 
going to be good for the transaction at the best of times.

Amos

Received on Thursday, 18 April 2013 03:48:42 UTC