Skip to content

Audit the public surface for security, SEO and accessibility, and fix what it found - #81

Merged
Flatts3000 merged 4 commits into
mainfrom
audits-2026-08-30
Aug 31, 2026
Merged

Flatts3000 merged 4 commits into
mainfrom
audits-2026-08-30

Conversation

@Flatts3000

@Flatts3000 Flatts3000 commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Three audits in docs/audits/, measured against a running system rather than read off the source: the production build served by the real nginx configs in containers, a live backend, and a seeded database (12 groups, 1 hub).

Twenty findings, nineteen fixed. Then a review of those fixes found eight more, all eight verified and fixed too. Every audit carries a remediation table; the findings themselves are left as written, because the record of what was wrong is the point of an audit.

Closes #79
Closes #80

The three biggest findings

SEC-1 The strict CSP in backend/src/app.ts was served only on /api responses — JSON, which cannot execute a script, load a font or embed a frame. The HTML document, where the group passphrase is derived and help requests are decrypted, had no CSP at all.
A-1 The language switcher never updated <html lang>, so a screen reader read Spanish through an English voice. It landed entirely on the audience docs/problem_brief.md puts at the center of this project, and was invisible to anyone testing in English.
S-1 Every application route told crawlers it was the home page. /security is 828 words that could not rank because it declared itself a duplicate. Partly a regression from #78, so the fix was to finish per-route metadata rather than revert.

The number everyone had been ignoring

Every push printed "28 vulnerabilities, 1 critical" while CI's npm audit returned zero. Both were correct: frontend/package-lock.json was committed once in February 2026 and never touched again, this is a workspaces monorepo, npm ci runs at the root, and backend/ has no lockfile at all. All 28 alerts named that orphan, pinning vitest 1.6.1 and vite 5.4.21 against 4.1.11 and 8.2.2 actually installed. Deleting one file resolves all of them.

The review caught something that would have shipped

The CSP I added blanked the partner deck. /deck is one self-contained file on purpose — inline <script> slide engine, base64 data: webfonts, so it works offline as an attachment. The site-wide policy blocked both, silently and totally: measured at 15 slides, none activated, 63 characters of text. A funder opening relayfunds.org/deck would have got an empty page.

/deck now has its own policy allowing the inline script by hash rather than 'unsafe-inline', plus data: fonts. Measured after: 15 slides, one active, five fonts, 809 characters, zero CSP blocks. deploy/check-nginx-parity.mjs recomputes the hash in CI, so a deck rebuild that changes the script fails the build instead of shipping a blank deck.

The hash must be taken over LF-normalised text — the HTML parser normalises CRLF before hashing, so raw bytes from a Windows checkout give a hash the browser never agrees with. That cost a debugging round and is now written down in the checker.

/help was told it did not exist. The route map omitted it, so the anonymous help broadcast — the one public surface built for someone in a crisis, and not disallowed in robots.txt — was served noindex plus "That page does not exist." The cause was conflating being a real page with being indexable; those are now separate.

Also fixed from review: <html lang> used the detected language rather than the resolved one (a fr-FR browser got English copy under lang="fr-FR"); a dead block class that had quietly stopped the mobile menu links filling the row; a skip link pointing at an id two of its consumers lacked; a parity check that only compared the first CSP; and a broadcast limiter whose 5-minute key rotation inside a 1-hour window made "5 per hour" mean 60.

Everything else fixed

Security — keyed HMAC for the rate-limit key (the old salt came from the clock, and the code is public, so digests were reversible by enumerating a 32-bit space), Permissions-Policy, real 404s for any path with a file extension (no route in App.tsx contains a dot, so the rule needs no route list and cannot drift), and a CI guard comparing six security directives across both nginx configs — a pair that has drifted twice.

SEO — per-route canonical and og:url, trailing-slash normalisation, Organization JSON-LD (SoftwareApplication deliberately omitted: the audience research is explicit that pitching this as SaaS misreads the people it depends on), a home title longer than five characters, llms.txt generated from the same page list, and a sitemap lastmod that no longer claims every page changed today on every build.

/directory CLS 0.178 → 0.0154. 0.149 of it was one event: the footer displaced when results replaced a centred spinner. Skeleton cards in the real grid now hold the space, and announce themselves, which the spinner never did.

Accessibility — /login landmark, skip link on every route, 44px tap targets, and the contrast failure on the IS/KEPT chips (3.59:1 against a 4.5:1 requirement, on the label distinguishing what Relay is from what it is not).

