DocsDeploy & operate

Security

What Sluurp does against the common attacks on web apps, and what is left to you.

This page takes the common web attacks, as listed by MDN, and says how Sluurp handles each. Most need nothing from you. To limit where server code may send data, turn on Only these and add rules:

sluurp outbound add '@@||api.stripe.com^'
sluurp outbound only on

Features include:

  • Text never parsed as markup, and javascript: URLs neutralised
  • Requests signed in by a header, never by cookies
  • Rules enforced in SQL on every read and write, down to fields
  • Server code held to the hosts it was allowed, once you turn that on, and to public addresses for links users give
  • Browser connection allowlists, reported first and then enforced
  • No packages installed at runtime

Cross-site scripting (XSS)

Text is never parsed as markup. JSX and html templates insert strings as text, so a name like <img onerror=…> shows as it is. javascript: URLs in href, src, action and the like are neutralised however they’re encoded. Strings can’t be event handlers: onclick="…" is refused. The same applies when pages are drawn on the server.

Cross-site request forgery (CSRF)

Requests are signed in by the Authorization header, never by cookies. Another site can make the browser send a request but can’t add the header, so it arrives signed out.

Clickjacking

HTML pages can’t be framed by other sites: all are sent with X-Frame-Options: SAMEORIGIN and frame-ancestors 'self'. A page meant for embedding can set its own header, which wins.

Insecure direct object references (IDOR)

Ids are random, but that’s not the protection. Every read and write goes through the collection’s rules, enforced in SQL down to individual fields, so knowing an id grants nothing.

Manipulator in the middle (MITM)

Serve behind TLS; see Deploying. Once a browser connects over HTTPS, Strict-Transport-Security pins it there for a year.

Server-side request forgery (SSRF)

Your own server code is trusted, so its fetch can reach any address until you turn on Public addresses only in Settings. A request for an address somebody else gave, such as a link a user posted, is different: code makes it with publicOnly: true, and it can then reach public addresses only, whatever the settings and lists allow. Link previews work this way. With either, loopback, private ranges and cloud metadata endpoints are refused, and every redirect is checked again. The request then connects to the very address that was checked, so a name that answers differently the second time it is looked up (DNS rebinding) can’t get around the check.

Hosts each script may reach

Each function, hook and job also has hosts of its own. They are learned as it runs and listed in Settings, under Hosts each script may reach. Turn on Only these, and each one can reach only the hosts it was seen reaching or that you allowed. A new host is refused, logged and listed there, to allow with a click. A script that leaks data has nowhere new to send it. Its data is held the same way: the collections each script reads and writes are learned too, and with Only these on, a collection it never read (or wrote) is refused and listed for you to allow. Migrations are never held to it.

Rules decide before what was learned. They’re written one per line, the way AdGuard writes its DNS filters:

! a comment (# too)
@@||api.stripe.com^                 allowed: it and every name under it
||ads.example.com^                  blocked: it and every name under it
@@hooks.slack.com                   allowed: that name only
@@*.internal                        allowed: any name under internal
/^track[0-9]+\./                   blocked: names matching the expression
@@||mail.example.com^$script=newsletter|digest    only for those scripts
||example.org^$important            wins over an allowing rule

Set them in Settings, where you can also check a host, or from a migration:

migrations/V7__outbound.json
{ "outbound": { "add": ["@@||api.stripe.com^"], "remove": ["||old.example.com^"], "only": true } }

rules replaces the whole list instead of add. Or use the command line:

sluurp outbound add '@@||api.stripe.com^'
sluurp outbound only on
sluurp outbound check api.stripe.com --script checkout
sluurp outbound list

Data leaving through the page

A script you embed, or code an agent wrote, could send what a page holds to a server of its own. Sluurp tells the browser where your app’s pages may connect at all, with Chrome’s connection allowlists (Chrome 152 and later): every fetch, WebSocket, prefetch and redirect is checked before it connects, and anything not on the list is refused.

It starts in report only: nothing is blocked, and each address a page reached that isn’t on the list is reported back and listed in Settings → Browser connections, with Allow beside it. Once the list covers what your app really uses, switch to Enforce. The page’s own server is always allowed. The UI Kit’s frames, where components an agent wrote are drawn, are always held to their own server.

In a migration:

migrations/V8__connections.json
{ "connections": { "mode": "enforce", "allow": ["https://api.stripe.com/*", "https://*.example.com/*"] } }

Redirects are followed unless you turn them off; WebRTC (calls, peer to peer) is refused unless you turn it on. Other browsers ignore the header, so it adds to the rest of this page rather than replacing it.

Prototype pollution

The server parses JSON into Rust types, which have no prototype. In the browser and the server, island props and server function arguments and results are read by Sluurp’s own serializer without eval: every value is checked, and a __proto__ key becomes an ordinary property instead of changing the prototype.

Cross-site leaks

Cross-site referrers are trimmed to the origin (strict-origin-when-cross-origin), and MIME sniffing is turned off (nosniff).

Supply chain

Nothing is installed at runtime; the server is a single binary. An app’s packages are installed by Bun from its lockfile (bun.lock, checked by integrity) and bundled with it, never fetched from a CDN by the page, so what runs is exactly what you reviewed and committed.

Phishing and subdomain takeover

These are about people and DNS, not code. Offer two-factor sign-in (see Sign-in), and delete DNS records when their target server goes away.

View as Markdown