SHADE is young: 0.1.0-next.2 is a pre-release, and 0.1.0 isn't out yet.

SHADE
Security

Security testing

How SHADE is tested for security, what runs where, and when. Below is what SHADE builds into its own code and pipeline, and the practice around it.

What SHADE already does in its code

  • A threat model per decision. Every decision record has one: what an attacker tries, what stops it, and the test that proves it. Every change runs the ones it can affect (pnpm test:affected and pnpm test:e2e:affected, which runs every browser test when signing in, permissions, routes or the kernel change); the full pnpm test and pnpm test:e2e run at milestones and before every release.
  • Rules held by tests: the layers and front doors, which Better Auth plugins and options are used, module stylesheets scoped to the module, what the module SDK gives a module.
  • Request protection in the API: rate limits counted per IP (IPv6 per /64), per token and per account, in Redis for every container (the account steps that check the password, signing in again among them, five tries per team member in 15 minutes), refused with 503 while Redis is down rather than let through; idempotency keys; webhook signatures (apps/api/src/http/middleware/protection.ts); origin checks for cookie routes (origin.ts); a strict Content Security Policy for the admin (csp.ts); and on every module route's answer, SHADE's own cache and security headers: no-store unless a public GET route declares a cache, nosniff, and a policy that runs no script on an SVG (plugin-answers.ts).
  • Detection: the error log and security alerts emailed to admins, and the audit log.
  • Better Auth's advisories checked against the pinned version before each release (pnpm advisories:better-auth).
  • Signed modules, and untrusted modules in workerd's sandbox.
  • Modules' outgoing calls: a trusted module's moduleFetch and an untrusted module's fetch reach only their declared hosts, over https, never an address inside the server's network (private, loopback, link-local and cloud metadata, carrier-grade NAT, unique-local, multicast, reserved and the documentation ranges, in IPv4 and IPv6, mapped forms included), with the connection pinned to the address checked and every redirect checked (shade/kernel/outbound.ts). Tests run against a local https server with names resolved by a stub: refused hosts, internal addresses in every notation, DNS answers pointing inside, rebinding, redirects inside, oversized answers and timeouts. What a trusted module's code does past moduleFetch is not stopped: see Network. The email settings' SMTP server is held to the same address check, unless the operator allows an internal relay (SHADE_SMTP_ALLOW_INTERNAL).
  • Access control as a whole: every route called as every kind of actor against a table of expected answers (apps/api/test/sweep/access-table.ts), and every exported service whose first parameter is a context or a database checked to refuse before it reads anything (shade/test/contract/service-access.ts). Both run with pnpm test; a new route or service without its line fails.
  • A deployment template (deploy/compose.yml) with the container settings of Hardening a production instance, held by a test, and a smoke test that starts the image with exactly those settings.
  • /.well-known/security.txt on every instance, and a SECURITY.md in each repository: where to report a hole.

What these don't cover is a running instance seen from outside: the server, the network, the deployment's settings, and attacks across many requests. That is what the rest of this page is for.

The layers

LayerToolWhat it catches
Access controlSHADE's own route testEvery route called as every kind of actor (anonymous, visitor, editor, custom role, each token type, the module actor, admin) against its expected answer; a new route without one fails
Dependenciespnpm audit, OSV-Scanner, Dependabot alertsKnown vulnerabilities in the npm tree and any other lockfile
CodeSemgrep (JavaScript, TypeScript, Node, XSS and JWT rules)Unsafe patterns: queries or redirects built from input, missing checks
SecretsgitleaksKeys or tokens committed to any of SHADE's repositories
The imageTrivy, hadolintOutdated OS and Node packages and misconfiguration in the one image every client runs
The APISchemathesis, driven by the OpenAPI documentMalformed input to every endpoint: crashes, 500s, validation gaps
The running appOWASP ZAP (baseline, and the API scan from the OpenAPI document, signed in as a test admin and a test visitor)XSS, header and CSP gaps, cookie flags, CORS, open redirects
The servernmap, testssl.sh, nuclei, Mozilla Observatory, a DMARC checkOpen ports, weak TLS, exposed panels, missing headers, spoofable email
PeopleAn external penetration testThe logic holes tools miss

Running the checks

Until CI runs again on GitHub Actions, run these locally before a pull request; CI runs the same once it is back. Docker is the only tool they need: gitleaks, Trivy, OSV-Scanner, Semgrep and hadolint run as their official images, pinned by digest, never installed.

