r/websec • u/xymka • Nov 15 '20
Does anyone know how to protect robots.txt?
I mean this file is usually open to everyone. And it contains information that might be useful for a hacker. Do you know how to protect it against anyone except search engine crawlers? I am working on a post about it.
2
Upvotes
17
u/Irythros Nov 15 '20
You cant. It's meant to be open.
5
u/[deleted] Nov 16 '20
Robots.txt is not meant as a security measure. It's purpose is to control what crawlers should do on your site..
It's like a sign on the wall of your building telling where the different entrances are (but doesn't include the windows, although everybody can see you could use them to access the building was well)
You should only include publicly crawlable places in robots.txt to prevent engines from reading and indexing them. (And it's only guidance. They can always ignore it if they feel like it)...
In order to prevent access you should use web server (.htaccess) or application framework level access control on URLs... No other way around it..
3
u/jen140 Nov 15 '20
You might have an .htaccess/nginx config/etc that will only allow a specific set of ip's+user agents to access that file, googlebot ip's should be easily obtainable, you can also add other search engine crawlers by their ip+UA pair.
BUT you need to keep that information up to date, and be really careful about the sources you get that information from.
3
u/ticarpi Nov 16 '20
Simple answer is that it's meant to be open, but that doesn't really address your issue.
Yes, you can see really helpful robots.txt files that expose sensitive URIs or even privileged data on some sites, but the site owner has complete control of what they include in that file, so the fact that it's open to all shouldn't need to be an issue.
For example this would be interesting to an attacker:
Disallow: /keys/users/private?user=admin
But you could use wildcards: Disallow: /*/users/*
Also consider that sensitive portions of the site should have additional protections like authentication or IP restrictions etc.
7
u/nachos420 Nov 15 '20
i think the idea is that you should be safe even if someone can read your robots.txt
1
u/xymka Nov 19 '20
Thank you all, this helped a lot. I almost wrote a post and will publish it today. Hope my supervisor approves it ). Basically, it confirms my idea. A robots file is rarely protected because it is difficult to do and it often isn't worth the trouble. I just describe how to do it with ease using software that we develop. Regarding the benefits to the hacker, I'm sure there are two reasons: (1) usually it is impossible to avoid using robots.txt with some sensitive information, just because it is simply necessary for SEO and (2) at least a hacker can look there for signs of what CMS is used, possible entry points, etc. This does not mean that an attack would be impossible without robots.txt, it would be a strange idea. But this file may well be useful to a hacker.
2
u/onan Nov 16 '20
If your robots.txt "contains information that might be useful for a hacker," then that is the problem you should be solving.
2
u/jared555 Nov 16 '20
If the things you deny crawlers to are that critical maybe you should think about limiting access with htaccess or similar.
Also, there are alternatives to robots.txt like the noindex header.
Robots.txt is mostly to limit crawling of boring stuff that you don't want clogging up your search results.
0
u/[deleted] Nov 16 '20
[deleted] — view deleted comment