WordPress security.txt: publish a security contact without a file
To publish a security.txt contact on a WordPress site, open BetterShield › Settings › General, find the security contact card under Privacy & sharing, enter a Contact and turn on Publish a security contact. BetterShield then answers / with your contact and an expiry date, and it writes no file to your server. This guide covers what goes in it, what it can and cannot do, how to renew it and how to take it down.
The file is a small piece of the site’s public face, so it sits naturally beside the server-level changes in WordPress hardening. Where that guide covers what the site hides, this post covers the one setting that says where to send a report, and it pairs with hiding sensitive files in WordPress, which keeps leftover files out of view.
Quick summary
- Publish a security contact is off until you turn it on. It serves
/from your settings, as plain text, and writes no file to disk..well- known/ security.txt - Contact takes an email address or an https page with a form. The optional Disclosure policy page takes an https address.
- The file carries an expiry date, set a year out when you turn it on. A finding appears 30 days before it lapses, and Renew for a Year extends it.
- It works on any hosting, nginx included, because WordPress answers the request itself.
- Turning the switch off removes it completely, and the change can be put back from settings history.
Why publish a security contact
A person who notices a problem on your site has to decide where to tell you. If your site says nothing, they guess at an address, use a contact form that may go nowhere, or give up. A published contact turns that guess into a known place to write.
RFC 9116 defines the standard way to say it: a plain text file at /, with a contact, an expiry date and a few optional lines. Nothing about the file protects your site by itself. It is a courtesy to the people who may write to you, and a way to be reachable on your own terms.
What BetterShield publishes
BetterShield builds the file when someone asks for it, from the values you saved. Nothing is stored on your server as a file, so there is nothing to edit by hand, nothing to remove on uninstall, and no drift between the file and the settings behind it. A request for / gets plain text with these lines:
| Line | Where it comes from |
|---|---|
| Contact | The Contact you entered. A bare email address is served as a mailto: address, and an https page is served as you wrote it. |
| Expires | A date a year after you turned the setting on, or after you last renewed it. |
| Policy | The Disclosure policy page (optional), when you add one. |
| Canonical | Your site’s own / address, so a copy pasted onto another host can be told apart. |
| Preferred-Languages | Your site’s language, when it is a plain language tag. |
While the switch is off, the address answers as it always did and nothing is served. BetterShield never answers with an empty file, because a contact policy with no contact in it is worse than none.
Set it up
- Open BetterShield › Settings › General and find the security contact card under Privacy & sharing.
- Enter a Contact: an email address, or an https page with a form. We recommend a shared mailbox that more than one person reads, or a maintained form, rather than one person’s inbox.
- Optionally add a Disclosure policy page (optional): an https page that says how you handle reports. Keep it public.
- Leave each field to save it. A field that is not a complete address tells you why.
- Turn on Publish a security contact.
A contact that starts with http:// is refused with “A security contact needs https, or anyone on the network can read the report.” A telephone contact is accepted in the form tel:+15551234567.
BetterShield does not read or send mail itself, so it does not check that the mailbox works. Send a test message to the address before you publish it.
What it does not do
It is worth being plain about the limits:
- It does not protect the site. It names a way to reach you. It scans nothing and blocks nothing.
- It does not promise a reply. Reporters will expect one, so name someone who will read the mailbox, and decide your answer in advance.
- It does not publish your policy. The optional page is only a link to a page you wrote yourself.
When WordPress is in a subfolder
The standard puts the file at the root of the domain. When WordPress is installed in a subfolder, a request to the domain’s root never reaches WordPress, so BetterShield cannot answer it. It serves the file at the address under your install, and the card says where each one is. To publish it at the root, copy it there with your host’s file manager.
Renew it once a year
The file carries an expiry date because the standard requires one. It tells finders that the contact is current, and an outdated contact leaves a reporter with no way to reach you.
| When | What BetterShield does |
|---|---|
| You turn it on | Sets the expiry a year out |
| 30 days before it lapses | Opens the finding Your security contact file (security.txt) expires soon (Low) |
| After it has passed | Changes it to Your security contact file (security.txt) has expired (Medium) |
| You press Renew for a Year | Moves the expiry a year on |
Press Renew for a Year when the finding opens, and confirm the contact still works while you are there. How findings count toward your score is covered in what the security score measures, and scheduled audits look for them on a schedule.
What it can break, and how to undo
The one thing this setting can get wrong is sending a report to the wrong place. If the mailbox is closed or the form is gone, a finder trusts the contact and gets nowhere. Correct the field, or turn the switch off.
- Turn it off with Publish a security contact. The file stops being served, and the address answers as if it had never been published.
- Put it back from settings history. Saves to the security contact are among the changes BetterShield records, and the guide to putting a settings change back explains how to restore the value a save replaced.
- Check the activity log. Turning it on records “Security contact file (security.txt) published”, and turning it off records “Disclosure contact withdrawn”.
If you copied the file to the domain root from a subfolder install, remove that copy yourself when you turn the setting off.
Check it is working
- In a private window, open
/on your site. You should see your contact, an expiry date in the future and, if you added one, your policy page..well- known/ security.txt - Check the Canonical line is your own address.
- Open the activity log and confirm the entry for publishing it.
- Look at the security contact card. It shows the expiry date and, when the date is close, Renew for a Year.
BetterShield Hub also shows whether a connected site publishes a security contact and, when available, its expiry, so you can check several sites in one place.
Recommended settings
We recommend turning it on for any site that people other than you rely on, with a monitored shared mailbox or a maintained form as the Contact. Add a Disclosure policy page (optional) only when you have written one. Put the renewal in your calendar for a month before the expiry, and renew it when the finding opens. On an agency or team site, record who reads that mailbox, the same way you record who answers a support request.
If you move a site’s settings to another site, the security contact travels in the settings file, so check the contact and the expiry on the new one. The guide on moving settings between sites lists what the file carries.
Frequently asked questions
Does BetterShield write a security.txt file to my server?
No. BetterShield assembles the file from your settings when it is requested and writes nothing to disk. Turning the setting off stops it completely.
Does it work on nginx?
Yes. It works on any hosting, because WordPress answers the request itself and no server rule is involved. That makes it different from the hardening fixes that write to .htaccess.
What happens when the expiry date passes?
BetterShield opens a finding 30 days before, and a Medium finding once it has passed. Press Renew for a Year to move the date a year on.
Can I use a contact form instead of an email address?
Yes. Contact accepts an email address or an https page with a form. A bare email address is served as a mailto: address.
Is the security contact part of the free plugin?
Yes. It is part of the free BetterShield plugin on WordPress.org.
Conclusion
A security contact tells finders where to send a report and when the answer was last checked. Open BetterShield › Settings › General, enter a monitored Contact, turn on Publish a security contact and renew it when the finding asks.
BetterShield is free on WordPress.org. The reference page is Publish a security contact, and the other server-side choices are in Hide sensitive files.