shipcra

security.txt: what it is, an example file and how to publish it

Reviewed 2 min read

security.txt is a plain-text file published at /.well-known/security.txt that tells people how to report a security issue to you. RFC 9116 defines it: Contact and Expires are required, and fields such as Policy, Encryption and Preferred-Languages are optional. It takes five minutes to write.

Key facts

Standard
RFC 9116 (April 2022)
Location
https://your-domain/.well-known/security.txt
Required fields
Contact and Expires
Format
Plain text, served over HTTPS as text/plain with UTF-8
Expires
Recommended less than a year in the future

What security.txt is for

When someone finds a vulnerability in your product, the hardest part is often finding who to tell. security.txt solves that with a file at a predictable address that people and scanners know to check. RFC 9116, published in April 2022, standardises the format.

The fields

Field Required What it holds
Contact Yes, at least one A mailto:, https:// or tel: address for reports
Expires Yes, exactly one When the file becomes stale, in ISO 8601 format
Policy No The URL of your vulnerability disclosure policy
Encryption No Where to find a key for encrypted reports
Preferred-Languages No Languages you can handle reports in, such as en, fr
Canonical No The URL where this file is officially published
Acknowledgments No A page thanking past reporters
Hiring No Security job openings

You can repeat Contact to list several channels, in order of preference.

An example file

Contact: mailto:security@example.com
Contact: https://example.com/security/
Expires: 2027-10-31T23:00:00.000Z
Preferred-Languages: en, fr
Canonical: https://example.com/.well-known/security.txt
Policy: https://example.com/security/

That is a complete, valid file. Lines starting with # are comments.

Where to publish it

  • At https://your-domain/.well-known/security.txt. A copy at the root, /security.txt, is allowed for older tools, but the .well-known path is the one to rely on.
  • Over HTTPS, served as text/plain with the UTF-8 charset.
  • On every domain where people interact with your product, including the website your app store listing points to.

On a static site, put the file in the folder that maps to /.well-known/. In Astro, Next.js or Vite projects, that is usually public/.well-known/security.txt.

Optional: sign it

RFC 9116 allows the file to be signed with an OpenPGP cleartext signature, so readers can check it wasn’t altered. If you sign it, re-sign every time you edit it. Most small teams skip this and rely on HTTPS.

Check it after publishing

  • The URL returns the file, over HTTPS, with a text/plain content type.
  • Expires is in the future and less than a year away.
  • Every Contact works: send yourself a test message.
  • Canonical matches the URL the file is served from.
  • The Policy link opens your current disclosure policy.

Put a reminder in your calendar a month before Expires.

security.txt and the Cyber Resilience Act

The CRA doesn’t name security.txt. It does require manufacturers to make it easy to report vulnerabilities, including by providing a contact address (Annex I, Part II, point 6), and to give users a single point of contact for reporting vulnerabilities (Annex II). A security.txt file pointing to your vulnerability disclosure policy is the simplest way to publish that contact where researchers already look.

Questions

Is security.txt mandatory?

Neither RFC 9116 nor the Cyber Resilience Act makes it mandatory. It is the most widely recognised way to publish a security contact, and the CRA does require you to give one.

What does the Expires field mean?

It is the date after which the file should be treated as stale. RFC 9116 recommends a date less than a year ahead, so you review the file at least once a year.

Do I need a security.txt for a mobile app or a game?

Publish it on the website you list as the developer or support site in the app stores. That is where researchers will look for it.

Can I generate a security.txt file?

Yes, the file is only a few lines, so you can write it by hand from the example on this page. shipcra generates one as part of its document pack, pointing to a disclosure page it hosts for you.

Sources

  1. RFC 9116: A File Format to Aid in Security Vulnerability Disclosure
  2. Regulation (EU) 2024/2847, Annex I Part II and Annex II, EUR-Lex

This guide explains the regulation in general terms. It isn’t legal advice for your product.

Draft the paperwork from your answers.

The pack turns your Annex I answers into a gap report, technical documentation and a draft declaration that you review and sign.

Join early access