Answer at /.well-known/security.txt
This one looked like it already worked. The path returned HTTP 200, so an estate-wide check that only reads status codes counts it as present. What it returned was the SPA shell: the catch-all answers any non-/api path with index.html, so the file a researcher or a scanner looks for was a page of HTML. A 404 would have been more honest. SECURITY.md was no better. It told a reporter to "email the project maintainers at the address on the GitLab project page", which is not an address. It now names security@caelum.network, which was created as an alias and confirmed to answer 250 in an SMTP conversation from off the mail server. The route is registered before the SPA block so the catch-all cannot swallow it, and Expires is computed per request: RFC 9116 makes it mandatory and tells consumers to disregard a file that has passed it, so a hardcoded date is a promise to come back and edit it in a year. Policy points at SECURITY.md, which is publicly readable. Verified on a real request: 200, text/plain; charset=utf-8. The production container sets no PUBLIC_BASE_URL, so the canonical falls back to https://caelum.network, which is correct. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
5c9b8c2f7f
commit
5af2865a80
+3
-1
@@ -8,7 +8,9 @@ Caelum is pre-1.0. Only the `main` branch receives security fixes.
|
||||
|
||||
**Do not** open a public issue for a security vulnerability.
|
||||
|
||||
Email the project maintainers at the address on the GitLab project page. Include:
|
||||
Email **security@caelum.network**, which is also published at
|
||||
[`/.well-known/security.txt`](https://caelum.network/.well-known/security.txt).
|
||||
Include:
|
||||
|
||||
- A description of the issue.
|
||||
- Steps to reproduce, or a proof-of-concept if you have one.
|
||||
|
||||
@@ -52,6 +52,7 @@ import reductionWorkerRoutes from './routes/reduction-worker.js';
|
||||
import { setIo as setNotifyIo } from './services/notifications.js';
|
||||
import { startPublicFeed } from './services/public-feed.js';
|
||||
import { startHealthHistory, getRecentHistory } from './services/health-history.js';
|
||||
import { securityTxt } from './services/security-txt.js';
|
||||
import { startWeatherSim } from './services/weather-sim.js';
|
||||
import { startWeatherStationPolling } from './services/external-drivers.js';
|
||||
import { startLifecycle } from './services/lifecycle.js';
|
||||
@@ -261,6 +262,17 @@ app.get('/api/health', async (req, res) => {
|
||||
// Legacy observatory routes redirect to sites
|
||||
app.get('/api/observatories', (req, res) => res.redirect(307, '/api/sites'));
|
||||
|
||||
// RFC 9116. Registered before the SPA block: the catch-all answers any
|
||||
// non-/api path with index.html, so without this the path a researcher checks
|
||||
// returns 200 and a page of HTML, which reads as "there is a file here" to
|
||||
// anything that only looks at the status code.
|
||||
app.get('/.well-known/security.txt', (req, res) => {
|
||||
const base = (process.env.PUBLIC_BASE_URL || 'https://caelum.network').replace(/\/$/, '');
|
||||
res.type('text/plain; charset=utf-8');
|
||||
res.set('Cache-Control', 'public, max-age=86400');
|
||||
res.send(securityTxt(new Date(), base));
|
||||
});
|
||||
|
||||
// Serve the built Vue SPA when present (production / single-zip deploys).
|
||||
// In dev, vite serves the client on its own port and proxies /api here.
|
||||
const __srcDir = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* The contents of /.well-known/security.txt (RFC 9116).
|
||||
*
|
||||
* SECURITY.md told a reporter to "email the project maintainers at the address
|
||||
* on the GitLab project page", which is not an address, and the path a
|
||||
* researcher or a scanner actually checks first returned the SPA shell: HTTP
|
||||
* 200 with a page of HTML, which reads as "there is a file here" to anything
|
||||
* that only looks at the status code.
|
||||
*
|
||||
* WHY THE EXPIRY IS COMPUTED RATHER THAN WRITTEN DOWN. RFC 9116 makes
|
||||
* `Expires` mandatory and tells consumers to disregard a file that has passed
|
||||
* it. A date typed into a static file is a promise to come back and edit it in
|
||||
* a year, and nobody ever does; the file then reads as abandoned, which is
|
||||
* worse than absent, because it suggests the contact is stale when it is not.
|
||||
*/
|
||||
|
||||
export const SECURITY_CONTACT = 'security@caelum.network';
|
||||
|
||||
/** RFC 9116 says an expiry should be less than a year out. */
|
||||
const YEAR_MS = 365 * 24 * 60 * 60 * 1000;
|
||||
|
||||
export function securityTxt(now, siteUrl) {
|
||||
const base = String(siteUrl).replace(/\/$/, '');
|
||||
const expires = new Date(now.getTime() + YEAR_MS).toISOString().replace(/\.\d{3}Z$/, 'Z');
|
||||
return [
|
||||
'# Caelum',
|
||||
'#',
|
||||
'# Report a vulnerability to the address below rather than opening a',
|
||||
'# public issue. Please give us a reasonable opportunity to fix it before',
|
||||
'# disclosing it publicly. You will get an acknowledgement within 72',
|
||||
'# hours; see the policy for scope and timelines.',
|
||||
'',
|
||||
`Contact: mailto:${SECURITY_CONTACT}`,
|
||||
`Expires: ${expires}`,
|
||||
'Preferred-Languages: en',
|
||||
`Canonical: ${base}/.well-known/security.txt`,
|
||||
'Policy: https://gitlab.com/paulhitt/caelum/-/blob/main/SECURITY.md',
|
||||
'',
|
||||
].join('\n');
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
// /.well-known/security.txt is where a researcher or a scanner looks first.
|
||||
//
|
||||
// Caelum's SPA catch-all answers any non-/api path with index.html, so that
|
||||
// path returned 200 and a page of HTML: to anything checking only the status
|
||||
// code, the file appeared to exist. SECURITY.md meanwhile pointed reporters at
|
||||
// "the address on the GitLab project page", which is not an address.
|
||||
//
|
||||
// RFC 9116 gives the file rules worth pinning: Expires is mandatory, consumers
|
||||
// are told to disregard a file that has passed it, and the date should be
|
||||
// under a year out.
|
||||
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { securityTxt, SECURITY_CONTACT } from '../src/services/security-txt.js';
|
||||
|
||||
const SITE = 'https://caelum.network';
|
||||
const at = (iso) => securityTxt(new Date(iso), SITE);
|
||||
const field = (text, name) =>
|
||||
text.split('\n').filter(l => l.startsWith(name + ':')).map(l => l.slice(name.length + 1).trim());
|
||||
|
||||
const txt = at('2026-09-15T20:00:00.000Z');
|
||||
|
||||
test('names a contact, and it is an address rather than a pointer to one', () => {
|
||||
assert.deepEqual(field(txt, 'Contact'), ['mailto:' + SECURITY_CONTACT]);
|
||||
assert.match(SECURITY_CONTACT, /^[^@\s]+@[^@\s]+\.[a-z]{2,}$/);
|
||||
});
|
||||
|
||||
test('carries exactly one Expires, which RFC 9116 requires', () => {
|
||||
assert.equal(field(txt, 'Expires').length, 1);
|
||||
});
|
||||
|
||||
test('expires in the future but less than a year out, wherever the clock is', () => {
|
||||
for (const iso of ['2026-09-15T20:00:00.000Z', '2028-06-01T00:00:00.000Z', '2034-12-31T23:00:00.000Z']) {
|
||||
const now = new Date(iso).getTime();
|
||||
const expires = new Date(field(at(iso), 'Expires')[0]).getTime();
|
||||
assert.ok(expires > now, `${iso}: expiry is not in the future`);
|
||||
assert.ok(expires - now <= 366 * 24 * 60 * 60 * 1000, `${iso}: expiry is more than a year out`);
|
||||
}
|
||||
});
|
||||
|
||||
test('the expiry is a timestamp a parser will accept', () => {
|
||||
const raw = field(txt, 'Expires')[0];
|
||||
assert.match(raw, /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/);
|
||||
assert.ok(!Number.isNaN(Date.parse(raw)));
|
||||
});
|
||||
|
||||
test('the canonical and policy URLs are absolute', () => {
|
||||
assert.deepEqual(field(txt, 'Canonical'), [SITE + '/.well-known/security.txt']);
|
||||
for (const url of field(txt, 'Policy')) assert.match(url, /^https:\/\//);
|
||||
});
|
||||
|
||||
test('a trailing slash on the base URL does not produce a doubled path', () => {
|
||||
assert.deepEqual(field(securityTxt(new Date(), SITE + '/'), 'Canonical'),
|
||||
[SITE + '/.well-known/security.txt']);
|
||||
});
|
||||
|
||||
test('every non-comment, non-blank line is a field, so no prose leaks in', () => {
|
||||
const lines = txt.split('\n').filter(l => l.trim() && !l.startsWith('#'));
|
||||
assert.ok(lines.length > 3);
|
||||
for (const line of lines) assert.match(line, /^[A-Za-z-]+: \S/);
|
||||
});
|
||||
Reference in New Issue
Block a user