Skip to main content
WebTools

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

Illustration of a website window with a small text file rising from a hidden folder, beside a shield with an envelope and a magnifying glass.
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
Diagram of an example security.txt file with Contact, Expires, Preferred-Languages, Canonical and Policy lines. Labels say Contact is required at least once, Expires is required exactly once and should be under a year away, and the other fields are o
The two required fields and the optional ones.
FieldRequired?What it holds
ContactYes, at least onceAn email address (mailto:), phone number (tel:) or https:// web page. List several in order of preference.
ExpiresYes, exactly onceThe date and time the file stops being valid, in a format such as 2027-09-30T23:00:00.000Z.
PolicyNoA link to your vulnerability disclosure policy.
EncryptionNoA link to a public key researchers can use to encrypt their report.
CanonicalNoThe address or addresses where this file is meant to live.
Preferred-LanguagesNoLanguages you can read reports in, such as en.
AcknowledgmentsNoA page thanking researchers who reported problems.
HiringNoSecurity 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.

Open the tool: security.txt Checker

Where and how to publish it

Section 3 of RFC 9116 sets the rules:

  • The file must be at /.well-known/security.txt, for example https://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.

Open the tool: Security Header Checker

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.txt on every site you run.
  • It's served over HTTPS as text/plain, with a 200 status.
  • At least one Contact line, written as mailto:, tel: or https://.
  • Exactly one Expires line, 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.
  • 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.