|Summary:||Space in username not properly escaped in log files (%u)|
|Product:||Apache httpd-2||Reporter:||David A. Wheeler <dwheeler>|
|Component:||Core||Assignee:||Apache HTTPD Bugs Mailing List <bugs>|
|Attachments:||Hi, i wrote a little patch for this old bug. It replaces the space in usernames with an : in the "log_remote_user" function.|
Description David A. Wheeler 2011-07-22 19:43:16 UTC
Spaces, if any, in a username are not being properly escaped when they are written to logs (as part of %u). The normal logs use space as a delimiter between field, so have an unescaped space screws up all log processing for anything involving usernames (%u) with spaces. This is ESPECIALLY a problem for user SSL certificates, because organizations (O=) typically include a space character, e.g., "U.S. Government". Even the Apache docs show an organization "O=" with a space in: http://httpd.apache.org/docs/2.2/ssl/ssl_howto.html. Thus, if usernames are actually user SSL certificates, then anyone with an organization having a space in it (including U.S. Government") will have a corrupted log entry. Note that the DEFAULT log format includes %u. This is NOT the same as bug 28117, because this involves whitespace not backslashes. Here's an example of the format I see in the log files: 220.127.116.11 "-" /C=US/O=U.S. Government/OU=DoD/OU=PKI/OU=CONTRACTOR/CN=someNAME.someNUMBER [22/Jul/2011:14:56:50 -0400] "GET /somestuff HTTP/1.1" 200 4319 Notice that "U.S. Government" has an embedded space. But a leading "/" doesn't tell anyone where it begins or ends. I don't know which escape mechanism is the right one for usernames. I can imagine %20 working. Alternatively, surround it with double-quotes if there's an embedded space, and escape double-quote as a pair of double-quotes inside that. The key is to pick one. I have confirmed that this happens in httpd version 2.2.3 of CentOS version 5.6. I don't know for sure if it happens in later versions, though I suspect it does. However, I'm seeing this in a production system, and I don't have the luxury of upgrading to latest version of Apache. I originally found this problem when trying to parse a log using the Apachelog Python library at http://code.google.com/p/apachelog/downloads/list but I don't think the library is at fault here. Thanks!
Comment 1 Seb 2014-02-05 15:47:22 UTC
Created attachment 31285 [details] Hi, i wrote a little patch for this old bug. It replaces the space in usernames with an : in the "log_remote_user" function.
Comment 2 William A. Rowe Jr. 2018-11-07 21:08:40 UTC
Please help us to refine our list of open and current defects; this is a mass update of old and inactive Bugzilla reports which reflect user error, already resolved defects, and still-existing defects in httpd. As repeatedly announced, the Apache HTTP Server Project has discontinued all development and patch review of the 2.2.x series of releases. The final release 2.2.34 was published in July 2017, and no further evaluation of bug reports or security risks will be considered or published for 2.2.x releases. All reports older than 2.4.x have been updated to status RESOLVED/LATER; no further action is expected unless the report still applies to a current version of httpd. If your report represented a question or confusion about how to use an httpd feature, an unexpected server behavior, problems building or installing httpd, or working with an external component (a third party module, browser etc.) we ask you to start by bringing your question to the User Support and Discussion mailing list, see [https://httpd.apache.org/lists.html#http-users] for details. Include a link to this Bugzilla report for completeness with your question. If your report was clearly a defect in httpd or a feature request, we ask that you retest using a modern httpd release (2.4.33 or later) released in the past year. If it can be reproduced, please reopen this bug and change the Version field above to the httpd version you have reconfirmed with. Your help in identifying defects or enhancements still applicable to the current httpd server software release is greatly appreciated.