Most of the protection is built in. This page covers what comes switched on, the one choice you make (the public site's Content Security Policy), what a live site needs, and what makes pages fast.
Built in
- Escaping. Templates print every value through an escaping function, so code typed into a field shows as text instead of running. The AI writes every template this way; only the editor's formatted text goes out as HTML.
- Form tokens. Every form, in the admin and on the site, carries a secret token (CSRF protection), so another site can't submit it in someone's name.
- Database. Queries are prepared statements, which shuts out SQL injection.
- Logins. Too many wrong passwords pause the login for some minutes, in the admin and in the members area. Admin users and members can also get a 6-digit code by e-mail at each login.
- Uploads. SVG files are cleaned on upload and, since v3.7.7, served in a sandbox that stops any leftover script. Files sent through forms are private: only a logged-in admin downloads them.
- Private folders. The server rules keep
.env, the engine,storage/and the theme's PHP files out of reach from the web. - The admin. Since v3.8.1 it runs no inline JavaScript (an injected script doesn't execute) and asks search engines not to index it. Since v3.8.2 its forms only send to the site itself, so a fake login form can't carry a password away.
The Content Security Policy
A Content Security Policy (CSP) is a header telling the browser which scripts may run on a page and where its forms may send. Since v3.8.1 Velk sends one on the public site, and since v3.8.4 it is set in the theme's site.json (security.csp), so it travels with the theme to the server. Up to v3.8.3 it lived in .env, and the AI moves it into site.json when it upgrades such a site.
| Mode | What it does |
|---|---|
open | The default. Breaks nothing: other sites can't frame yours (frame_ancestors names those that may), and over HTTPS insecure requests are upgraded. No script is restricted. |
report | A rehearsal: open stays in force, and the browser reports what strict would block. |
strict | Runs only the scripts carrying the page's one-time code (nonce), without 'unsafe-inline', which security scans flag. Forms only send to the site itself; Stripe is added on its own when payments are on. |
off | No policy at all. For a host or CDN that sends its own. |
Ask the AI
A security scan of the Atlas Law site flagged 'unsafe-inline' scripts. Prepare the theme for the strict Content Security Policy: run csp:check and fix what it finds. The site embeds YouTube videos and its newsletter form posts to Mailchimp. Leave the site in report mode; I'll browse it before we switch.
The AI puts the page's nonce on the theme's scripts, replaces inline handlers such as onclick, adds the newsletter's address to allow.form and sets the mode to report.
csp:check reads templates as text: what code builds, or a CDN inserts, only shows up in the browser.From open to strict
-
Check
csp:checklists scripts without the nonce,onclick-style attributes,javascript:links and forms posting to sites nothing allows. -
Rehearse in report
Browse the site — forms, embeds, members area, checkout — with the browser console open, or collect the reports at an address set in
CSP_REPORT_URIin.env. -
Switch
Only the mode changes. Scripts pasted in the admin's Scripts screen keep working: Velk adds the nonce to them, and what they load (Google Tag Manager's tags, say) inherits the trust.
A live site
On the server, APP_DEBUG stays false — when on, an error shows file paths and queries to any visitor — and the first deploy writes it that way. Turn on the hosting's HTTPS certificate and keep APP_URL with https://. Leave the admin out of robots.txt: the file is public, it would reveal an admin address you changed, and a crawler that obeys it never reads the “don't index” instruction.
Speed
The biggest gain comes from a CDN, a network such as Cloudflare that keeps copies of pages close to visitors. Velk tells it what it may keep:
CACHE_TTLin the server's.envis how many seconds the CDN may keep a page. At0, the default, Velk sends no cache header.- With it on, a page that opened no session goes out cacheable; a page with a form, or seen by a logged-in member, goes out private, so the cache never hands one person's page to another.
- A form in a part shown on every page, such as a newsletter in the footer, stops caching on the whole site, with no error. Keep it on one page and link to it.
- On your computer, with
APP_DEBUG=true, theX-Velk-Cacheheader says whether a page can be cached, and why not. - Many CDNs cache only files such as images until page caching is allowed on their side. Image sizes, covered on the media page, keep pages light too.
Ask the AI
Turn on edge caching for 5 minutes on the live site, which sits behind Cloudflare. Then show me the cache headers of the home, a blog post and the contact page, and tell me if anything stops the public pages from being cached.
The AI reads the headers with curl -sI. The contact page comes back private, as expected.