|
www.hmrc.gov.uk Initial Threat Level:  Current Threat Level:  (17/04/09) This has now been resolved. Summary: A critical directory traversal vulnerability has been discovered on Her Majesty's Customs & Excise web site.
Description: http://search2.hmrc.gov.uk/kbroker/hmrc/atoz/atoz.jsp?letter=A Text contained within the "letter" variable at the above location is not being sanitized before being executed. This vulnerability allows hackers to traverse directories on the server and include files which wouldn't ordinarily be available. For example, sites which require database access have configuration files which store authentication details for the database. This data is typically stored in plain (unencrypted) format and can obviously be read by anyone. Fortunately, the location of these files is hidden and access to them is usually limited by access control lists (ACL's). However, entering arbitrary code in to the "letter" variable allows us to bypass any permissions and read virtually anything on the server. If you replace the 'A' with '../' (not including the quotes), you're met with an error to say the file does not exist. "The requested resource (/kbroker/hmrc/atoz/atoz/a2z-../.html) is not available" If you now add another '../' to the end of the URI, you're met with this error. "The requested resource (/kbroker/hmrc/atoz/atoz/.html) is not available" Notice the difference between the two bold lines? We're no longer looking in the "a2z-" directory... we're looking in "/atoz". How far up the tree you go depends on how many "../" you use. As you can see, the error contains ".html" which cannot be altered in the address bar. This text is being concatenated behind the scenes... so the hacker is limited to HTML (web pages) only, right? Wrong. By adding the right series of escape codes, almost any file becomes available (ACL's aside). Consider this directory structure... - root - - - web_files\index.php?letter=A - - - web_files\a.html - - - protected_files\my_passwords.txt - - - protected_files\my_credit_card_number.txt If you were to execute the top line (index.php?letter=A), the server would show the user the data within the file "a.html". If I run (index.php?letter=../protected_files/my_passwords.txt), the server no longer looks within the current directory and allows us to see files elsewhere. For obvious reasons, the example in italics has some code missing to prevent abuse of this PoC. |