0

Would access need to be gained to the server in question or can an .htaccess file leak information in some way?

3 Answers 3

2

Would access need to be gained to the server in question?

To read the .htaccess file, yes, assuming the server is properly configured everything else running on the server is secure. Most default apache installations have a rule that files starting with .ht will not be served statically. It could still be served by a buggy application on the server, like a PHP script that passes user input directly into file_get_contents .

Can an .htaccess file leak information in some way?

Yes, it can leak anything that is in it. Basic information like the path to your web root can be found in it. Perhaps an open redirect could be discovered. Some applications have a .htaccess file set environment variables containing database credentials. In reality though, if someone is able to get access to your .htaccess file, you probably have bigger problems.

1

This is configuration specific. By default, Apache is configured to prevent any files starting ".ht" from being served through the web server. This wouldn't protect any files being served, for example, by another web server, or found through FTP access. Other web server software don't always use .htaccess files, so may expose their contents, but in that case, the contents will not be in active use.

If .htaccess files are exposed, this can reveal details about logging locations, password files, environmental variables, and pretty much anything else that could be in a system wide Apache config file.

2
  • What about .html files? Commented Jan 11, 2016 at 15:06
  • If they start .html, they will be blocked by Apache in default config. Would be a fairly unusual file name though - something.html would be more normal, which doesn't start with .ht, so is fine.
    – Matthew
    Commented Jan 11, 2016 at 15:14
1

It's not entirely clear what you mean here.

An .htaccess file is in essence, just a config file on the server. Assuming the server is reasonably well configured and hardened, so no unauthorized user can access the file itself, it should not leak any information, as it will only be used by the server itself, and internally and invisibly from the outside.

That said, there may be caveats: If for instance, you want to use the .htaccess file to limit access to a directory by setting a password, then that will be more open to a brute force attack than other login options containing more logic, e.g. to allow only a small number of attempts before either displaying a CAPTCHA, or locking the account, etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .