security.txt explained: how to publish one
What a security.txt file is for, the Contact and Expires fields it needs, where to put it on your website and the mistakes that make researchers ignore it.
Published
On this page
The short answer: security.txt is a small plain text file at /.well-known/security.txt on your website that tells security researchers how to report a problem to you. It needs only two lines: a Contact line with an email address or web form, and an Expires line with a date less than a year away. Serve it over HTTPS as plain text, and put a reminder in your calendar to move the date forward before it passes.
This guide explains what the file is for, what goes in it, how to publish it on common hosting, and the mistakes that make researchers ignore it.
What security.txt is for
When someone finds a security problem on your website, such as a page that leaks customer data or an out-of-date plugin, they need to know who to tell. Without a clear route, reports go to a general enquiries inbox, a social media account or nowhere at all. Some researchers give up; others publish what they found.
security.txt solves that with a file in a predictable place. It's defined in RFC 9116, published in April 2022 as an informational specification. Researchers and automated scanners know to look for it, in the same way search engines look for robots.txt.
The UK's National Cyber Security Centre recommends it. Its Vulnerability Disclosure Toolkit names security.txt as one of three parts of a basic disclosure process, alongside a dedicated contact route and a written policy, and says the file should be published on all your domains and subdomains.
What goes in the file
Each line is a field name, a colon and a value. Lines starting with # are comments. A minimal file looks like this:
Contact: mailto:security@example.com
Expires: 2027-09-30T23:00:00.000Z
A fuller file adds the optional fields:
Contact: mailto:security@example.com
Contact: https://example.com/report-a-vulnerability
Expires: 2027-09-30T23:00:00.000Z
Preferred-Languages: en
Canonical: https://example.com/.well-known/security.txt
Policy: https://example.com/vulnerability-disclosure
Encryption: https://example.com/pgp-key.txt

| Field | Required? | What it holds |
|---|---|---|
Contact | Yes, at least once | An email address (mailto:), phone number (tel:) or https:// web page. List several in order of preference. |
Expires | Yes, exactly once | The date and time the file stops being valid, in a format such as 2027-09-30T23:00:00.000Z. |
Policy | No | A link to your vulnerability disclosure policy. |
Encryption | No | A link to a public key researchers can use to encrypt their report. |
Canonical | No | The address or addresses where this file is meant to live. |
Preferred-Languages | No | Languages you can read reports in, such as en. |
Acknowledgments | No | A page thanking researchers who reported problems. |
Hiring | No | Security jobs at your organisation. |
Contact
RFC 9116 section 2.5.3 says Contact must always be present, and each value must be a proper URI: mailto: for email, tel: for phone numbers, and https:// for web pages. A plain email address without mailto: is a common mistake. Use a shared address such as security@ rather than one person's mailbox, so reports aren't lost when someone leaves.
Expires
Expires must appear exactly once. Section 2.5.5 recommends a date less than a year in the future, so stale files don't send reports to an address nobody reads. After the date passes, researchers should treat the file as out of date. This is the field people forget: a file published once and never updated expires quietly a year later.
Try it now
security.txt Checker
Check a website's security.txt: the Contact and Expires fields, the location, HTTPS, redirects and signatures, against RFC 9116.
Where and how to publish it
Section 3 of RFC 9116 sets the rules:
- The file must be at
/.well-known/security.txt, for examplehttps://example.com/.well-known/security.txt. - It must be served over HTTPS.
- It must have the content type
text/plain; charset=utf-8. - For older tools, you may also put a copy at the top-level
/security.txt, or redirect that address to the well-known one. If both exist, the well-known file wins.
The file applies only to the exact host it's served from, not to subdomains or the parent domain (section 3.1). A file on example.com doesn't cover shop.example.com. Publish one on each site, or redirect each site's address to one shared file.
On cPanel and other shared hosting
Open the file manager, go to your site's document root (often public_html), and create a folder called .well-known if it doesn't exist. It may already be there, because certificate tools use it. Create security.txt inside it. Apache and most hosts serve .txt files as plain text automatically.
On a CMS or framework
WordPress, Laravel and similar systems serve files from their public folder, so the same .well-known folder works. Check that no rewrite rule sends the address to a "page not found" page instead. Some platforms, such as hosted shop builders, don't let you add files; in that case, put the details on a security page and ask the platform's support team.
Signing and Canonical
RFC 9116 section 2.3 recommends signing the file with an OpenPGP cleartext signature, so researchers can check it hasn't been changed by someone who broke into your website. If you sign it, also list the file's address in a Canonical line. A signed file with a Canonical line proves where it is meant to live.
Signing is optional, and an unsigned file is far better than none. For most small organisations, a correct unsigned file that is kept up to date is the right choice. If you do sign it, remember to sign it again every time you change the Expires date.
If you include Canonical lines, the address the file is fetched from should be one of them. Section 2.5.2 says a researcher should not trust a file whose own address isn't listed. That matters when you copy one file to several sites: either list every address, or leave Canonical out.
security.txt and your other security settings
security.txt is about what happens after someone finds a problem. Security headers, such as Content-Security-Policy and Strict-Transport-Security, help prevent the problems in the first place. They sit side by side: a site with good headers and a security.txt shows researchers that someone is looking after it. Our guide on security headers explains which ones your site needs.
Have a plan for the reports, too. Someone should read the security address, reply within a few working days, and know who to pass a report to. The NCSC toolkit includes an example disclosure policy you can adapt.
Try it now
Security Header Checker
Check a website's HSTS, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy and Permissions-Policy headers, with plain-English guidance.
Common questions
Is security.txt a legal requirement?
Not in general, although some government bodies and regulated sectors expect a disclosure process. It's a simple, widely recognised way to show you have one.
Will it attract attacks?
No. Attackers don't need an invitation, and the file reveals nothing about your systems. It makes it easier for people who find problems to tell you rather than someone else.
Will I get spam?
Some, often automated reports of low-value issues offered for a reward. A policy that says what you consider in scope, and that you don't pay for reports unless you say so, helps. Use a filtered shared mailbox.
How often should I update it?
Whenever a contact changes, and before the Expires date. Setting Expires about 11 months ahead and adding a calendar reminder a month before works well.
Checklist
- The file is at
/.well-known/security.txton every site you run. - It's served over HTTPS as
text/plain, with a 200 status. - At least one
Contactline, written asmailto:,tel:orhttps://. - Exactly one
Expiresline, in the future and less than a year away. - Canonical lines, if used, include the address the file is served from.
- A calendar reminder to update Expires.
- Someone reads the security mailbox and knows what to do with a report.
Related tools
-
security.txt Checker
Check a website's security.txt: the Contact and Expires fields, the location, HTTPS, redirects and signatures, against RFC 9116.
-
Security Header Checker
Check a website's HSTS, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy and Permissions-Policy headers, with plain-English guidance.
More website guides
-
Website
Redirect chains and loops: fixing http-to-https and www redirects
How redirects work, why chains slow your site and loops break it, and how to send every version of your address to one final address in a single step.
-
Website
Robots.txt and sitemaps: what search engines actually read
What robots.txt and sitemaps really do, the rules search engines follow, why neither keeps a page out of results, and the mistakes that cause the most trouble.
-
Website
Why is my SSL certificate not trusted?
The five common reasons browsers reject a certificate, from a missing intermediate to a wrong clock, and how to fix each one.