Home

Published

- 1 min read

Deploy security.txt on Kubernetes

Hero image

Photo by Reymark Cabil on Unsplash


Basic concept

IANA (Internet Assigned Numbers Authority) defines a list of well known HTTP paths that are prefixed by
/.well-known/. One of these is the security.txt - a structured textfile that allows security researchers and anyone else with a security relevant message to reach the appropriate contact without delays.

Let’s look at an example:

Contact: mailto:security-department@example.com
Expires: 2026-12-23T18:57:11Z
Preferred-Languages: en, de
Canonical: https://example.com/.well-known/security.txt

While the file itself is pretty simple, deploying it on Kubernetes requires quite a bit of pipework:

  • A webserver to serve it
  • An Ingress or HTTPRoute to route it
  • Some mechanism to update the mandatory expiration date

Deployment

To easily deploy the security.txt and other well known files, I created a simple helm chart. To deploy the example above using GatewayAPI, all we need is:

cat > values.yaml <<EOF
files:
  - content: |
      Contact: mailto:security-department@example.com
      Expires: {{ now | date_modify "+720h" | date "2006-01-02T15:04:05Z07:00" }}
      Preferred-Languages: en, de
      Canonical: https://{{ .Host }}/.well-known/security.txt
    paths:
      - path: /.well-known/security.txt
        hosts:
          - example.com
httpRoute:
  enabled: true
  parentRefs:
    - name: http
      hostnames:
        - example.com
EOF
helm upgrade -i -n default well-known oci://registry.minding.blog/well-known/well-known -f values.yaml

Here the content is always valid for 30 days from the time it was requested. Of course this can be expanded to other domains and files (even without the /.well-known/ prefix!).

Further reading