toolhq.io

All posts
6 min readby Jameel Haider

security.txt: giving security researchers somewhere to report a vulnerability

Someone finds a problem on your site. They mean well and want to tell you. Then they look for where to send it, and find a sales form, a support queue that replies with a ticket number, and a contact page with no email address on it.

A security.txt file fixes that. It is a plain text file that tells a researcher who found a problem where to report it. Without one, reports go to a sales address, a support queue, or nowhere, and some researchers give up and publish instead.

Where the file lives

The canonical location is:

https://example.com/.well-known/security.txt

A copy at the web root, /security.txt, is permitted for legacy reasons, but the .well-known path is the one to use and the one tools look for first.

Three rules apply to how it is served:

  • It must be served over HTTPS. A contact address delivered over plain HTTP can be rewritten by anyone in the middle.
  • It must be served as text/plain. A framework that wraps every unknown path in an HTML shell will break it.
  • It applies per host. A file on www.example.com says nothing about api.example.com, so each host that matters needs its own.

That last point is easy to miss. If you have an app subdomain, a docs subdomain and a marketing site, a researcher on any of them will look at that host and no other.

The format

One Field: value per line, with # for comments. A minimal, valid file is two lines:

Contact: mailto:security@example.com
Expires: 2027-11-12T00:00:00Z

Only those two fields are required.

Contact can appear more than once, in order of preference. Each value is a URI: an email address as mailto:, a phone number as tel:, or a URL to a reporting form. A bare email address without mailto: is the most common formatting mistake.

Expires appears exactly once. It is a single ISO 8601 timestamp after which the file should no longer be trusted.

The optional fields are worth a few more lines:

FieldWhat it holds
EncryptionA URL pointing to your public key, never the key itself inline
AcknowledgmentsA page thanking people who reported issues
Preferred-LanguagesComma separated language tags, such as en, de
CanonicalThe URIs where this file is meant to live
PolicyYour disclosure policy
HiringA jobs page

Hiring is why many of these files double as recruitment adverts. It is harmless, but it is not the reason the file exists, so do not let it be the only field anyone maintained.

A fuller example:

# Security contact for example.com
Contact: https://example.com/security/report
Contact: mailto:security@example.com
Expires: 2027-11-12T00:00:00Z
Encryption: https://example.com/pgp-key.txt
Preferred-Languages: en, de
Canonical: https://example.com/.well-known/security.txt
Policy: https://example.com/security/policy

Expires is the field people get wrong

The point of Expires is to stop a stale file sending reports to a mailbox that was closed two reorganisations ago. The side effect is that the file has a shelf life, and nothing warns you when it runs out.

A date in the past makes the file worthless. A careful researcher treats an expired file as untrusted, and an automated checker flags it as invalid.

Set the date about a year out. Much longer defeats the purpose, and much shorter means you are renewing it constantly. Then put the renewal in the same place as your certificate renewals: the same calendar, the same runbook, the same person. If your certificates renew automatically and nothing else in that calendar does, generate the file at deploy time with a date computed from the build, so that shipping regularly keeps it fresh.

The file can also be signed with an OpenPGP clearsigned signature, in which case the signature covers the whole file. That lets a researcher confirm the contact details were written by you and not by whoever compromised the web server. If you sign it, include Canonical, so the signed content states which URLs it belongs to. Remember that a signed file cannot be edited by hand afterwards: changing the Expires line means signing it again.

Make sure someone is listening

The file is the easy part. What happens after a report arrives is what matters.

  • Use a role address or a form, not a person. security@ survives someone leaving. A named individual does not, and their mailbox may be forwarded somewhere odd.
  • Check that the destination accepts mail from strangers. Reports come from personal addresses you have never seen, often with attachments or proof of concept code. A spam filter that quarantines those, or a group address that only accepts internal senders, silently swallows them. Send a test from an outside account.
  • Confirm it is monitored. An alias that delivers to a shared inbox nobody opens is the same as no alias.
  • Write a short Policy page. Say what is in scope, what is not, and that you will not pursue good faith research. Researchers read this before deciding whether reporting to you is safe. You do not need a bounty to have a policy.

A file that promises a reply and then does not deliver one is worse than none. It tells the researcher you were warned, and it removes their reason to wait.

Reports themselves often contain sensitive detail: request logs, session tokens, a working exploit. That is what Encryption is for, and the habits in sharing logs and API keys safely apply to how your team passes the report around once it lands. If a report arrives by email and you want to check it really came from where it claims, how to read email headers covers that.

Checking yours

Fetch the file and read it as a stranger would. Confirm it loads at the .well-known path over HTTPS without a redirect to a login page, and use the HTTP Header Viewer to confirm the Content-Type is text/plain. Check that Expires is in the future. Then send a message to every Contact and see who answers, and how long it takes.

A security.txt file is not a security control. It blocks nothing, which is why it sits alongside the response headers in the practical checklist and does not replace any of them. The Security Headers Scanner tells you how well a site defends itself. This file covers the case where the defence was not enough and somebody kind noticed first.