Security
What prime protects on its own, what you set up when you deploy, and the limits to know about.
prime runs inside your site, so its admin is as exposed as your site is. This page lists what prime does for you, what you need to do when you deploy, and what it does not do yet.
Before you deploy
- Set
authinprime.config.ts. Without it, a production build refuses every request to/prime. - With
basicAuth, use a password of at least 16 characters, such as one fromopenssl rand -base64 24. Shorter passwords keep a production admin closed. - Serve the site over HTTPS. A production admin does not open over plain HTTP.
- Keep secrets in environment variables or your host’s secret store, never in
prime.config.tsor the repository. - Give
GITHUB_TOKENaccess to the one repository, with Contents read and write and nothing else.
Who can open the admin
Closed until you choose. Without auth, the admin opens on localhost while you develop and nowhere else. A production build refuses every request, even on localhost.
Passwords. basicAuth asks for a username and password through the browser’s sign-in prompt. Every user is compared on each attempt, so how long a refusal takes does not reveal which usernames exist. In production:
- Every password must be at least 16 characters. If one is shorter, the admin stays closed and says why.
- A wrong password waits one second before it is refused. A visit that sends no password is not slowed.
HTTPS only. Outside development, an admin with auth set only opens over HTTPS, so a password never travels unencrypted. Over plain HTTP prime refuses before asking for a password, so the browser never shows the sign-in prompt there. If a proxy ends HTTPS and forwards plain HTTP to your server, as nginx and most hosting platforms do, prime accepts its X-Forwarded-Proto: https header.
Development is relaxed. When NODE_ENV is development or test, any password length works and plain HTTP is allowed on any address, so you can try the admin from a phone on your network. astro dev, next dev, vite, SvelteKit’s dev server and primecms dev all set NODE_ENV=development. A runtime that does not set NODE_ENV at all counts as production.
Roles. On Studio and Agency plans, each person can have a role that limits what they change. See Access and roles.
Putting a proxy in front
You can let something in front of your site decide who gets in, such as Cloudflare Access, Tailscale or your company’s single sign-on:
trustUpstreamlets every request in.fromHeaderreads who is asking from a header the proxy sets.
Both trust the proxy completely, so they are only safe when nothing can reach your site without going through it. On Cloudflare Workers, that means the *.workers.dev address and preview URLs too: either turn them off in the Worker’s settings or protect them with Access as well. Otherwise anyone who finds them reaches the admin with trustUpstream, and can claim to be anyone with fromHeader.
To check, request https://<your-worker>.workers.dev/prime/api/schema from a private window. It should be refused or not found, never answered.
When in doubt, use basicAuth, or require both with your own auth function.
What prime checks on every change
- Same-site writes. Every change must send an
x-prime-requestheader, which a form on another site cannot send. When a browser marks a change as coming from another site, through theSec-Fetch-Siteheader, prime refuses it. Scripts and CI do not send that header and are not affected. - Validation. Every save is checked against your schema before it is written.
- No lost edits. A save names the version of the file it started from. If the file changed since, the save is refused, and the editor is asked to reload.
- All or nothing. A change to several files, such as a proposal, is written completely or not at all.
- Safe paths. Entry names and media file names are checked, so no request can read or write outside your content and media folders.
The agent
- The agent cannot change your content. It only has tools that read, and its changes become proposals that a person applies or rejects in Reviews.
- Text the agent reads, including your entries and anything pasted into them, can try to steer it. Because every change waits for review, the worst it can do is propose something you reject. Read proposals before you apply them.
- Model keys are read from environment variables on deployed sites. A key pasted into Settings during development is kept in
.prime/secrets.local.json, which prime adds to.gitignorefirst. With GitHub storage, prime refuses to write a key at all. - Requests go from your server to your model provider, on your account. The offline demo model only runs on local addresses.
Media
- Uploads are limited to the image, PDF, font and zip types listed in Media, each with a size limit. prime checks each file’s first bytes, not only its name, so a different file renamed to
.pngis refused. - SVG and HTML uploads are refused, because either one opened on its own can run script. SVGs already in your media folder are shown with a policy that blocks script.
- Files other than images download rather than open, so a PDF or a font never runs inside the admin.
The admin page
The admin is served with headers that stop other sites from framing it, stop browsers from guessing file types, and keep its address out of links you follow from it.
Limits
- No sign-out with
basicAuth. The browser remembers the password until it closes. On a shared computer, close the browser when you finish. A sign-in page with sessions and sign-out is planned. - The one-second wait does not stop a determined attacker. It slows guesses made one at a time, not many at once. On Cloudflare, a rate limiting rule on
/prime/apiis the real limit. The 16-character rule makes guessing hopeless either way. - No audit log. Git records who changed files, and proposals record who asked for them. prime keeps no other record.
- Roles cover whole collections. They cannot limit single fields or entries.
Reporting a problem
If you find a security issue in prime, email support@primecms.dev with “Security” in the subject. Please do not open a public issue. We will reply, fix the issue, and credit you if you would like.