Verification

  • axe: zero violations across 11 pages × 2 viewports, where the first run had 10 failing nodes.
  • Zero third-party hosts on any page; all four Inter weights load from origin.
  • <html lang> consistent with rendered copy across fr-FR, es-MX and en-US.
  • CSP verified in a container: present on / and /deck/, no violations, /directory still renders seeded data, and the home page's fetch to formspree.io still permitted — a naive connect-src 'self' would have broken the contact form silently.
  • All three drift guards tamper-tested: a figure changed to 188, a share card deleted, the CSP removed from one config and changed in one config, and the deck's inline script edited.
  • Typecheck, lint, 191 tests, nginx syntax, and both builds pass.

Not fixed, deliberately

S-8, one share card for every application route. LOW, and the single card already beats the nothing that preceded it.

Not covered

No penetration testing, no screen-reader testing with an actual screen reader, and no audit of the signed-in application. The anonymous broadcast submission flow was not exercised end to end and is the highest-consequence path in the product; it should be next. The client-side cryptography was not re-reviewed — that is still #14.

🤖 Generated with Claude Code

https://claude.ai/code/session_017DSai3M3GxBuphu7TykTu5

Three audits in docs/audits/, measured against a running system rather than read
off the source: the production build served by the real nginx configs in
containers, a live backend, and a seeded database of 12 groups and 1 hub.

Twenty findings. Four were mine, introduced by #78, and are fixed here. The rest
are documented with remediation and left for their own changes.

## The three that matter most

**No Content Security Policy reaches the browser.** backend/src/app.ts configures
helmet with a genuinely strict policy and it works - on /api responses, which are
JSON and cannot execute a script, load a font or embed a frame. The HTML document
is served by nginx behind Caddy, and neither sets a CSP at all. The surface that
can run script has no policy; the surface that cannot has a strict one. That
matters here specifically because the group passphrase is derived and help
requests are decrypted in that document.

**The language switcher never updates <html lang>.** Switching to Spanish takes
the heading from "Mutual aid, connected." to "Ayuda mutua, conectada." with lang
still "en", so a screen reader reads Spanish through an English voice. It lands
entirely on the Spanish-speaking audience the problem brief puts at the center of
this project, and is invisible to anyone testing in English.

**Every application route tells crawlers it is the home page.** #78 added Open
Graph tags to the one SPA template with a hardcoded og:url, so /directory,
/login, /privacy, /security and /terms each serve og:url of "/". All six share
one description and none has a canonical. /security is 828 words that cannot rank
because it declares itself a duplicate. Partly a regression from #78; the fix is
to finish per-route metadata rather than revert.

## The finding that explains a number everyone has been ignoring

Every push prints "28 vulnerabilities, 1 critical" while CI's own npm audit
returns zero at every severity. Both are right. frontend/package-lock.json was
committed once in February 2026 and never touched again; this is a workspaces
monorepo, npm ci runs at the root, and backend has no lockfile at all. All 28
alerts name that orphan. It pins vitest 1.6.1 and vite 5.4.21 against 4.1.11 and
8.2.2 actually installed, so every alert, including the critical, describes a
version that cannot be installed. Deleting one file resolves all of them.

Rated MEDIUM for what it does to the channel rather than for the alerts: a
repository permanently showing a critical count teaches everyone the number means
nothing, and the real alert arrives into that habit.

## Fixed here, because they were mine

Contrast on the IS/KEPT chips was 3.59:1 against a 4.5:1 requirement - the label
distinguishing what Relay is from what it is not, and on /need-help/ what is kept
from what is never kept. Moved to teal-700, an existing token, at 5.25:1.

The masthead was a div, so the logo link belonged to no landmark; it is a header
with a labelled nav now. Nav tap targets 38px to 44px, footer links 23px to 44px,
the latter below even the 24px AA floor.

The sitemap stamped today's date into every lastmod on every build, which is a
false signal and a diff in every commit. Now taken from each page's last commit,
and verified idempotent across two builds.

All four pages now report zero axe violations at 1280x900 and 390x760.

## Method notes worth keeping

The first accessibility run pointed everything at the dev server, where vite's
SPA fallback returns index.html for /what-is-relay/ and friends. It measured the
React app four times and reported it as the marketing pages. Static pages have to
be audited through nginx.

Core Web Vitals were re-measured against the production build with a live API
after the dev-server numbers proved unrepresentative - 13 MB and 134 requests of
unbundled modules versus 186 KB and 6 requests. /directory's CLS of 0.178 held on
both, and the dominant 0.149 of it is the footer being displaced when results
arrive.

