Security rules for apps
An app runs inside a real business's site, with its customers' accounts and data. These rules are not optional: the automatic checks and the reviewer look for them, and the templates already follow them. Keep the secure defaults.
Keys and secrets
- The Site Key (
SITE_KEY) is server only. Never send it to a browser, a log, a file or git. - A deployed app site has four secrets, all set by EzyStudio:
DATABASE_URL,JWT_SECRET,SITE_KEYandSITE_JOBS_SECRET. Read them only insrc/platform/config.ts. An app you list can't add secrets of its own, and a bundle with a private key or a live API key in it is refused. - Everything in a page or in browser code is public: no secrets, no hidden admin routes, no “security by obscurity” flags.
- Secrets your own feature issues (an invite code, an API token) are stored as a SHA-256 hash with a short hint, and shown once.
Network
- A deployed site's server reaches only the EzyStudio platform host and its own database. Everything else is blocked.
- Never fetch or proxy a URL a user typed in. Platform calls go through
src/platform/api.ts. - Don't add CORS headers to your site's server: its pages talk only to the site's own address.
- Payments go through EzyStudio. Sending payment details to an outside service (Stripe or PayPal scripts and forms, payment links) is flagged with a warning in review. A percentage fee, or a price inside a free app, fails the pricing check.
- Webhooks into the site live in their own Hono app, mounted before the CSRF checks, and verify an HMAC signature with a constant-time compare before reading the body.
Access control
- Every route that isn't public runs
withViewer → requireAuth → requirePermission(codename). Hiding a button is not access control. - Scope every query to the caller (
where: {id, ownerId: viewer.id}) and answer 404, not 403, for rows that aren't theirs. - Never accept
userId,role,status,ownerIdorcreatedByfrom the client. Build each write field by field from validated input. - Use only the built-in sign-in (
/account/*): don't add your own login, register or reset pages. - For a dangerous action (delete an account, change an email), ask for the current password again.
Input and output
- Validate every input: type, trimmed length, allowed values, format. Reject bad input, don't repair it.
- SQL only through Prisma's query API, or parameterized tagged templates. Never
$queryRawUnsafe, never SQL built from strings, never a column name from input. - HTML: Astro escapes values. Raw HTML only from
sanitizeHtml(); in the browser usetextContent, neverinnerHTMLwith data. - Links from users:
https:(andmailto:where it makes sense) only, parsed withnew URL. Neverjavascript:ordata:. - Requests are limited to 64 KB and there is no file storage for sites yet. Never put base64 files in the database.
- Redirects go to paths on the same site only.
In the browser
- Keep
sameOriginand the CSRF check on the whole site backend. Browser writes go throughsiteFetchor the portal's API client. - Keep the security headers and the Content Security Policy. Never add
'unsafe-inline'or'unsafe-eval', inline event handlers (onclick=) orstyle=""attributes in Astro markup. - No
eval, nonew Function, no scripts loaded from a CDN at runtime.
Customer data
- Collect only what the app needs. Never sell or share customer data, and let owners export or delete it.
- Say what you store and why in your data note. Health information is flagged for a closer look.
- Only the user, and people with permission, see an email address.
- Never log passwords, tokens, cookies, the Authorization header, emails, full request bodies, raw IP addresses or environment values.
- Record security events (role changes, deletes, exports) with
audit(): who, what, on what. - Rate-limit anything that sends email, costs a lot or can be guessed, and give the same answer whether something exists or not.
Dependencies
| Rule | Why |
|---|---|
| Add a package only when you need it, at an exact version. | Fewer things to break or attack. The dependencies in your bundle's manifest take exact versions only. |
| Put package.json and package-lock.json at the root of your bundle. | Review reads them, never installs them, and checks the versions against known advisories. Without a package.json the security check can only warn. |
| No packages with native modules. | Sites run on Workers, where they can't load. |
| No install scripts and no packages from git or URLs. | Review warns on both. |
| Prefer WebCrypto to crypto libraries. | It is built in and fast. |
A critical or high advisory in your dependencies fails the security check.
What a whole-site listing may not contain
A whole site's code goes into every customer's site and editor, so submit and review refuse a version on the first of these it finds, and say which file and how to fix it. node store-check.mjs, in every release of the template, runs the same checks on your machine. The code in brackets is the reason the check answers with.
| Refused | Code |
|---|---|
A template.json that doesn't name astro-app or astro-static, or an add-on manifest (ezystudio-app.json) next to it. | bad_template |
| A template version that isn't the current release: an older one, or one that was never released. Merge the newest release tag first. The developer portal keeps Submit disabled until you have. | template_outdated |
Any file changed, added or deleted in src/platform/, the template's managed core. | platform_changed |
Any file changed, added or deleted in the template's rules for AI: AGENTS.md, CLAUDE.md, GEMINI.md or docs/agent/. | instructions_changed |
template.json, CHANGELOG.md, scripts/platform.mjs or scripts/managed-files.json changed or missing. | managed_file_changed |
A web app without sample data: no prisma/seed.sql, or one with only comments, or one with no INSERT. | seed_missing, seed_empty |
A package.json without a build script, or with a preinstall, install, postinstall, prepare or prepublish script: npm would run it in every customer's editor. | bad_package |
| A package for a database or data store other than Postgres. | not_postgres |
Hidden files other than .gitignore, .gitattributes, .env.example, .editorconfig, .nvmrc, .node-version, .prettierrc, .prettierrc.json and .prettierignore. | hidden |
Deploy config (wrangler.*, Dockerfile, Makefile, vercel.json, netlify.toml), shell scripts and native programs. Write scripts in JavaScript, scripts/*.mjs. | forbidden_file |
| Anything that looks like a live secret, in any file, even in a comment. | secret |
| Symbolic links, encrypted files, a file in twice, or a path with odd characters or longer than 240 characters. | symlink, encrypted, duplicate, bad_path |
| More than 50 MB in all, more than 5,000 files, or one file over 10 MB. | too_large, too_many_files |
- Agent and editor folders are never committed:
.claude/,.cursor/,.vscode/,.codex/,.idea/, and never.npmrc,.envor.platform/. Their settings can run commands for whoever opens the repository,.envholds your keys and.platform/is the platform's own. The template's.gitignoreleaves them out; if git already tracks one,git rm -r --cached .claude. - The template's own files are checked byte for byte against the release your
template.jsonnames. Changed one by mistake?git checkout v<version> -- <files>puts the release's copy back. - No secrets: no private keys, live payment keys, cloud keys or tokens. Keys are settings the site owner enters.
- Postgres only: the site's own database, through the client the template gives you. No other database, data store or connection string of your own.
Files you don't edit
src/platform/**, docs/agent/**, AGENTS.md, CLAUDE.md, GEMINI.md, template.json, CHANGELOG.md, scripts/platform.mjs and scripts/managed-files.json in a site are managed by EzyStudio and updated with the template. Don't edit them, weaken a guard or remove sameOrigin or csrf. If your app needs a change there, say what it needs instead.
The same rules, written for coding agents and kept up to date with the templates, are served on every site at /api/public/site/v1/agent-docs/security.md. See Rules for coding agents.