The problem
Security reviews tend to find the same frontend issues: a Content Security Policy that allows everything, session tokens readable by any script on the page, a dependency with a known vulnerability, an API key committed to the repository. None of these is hard to fix. They are hard to keep fixed, because nothing stops the next change from bringing them back.
Frontends now carry more risk than they used to. They hold session state, call many services directly, and pull in hundreds of packages. One compromised package or injected script can read everything the user sees and types.
The usual response is a review before launch and another after an incident. That finds problems once, then the codebase drifts again.
What we put in the spec
Security starts in the spec as a short threat model and a baseline in the constitution. Both are concrete enough to test.
Threat model
For each feature that handles sessions, personal data or payments, the spec lists what an attacker could want, how they could try, and which control stops it. It is short and specific. It is not a generic list.
The security baseline
| Area | Rule in the spec |
|---|---|
| Content Security Policy | default-src 'self'; scripts by hash or nonce only; every other origin listed with a reason |
| Sessions | Tokens in HttpOnly, Secure, SameSite cookies, never in localStorage; idle and absolute timeouts stated |
| Headers | HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, frame protection |
| Dependencies | Lockfile required; new packages reviewed for size, maintenance and network or storage behaviour |
| Secrets | No secrets in client code or the repository; public keys documented as public |
| Third-party scripts | Only those in the inventory; integrity hashes where the provider supports them |
| Forms and input | Output encoding by default; no raw HTML from users or APIs without sanitising |
Each rule becomes an acceptance criterion:
Feature: Session tokens out of reach of scripts
Scenario: A user signs in
Given a user with valid credentials
When they sign in
Then the session token is set as an HttpOnly, Secure, SameSite cookie
And no token or refresh token is written to localStorage or sessionStorage
And the session ends after the idle timeout stated in the constitution
How it is checked before release
Every control in the baseline has an automated check. Controls without a check are listed for senior review, so nothing depends on memory.
- Header and CSP tests: each build is served locally and its response headers are compared with the baseline. A weakened CSP fails the build.
- CSP violation tests: end-to-end tests run with CSP reporting on and fail on any violation.
- Session tests: tests confirm where tokens live, that timeouts apply, and that sign-out clears state.
- Dependency audit: known-vulnerability scanning on every pull request, plus review of every new package.
- Secret scanning: on every commit and in the history when we join a project.
These run as part of our quality gates, alongside the privacy checks. A senior engineer reviews every change.
What changes for you
Security findings stop coming back. A control that is in the spec and in CI stays in place, because a change that removes it doesn’t merge. Security reviews get faster, because the evidence is in the trace report: headers, CSP, dependency results and session behaviour, for every release.
Your team also gets a threat model it can read and extend, instead of a one-off report.
What you receive
| Deliverable | Format |
|---|---|
| Threat model per sensitive feature | In the spec |
| Security baseline | In the constitution |
| CSP and header configuration | In your repository |
| Header, CSP and session test suites | In your CI |
| Dependency and secret scanning | In your CI |
| Security results per release | In each trace report |
Common findings and what replaces them
Most frontend security issues have a known, testable replacement. The table shows the patterns we see most often and the rule that replaces each one in the spec. None of these needs a rewrite. Each one needs a decision, written down, and a check that keeps it in place.
| What we often find | What the spec requires instead |
|---|---|
script-src 'unsafe-inline' * |
Scripts by hash or nonce, origins listed |
Access tokens in localStorage |
HttpOnly cookies with stated timeouts |
| Analytics or chat loaded from a tag manager | Each script in the inventory, with an owner and a reason |
| API keys in the client bundle | Server-side calls, or keys documented as public and scoped |
innerHTML with API content |
Encoded output, or a sanitiser with an allowlist |
Starting from an existing frontend
If your frontend is already live, the usual first step is an Audit. In one to two weeks of fixed scope, we review headers, CSP, sessions, dependencies, secrets and third-party scripts. The findings arrive as spec deltas ranked by risk, so they can go straight into a Build or to your own team.
We secure the frontend. Your backend, infrastructure and incident response stay with you, and we coordinate with the people who own them.