deploy/relay-prod.pem is an SSH private key, correctly gitignored, with zero
commits across all history. Not an exposure; recorded so nobody has to check
again.

Typecheck, lint, 191 tests, both count guards and the frontend build all pass.
Nineteen of twenty. S-8, one share card for every application route, is left
alone deliberately: it is LOW, the single card is already better than the nothing
that preceded it, and the finding says so.

Each audit now carries a remediation table saying what happened to each finding.
The findings themselves are left as written - the record of what was wrong is the
point of an audit.

## Security

The strict CSP helmet builds only ever reached /api responses, which are JSON and
cannot execute a script, load a font or embed a frame. It is now set on the HTML
in both nginx configs, at server level and repeated inside location ^~ /deck,
because an add_header in a location drops every inherited one. connect-src allows
formspree.io: the home page's contact form posts there with fetch, and without it
the form fails silently, which is how a CSP breaks a site. Verified in a
container - present on / and /deck/, zero violations across four pages, formspree
still permitted, and the directory still renders seeded data.

The anonymous rate-limit key is a keyed HMAC now. The old salt came from the
clock and the code is public, so the digests were reversible by enumerating a
32-bit space. The risk was low - memory only, minutes long, never persisted - but
the comment above it said "we NEVER store the raw IP address", which read as a
far stronger guarantee than it delivered. The key is 32 random bytes generated at
boot and written nowhere.

frontend/package-lock.json is deleted. It was committed once in February 2026,
governed nothing, and produced all 28 open Dependabot alerts including the
critical one, every alert naming a version that npm ci cannot install.

Permissions-Policy set alongside the CSP.

Nothing returns 200 any more if it asks for a file and is not one. No route in
App.tsx contains a dot, so a path with an extension is never an app route; that
needs no route list and so cannot drift. Extensionless typos still reach the app,
and the not-found view carries a noindex now.

deploy/check-nginx-parity.mjs compares six security directives and the CSP value
across both configs, and CI runs it. The pair has drifted twice - f01ac7e and the
review of #78 - and nothing was checking. Verified by tampering both ways:
removing the CSP from one file, and changing it in one file.

## SEO

Every application route told crawlers its canonical identity was the home page,
because index.html is one template with a hardcoded og:url. DocumentTitle now
sets canonical, og:url, og:title, og:description and the Twitter pair per route.
/security is 828 words that could not rank because it declared itself a
duplicate.

Trailing slashes are normalised, so /directory and /directory/ agree. The
description lookup uses the normalised path too - keying it off the raw one would
have given /directory/ a noindex while /directory got a description, which is the
same duplicate handled two opposite ways.

/directory shifted 0.178 of layout against a 0.1 budget, and 0.149 of that was
one event: the footer being displaced when results replaced a centred spinner.
Skeleton cards in the real grid now hold the space. 0.178 -> 0.0154. The skeleton
also announces itself, which the spinner never did.

Organization JSON-LD, static so a crawler sees it without running JavaScript.
SoftwareApplication deliberately omitted - Relay is not a product being sold, and
the audience research is explicit that pitching it as SaaS misreads the people it
depends on.

The home page title was five characters. llms.txt exists, generated from the same
PAGES list so it cannot describe a page set that no longer exists, and it leads
with the fact that no pilot has run.

## Accessibility

<html lang> never followed the switcher, so a screen reader read Spanish through
an English voice. It lands only on the audience this project exists to serve,
which is why it survived. Verified: en-US -> es while the heading becomes "Ayuda
mutua, conectada."

The skip link existed on one route of six and now lives in PublicHeader, with
each main given the id it targets. /login has none on purpose: it renders no
repeated navigation block, so there is nothing to bypass. It does have a main
landmark now, on both return paths including the loading state.

Header navigation and the masthead logo link reach 44px. A-5's original wording
blamed a missing label; it is the logo, named by its image alt, and only the
height was wrong. Corrected in place rather than quietly.

Re-verified after all of it: zero axe violations across ten pages at two
viewports, where the first run had ten failing nodes.

## Also

#80 and #79 are both closed by this. The app self-hosts Inter, including the 500
weight that 45 components use, and makes no third-party requests at all - the
faces were already being fetched for the marketing pages. The icon points at a
file that exists.

Typecheck, lint, 191 tests, all three drift guards, nginx syntax, and both builds
pass.
All eight verified against a running system before being fixed; none was a false
positive. The first would have shipped.

## The CSP I added blanked the partner deck

