Trust boundaries
The first step of security practice is being clear about what you can trust and what you can't. This runtime draws the boundary in a very specific place.
flowchart LR
subgraph Untrusted["Untrusted (the user can change it freely)"]
DOM["HTML attributes<br/>data-linker-* / data-state-*<br/>render object allow lists"]
ST[("Client state")]
ARGS["Linker args<br/>fragment params"]
REF["Referer"]
end
subgraph Trusted["Trusted (only Rust code can change it)"]
REG["linker::register alias table"]
COMP["METHODS lists"]
ATTR["Login / authorization / validation in call"]
INST[("Stateful instance state")]
ACT["Action table"]
WL["render::register fragment names"]
end
DOM --> ARGS
ST --> ARGS
ARGS -->|"re-validated at every layer"| ATTR
ATTR --> COMP
COMP <--> INST
style Untrusted fill:#fee2e2,stroke:#b91c1c
style Trusted fill:#dcfce7,stroke:#15803dFour principles
1. Everything from the browser is user input
data-linker-args, data-linker-extra, data-param-*, form fields, client state: the user can change all of them in DevTools. On the server:
- Linker's
argsis the whole JSON map, without the PHP version's "undeclared keys are rejected" protection;callshould read only the keys it needs and validate the type and range of each. - Fragment
paramsare only guaranteed to be strings of at most 2048 characters; business rules must be checked in the fragment function. - An id in
extrastill has to be loaded as a model and checked withuser.authorize(...).
2. What can be called is a list, not a directory
| List | Where | Why it's manual |
|---|---|---|
| Linker components | linker::register::<C>() in src/cg/mod.rs | Writing a struct shouldn't open a door |
| Callable methods | Each component's METHODS | grep -rn "const METHODS" src is the attack surface |
| Browser actions | BUILTIN_ACTIONS + resources/js/cg/linker/actions.js | The most the server can make the browser do |
| Fragments | render::register("name", …) | The name is the allow list |
3. Business state never leaves the server
In Stateful mode, the component struct's fields are serialized into the server cache, and the browser only has the uuid and rev. The step the browser sees is just a display value returned by .data("step", …); changing it doesn't affect the server's decisions.
Client state should only hold things where "if it's tampered with, the worst case is the page looks odd". The test:
If the user changes this value in DevTools, what's the worst that can happen?
4. The server doesn't send code
- Linker returns named actions, not JS strings. There's no eval path, so CSP doesn't need
unsafe-eval. Action::newonly accepts names and arguments from the action table; a wrong name or argument returnsErr.- Error messages are fixed text (the
messagesmodule); server exceptions, SQL and paths never appear on screen (except withAPP_DEBUG=true; see Deployment).
"Development boundaries" vs "security mechanisms"
| Thing | Security mechanism? | Its value |
|---|---|---|
Render object allow lists (Allow::*) | ❌ | The template is the truth; catches slips |
ALLOWS_REFERER_URLS | ❌ (narrows exposure) | Stops other sites embedding your endpoints |
| Stateless signed URLs | ❌ (integrity + expiry) | Proves the capability wasn't tampered with or expired |
| Render tokens | ❌ (replay protection) | Each token can be used once, stopping resends |
Login (enforced by the runtime) and user.authorize / policies | ✅ | The real gatekeeping |
Argument validation in call | ✅ | The shape of arguments |
CSRF (Laravel for Rust's web group) | ✅ | Cross-site requests |
Next: Server-side checks → The browser and XSS → Deployment and operations → Review checklist.