Skip to content

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.

mermaid
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:#15803d

Four 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 args is the whole JSON map, without the PHP version's "undeclared keys are rejected" protection; call should read only the keys it needs and validate the type and range of each.
  • Fragment params are only guaranteed to be strings of at most 2048 characters; business rules must be checked in the fragment function.
  • An id in extra still has to be loaded as a model and checked with user.authorize(...).

2. What can be called is a list, not a directory ​

ListWhereWhy it's manual
Linker componentslinker::register::<C>() in src/cg/mod.rsWriting a struct shouldn't open a door
Callable methodsEach component's METHODSgrep -rn "const METHODS" src is the attack surface
Browser actionsBUILTIN_ACTIONS + resources/js/cg/linker/actions.jsThe most the server can make the browser do
Fragmentsrender::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::new only accepts names and arguments from the action table; a wrong name or argument returns Err.
  • Error messages are fixed text (the messages module); server exceptions, SQL and paths never appear on screen (except with APP_DEBUG=true; see Deployment).

"Development boundaries" vs "security mechanisms" ​

ThingSecurity 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.