Add a security.txt file
For administrators and hosting teams. A security.txt tells researchers where to report vulnerabilities in your site.
The project's statement lists it as not shipped (Adding security.txt).
Warning
.htaccess slows down every request. When .htaccess files are enabled (AllowOverride anything but None), let alone
used, Apache looks for them and reads and evaluates them on every request, in every directory of the path, and
page loading times go up drastically (measured). The only real fix is to switch the feature off for
the virtual host: AllowOverride None in the HTTPS virtual host, and the rules in the virtual host's own
configuration as mod_rewrite rules. That is far faster in production speed tests and well worth the time it takes
to optimize a production configuration. Switch over right away: copy the rules of the
example HTTPS virtual host into your virtual host (with the static cache, also
staticcache_offload.conf), set AllowOverride None, run apachectl configtest, reload Apache and
test the site. The same rules for other servers: nginx, LiteSpeed,
Caddy, IIS, Velocity (built in); where virtual host rules go in a control
panel: Plesk, cPanel, DirectAdmin, ISPConfig.
On LiteSpeed or OpenLiteSpeed, the server's own page cache can also answer anonymous visitors and crawlers without PHP: Page caching with LiteSpeed and OpenLiteSpeed.
Note This page describes features and common practice; it is not legal advice. Check the law that applies to your organization with your legal counsel.
Contents
Before you start
- A security contact mailbox and, ideally, a published disclosure policy page (see "Vulnerability disclosure").
- Access to the document root and the web server configuration.
Steps
Create
.well-known/security.txtin the document root:Contact: mailto:[email protected] Expires: 2027-10-31T23:00:00.000Z Policy: https://www.example.gov/vulnerability-disclosure Preferred-Languages: en Canonical: https://www.example.gov/.well-known/security.txtContactandExpiresare required by RFC 9116 (https://www.rfc-editor.org/rfc/rfc9116); keepExpiresless than a year ahead.Apache with
.htaccess_root: dot paths except.well-knownanswer 404, and the last rule sends everything else toindex.php. Add, beforeRewriteRule .* index.php:RewriteRule ^\.well-known/security\.txt$ - [L]nginx: make sure a
locationserves the file before requests fall through toindex.php.Add the file (and the rule) to your deployment so the next release keeps them.
Check that it worked
curl -sI https://www.example.gov/.well-known/security.txt | head -3
curl -s https://www.example.gov/.well-known/security.txtStatus 200, a plain text type, your file. An HTML page means the request reached index.php. Put the Expires date in
your calendar.
Related pages
- Adding security.txt
- Vulnerability disclosure
- A useful robots.txt out of the box
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.