/deck is one self-contained file on purpose: its slide engine is an inline
<script> and its webfonts are base64 data: URIs, so it works offline as an email
attachment. The site-wide policy blocked both, and the failure was silent and
total. Measured before the fix: 15 slides, none activated, nothing visible, 63
characters of text. A funder opening relayfunds.org/deck would have got the
chrome bar and an empty page.

/deck now carries its own policy: the inline script by hash rather than
'unsafe-inline', and data: added to font-src. Measured after: 15 slides, one
active, five fonts loaded, 809 characters, zero CSP blocks.

The hash has to be taken over LF-normalised text. The HTML parser normalises
CRLF to LF before hashing, so the raw bytes of a Windows checkout produce a hash
the browser will never agree with - which is exactly what happened on the first
attempt, and cost a debugging round. check-nginx-parity.mjs recomputes the hash
in CI, so a deck rebuild that changes the script now fails the build rather than
shipping a blank deck. Verified by tampering with the deck's script.

## /help was told it did not exist

publicDescriptions omitted /help, which routes to BroadcastSubmitPage - the
anonymous help broadcast, the one public surface built for someone in a crisis,
and not disallowed in robots.txt. It was being served noindex plus the
description "That page does not exist."

The cause was conflating two questions. Being a real page and being indexable
are different, and the map answered only one. There is now a description map
covering every real page including /help and /login, and a separate noindex set
containing /login alone. meta.login had been added and never referenced, which
was the same omission showing up twice.

## The rest

<html lang> came from i18n.language, which is the detected language, not the
rendered one. With no supportedLngs in the config, a first-time visitor on a
fr-FR browser got English copy from fallbackLng under lang="fr-FR" - a 3.1.1
failure the hardcoded "en" did not have. resolvedLanguage walks the fallback
chain. Verified across three browser locales: fr-FR now reports en with English
copy, es-MX reports es with Spanish copy.

`block ${linkClass(...)}` stopped producing a block when linkClass gained a
leading inline-flex, because Tailwind precedence is stylesheet order and
.inline-flex sits after .block in the built CSS. The mobile menu links had
quietly stopped filling the row, shrinking the tap targets this change was
widening. Now w-full: all four measure 358px.

The skip link I added to PublicHeader pointed at an id that two of its consumers
did not have - the not-found view and BroadcastSubmitPage - so on /help it went
nowhere, which is the defect A-3 was raised to fix. Both have the id now, and
every PublicHeader consumer was checked rather than the four I remembered.

The parity checker compared only the first CSP in each file, which is the
server-level one. The location-level /deck copy is precisely the one that rots,
since a location add_header discards every inherited header. It compares all of
them now.

broadcastCreationRateLimiter runs a one-hour window against a key that rotated
every five minutes, so one client got twelve fresh budgets and "5 broadcasts per
hour" was really 60. Pre-existing, but my comment restated the claim, and the
comment above anonymousKeyGenerator already names this exact hazard for IPv6
prefixes. The bucket matches the window now.

Re-verified after all of it: zero axe violations across eleven pages at two
viewports, the deck rendering, and typecheck, lint, 191 tests, all three drift
guards, nginx syntax and both builds passing.
@Flatts3000 Flatts3000 changed the title Audit the public surface for security, SEO and accessibility Audit the public surface for security, SEO and accessibility, and fix what it found Aug 31, 2026
Comment thread deploy/check-nginx-parity.mjs Fixed
CodeQL flagged js/bad-tag-filter on the new check: the tag pattern was a
lower-case literal that would not match <SCRIPT>. On its own that is a nag,
because the file it parses is one this repository generates.

The consequence here is worse than the usual one, and the tamper test proved it.
The block reads `if (inline) { ...verify the hash... }`, so a pattern that stops
matching does not fail - it skips. Editing the committed deck's tag to <SCRIPT >
made the check pass while the deck's script had changed underneath it, which is
precisely the "guard quietly stops guarding" failure the guard was written to
prevent.

The pattern is case-insensitive and tolerates attributes now, and it excludes a
tag carrying src so an external script is not mistaken for the inline one. More
importantly, finding no inline script is a reported problem rather than a silent
skip: the deck's slide engine is inline by design, and if that ever stops being
true the /deck policy needs revisiting rather than passing unexamined.

Re-tampered with the same uppercase edit: the check now names the mismatch.
@Flatts3000
Flatts3000 merged commit ffe8416 into main Aug 31, 2026
12 checks passed
@Flatts3000
Flatts3000 deleted the audits-2026-08-30 branch August 31, 2026 02:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants