Skip to content

Commit 8df9c96

Browse files
committed
Add HTML redirect method
1 parent e3a2cb8 commit 8df9c96

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

003-html-redirect/README.md

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
11
# 003-html-redirect
22

3-
TBC
3+
The least-recommended option for a security.txt redirect is using a HTML based redirect; however, with some content management systems this may be unavoidable.
4+
5+
## index.html and meta tag
6+
7+
Placing the following HTML in an `index.html` file ([copy here](index.html)) in the `/.well-known/security.txt/` directory works for a large majority of CMS and static site systems, including GitHub Pages.
8+
9+
``` html
10+
<!-- /.well-known/security.txt/index.html -->
11+
<!DOCTYPE html>
12+
<html>
13+
<head>
14+
<meta http-equiv="refresh" content="0; https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt" />
15+
</head>
16+
<body>
17+
<p><a href="https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt">https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt</a></p>
18+
<script>
19+
window.location.replace("https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt");
20+
</script>
21+
</body>
22+
</html>
23+
```
24+
25+
## security.txt HTML content-type
26+
27+
In some platforms, you may be able to configure the `security.txt` file with a `text/html` content-type (as opposed to the default of `txt/plain`).
28+
29+
For example, these commands for S3 will configure an appropriate "security.txt" file:
30+
31+
``` bash
32+
# download the index.html file as "security.txt" (actually html)
33+
curl https://raw.githubusercontent.com/co-cddo/implement-security.txt/main/003-html-redirect/index.html \
34+
-o security.txt
35+
36+
# pwsh equivalent
37+
# Invoke-WebRequest -Uri "https://raw.githubusercontent.com/co-cddo/implement-security.txt/main/003-html-redirect/index.html" -OutFile "security.txt"
38+
39+
# cp the security.txt to S3 but with the content-type of "text/html"
40+
aws s3 cp security.txt s3://BUCKET/.well-known/security.txt \
41+
--acl public-read \
42+
--cache-control "public, max-age=604800" \
43+
--content-type "text/html"
44+
```
45+
46+
_Note: ideally use [origin access controls](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html#create-oac-overview) and not an ACL of "public-read" but for an open, simple, and static site public access to an S3 bucket is likely fine._

003-html-redirect/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="refresh" content="0; https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt" />
5+
</head>
6+
<body>
7+
<p><a href="https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt">https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt</a></p>
8+
<script>
9+
window.location.replace("https://vulnerability-reporting.service.security.gov.uk/.well-known/security.txt");
10+
</script>
11+
</body>
12+
</html>

0 commit comments

Comments
 (0)