HTML Access Control Busted By Security ResearchersOpen source HTExploit tool can bypass a standard directory protection technique used to secure many types of Web pages, security experts demonstrated at Black Hat.
Two researchers presenting at last week's Black Hat conference in Las Vegas demonstrated a new technique they've discovered for bypassing .htaccess files. Also known as hypertext access files, they're primarily used for setting directory-level access controls for websites, and are common across multiple types of Web server software--including the open source Apache HTTP Server, which is the most commonly used Web server software in the world.
The two presenters--security researcher Maximiliano Soler, who works for Standard Bank in Argentina, and penetration tester Matias Katz, who founded Mkit Argentina--also released a tool under open source license, written in Python, that they developed to exploit the vulnerability. According to the presenters, the tool, named HTExploit, lets users list the contents of a directory protected this way, bypassing the authentication process.
They emphasized that their tool was designed to be used from within protected directories--run by people who already have access to a Web server--rather than via a publicly accessible site. But the vulnerability they uncovered could be used by outsiders to gain access, via the Internet, to parts of websites that are ostensibly protected by an .htaccess file.
[ Black Hat presenters warn of a possible attack on network-connected hardware. Read more at Mass Router Infection Possible: Black Hat. ]
Why bother attacking .htaccess files? The answer is simple: any directory that someone takes the time to protect is more likely to contain sensitive or secret information. "Today [it] is common to find lazy administrators and/or developers using directories located on the same Web server to save backups files, configurations, their own jobs, outdated versions, or new developments to be implemented in the future," the researchers wrote in a related white paper.
The good news is that with some small HTML and PHP tweaks to fix the exploitable configuration errors, thus restricting the types of access requests that can be made, vulnerable .htaccess pages can be made immune to the exploit outlined by Soler and Katz.
The bad news is that the problem they've uncovered may be quite widespread, and it could be used to compromise not just any directory that contains a misconfigured .htaccess file, but potentially any PHP file on the same site.
"What Katz and Soler described in their session is not some rare 'corner case' hack that could only possibly occur in a lab with billions of automated attempts; this is easily testable in the real world, and the tools to exploit it are freely available," said ESET security researcher Cameron Camp in a blog post.
The vulnerability stems from the fact that Apache "hands off PHP-based requests within .htaccess to PHP itself, which has been working fine on millions and millions of websites for years," said Camp. But if the .htaccess file gets fed some type of nonstandard input--in effect, injected--then "PHP automatically--unless otherwise instructed--treats it as a GET request, and allows the utility to start saving the PHP files on a webserver to your local filesystem," he said.
From there, however, the process continues, and begins combing accessed PHP files for any links they contain to other files on the same Web server, then downloading those to the local file system. In short order, an attacker--or penetration tester--could quickly grab copies of many, if not all, PHP files on a Web server. Such files could contain sensitive information, such as "references to login credentials for databases, passwords, personally identifiable information, and a host of other goodies that [could] be sold on the black market or used to enable further exploits," said Camp.
"Now might be a good time to check your website configuration to make sure you're protected, before the bad guys go scouring around trying to use this type of exploit," said Camp. "If you're not the person in charge of your website, you might want to point out this problem to the person who is. They may thank you, a lot."
Your networks may be under attack as you read this, but unless your security personnel are analyzing logs and leveraging common tools that are well known to your network operations teams, you may not find out until it is too late. In our What's Going On?: Monitor Networks To Thwart Intrusions report, we explain how your security and network teams can cooperate and use common tools to detect threats before your databases are compromised. (Free registration required.)