CheckCommand (in the SHADE repository)Fails on
Access controlpnpm test (access.test.ts, service-access.test.ts)An answer other than the table's; a route or service without a line
Dependenciespnpm security:audit (also in the SHADE workspace, for the site and the modules)A high or critical advisory without a reason in dependency-audit.json
Dependencies, every lockfilepnpm security:scan deps (OSV-Scanner, which asks OSV's database about each package)Any known vulnerability without a reason in osv-scanner.toml
Codepnpm security:scan code (Semgrep, metrics off; it fetches its rules from Semgrep's registry)A finding of an ERROR rule; one that doesn't apply gets a nosemgrep comment with the reason
Secretspnpm security:scan secrets [<repository>]Anything gitleaks finds in the history
The imagedocker build -f apps/api/Dockerfile -t shade ., then pnpm security:scan image shade and pnpm security:scan configA high or critical vulnerability with a fix; misconfiguration in the Dockerfile
The Dockerfilespnpm security:scan dockerfile (hadolint)Any finding; a rule is switched off only on its line, with the reason beside it
The deploymentpnpm deploy:smoke --image shadeSHADE not working with the template's settings (it writes outside its volumes, a role fails to start), the worker serving more than /health, or the admin not saying that background work is not running while no worker runs

The release gates

Before a release is cut, every check above and a few that only matter for a release run as one command, in the SHADE repository:

pnpm release:gates                                   # every gate; the image's need --image
pnpm release:gates --tag v0.1.0 --docs ../docs       # as the release workflow runs it: the tag, a shade-docs checkout
pnpm release:gates --only image,sbom,smoke --image shade   # the image's gates, on a built image
pnpm release:gates --list                            # the gates, with what each needs

Every gate runs, also after one has failed, and the report at the end gives each one's result: passed, failed, could not run (Docker or the network missing, no image, no docs checkout), or skipped by --only or --skip. A gate that could not run holds the release just as a failing one does. The release workflow (.github/workflows/release.yml) runs the gates before it publishes a package or pushes the image, and the image's own gates on the image it is about to push. Run by hand, the workflow is a dry run that publishes and pushes nothing.

GateWhat it checksReuses
versionSHADE_VERSION is a version, the tag matches it, and the SDK contract gives the release its date
changelogThe Changelog has the version's dated section, which records the check of Better Auth's advisories
experimentalEvery experimental manifest part and admin component is on the list of experimental parts, and no stable one is in its manifest table
advisory-listThe advisory list the module approval reads, shipped with the release, is at most 14 days old
licencesEvery production dependency of core, the SDK, svg, the API and the admin has a permissive licence, or one a person reviewed in licence-review.json; writes the list as licences.jsonpnpm licenses list
audit, better-authnpm's advisories; Better Auth's against the pinned versionpnpm security:audit, pnpm advisories:better-auth
secrets, osv, semgrep, hadolint, trivy-configThe scans in the table abovepnpm security:scan
packagesEvery package packed and checked, and no .env, .npmrc, key file or text shaped like a private key or token in what goes to npmpnpm release:packages
lint, typecheck, testsLint, the typecheck and every test, the access-control table and the threat models' tests among thempnpm lint, pnpm typecheck, pnpm test
image, sbom, smokeTrivy on the release image, its bill of materials as sbom.cdx.json (CycloneDX), and the smoke testpnpm security:scan, pnpm deploy:smoke

The licences allowed without a review are the permissive ones (MIT, ISC, the BSD licences, Apache-2.0, 0BSD, BlueOak-1.0.0, Zlib), the public domain dedications (CC0-1.0, Unlicense), Python-2.0, CC-BY-4.0 (for data such as caniuse's) and MPL-2.0, whose copyleft covers only the package's own files, which SHADE ships unchanged. An expression passes when one of its choices (OR) or all of its parts (AND) do. Anything else, a package with no licence field among them, needs a line in licence-review.json naming the licence as listed and why it is fine; the line holds only for that licence, so a package that changes its licence is checked again. The usual reviewed cases are a prebuilt library that a package loads dynamically and that stays unmodified (the LGPL-licensed libvips in sharp's platform packages), and a package whose repository is permissive but whose published files carry no licence field.

The frontend kit has its own pnpm release:gates in shade-frontend, with the gates that apply to it: changelog (CHANGELOG.md has the version's section, no longer marked as not released), licences (the packages the kit publishes, by the same rules and with its own licence-review.json) and secrets. It takes --only, --skip and --list as SHADE's does.

Publishing is held to the same rule: pnpm release:packages --publish refuses to publish to npm outside GitHub Actions, without npm provenance (NPM_CONFIG_PROVENANCE) or without the run's identity token, so nothing is published by hand.

A reason in dependency-audit.json names the advisory, why it doesn't reach SHADE, the projects it holds for and the day it was reviewed; it goes once the advisory is gone. A reason holds for 3 months: after that the audit fails again until someone checks it and updates reviewed. New versions wait a week: minimumReleaseAge in pnpm-workspace.yaml (10080 minutes) keeps pnpm from installing a version published less than a week ago, since a hijacked release is usually found and pulled within days. A reason in osv-scanner.toml works the same way: it names the advisory and why, and its ignoreUntil date, 3 months on, makes the scan fail again until someone reviews it. The weekly scans of a staging instance (ZAP, Schemathesis, nuclei) are not in SHADE's pipeline yet.

Where to test

  • A staging instance, never a client's production. It runs the same image and the same Coolify and Traefik setup as production, on its own subdomain, with made-up data. All active testing happens there: scans, fuzzing, brute force, uploads.
  • Production gets passive checks only: TLS, headers, which ports answer, and nuclei's safe templates at a low rate. Anything more needs the client's written permission in their contract. Testing a system without permission is a criminal offence in the Netherlands (Article 138ab of the Criminal Code), even one you built, and hosting providers have their own terms for scanning.
  • Check detection as well. During a session on staging, confirm that SHADE's rate limits answer, that the audit log records the attempts, and that the security alert emails reach an admin's inbox. Tell whoever receives them before you start.

When each runs

Run the fast checks (tests, the access-control test, dependency and secret scans) on every change, scan the image on every build, and run the slower scans of a staging instance regularly and before each release. How often is up to whoever runs the instance.

When something is found

  • In SHADE's code: fix it with a test that fails without the fix, as every security fix in SHADE has; add the attack to the decision's threat model when a decision covers that part.
  • In a dependency: upgrade it (a dependency change, reviewed on its own), or record why it doesn't reach SHADE.
  • In a client's deployment: fix it in the deployment and in Hardening a production instance, so the next instance starts right.
  • A finding that affects running instances holds the release that fixes it until every client is updated; the release notes say what it fixes without giving a recipe for the attack before clients are updated.