Security and recovery

Security

From docs/security.md at commit 548821a.

Spinto 0.1.0. These docs follow the main branch. Spinto isn't on crates.io yet, so you install it from a clone.

Spinto shows what your workflows did, and workflow runs hold real data: customer details, API responses, error messages that quote a request. This page describes who Spinto lets in, what it shows them, how its pages are protected in the browser, how to configure it, and what it doesn’t protect against.

Threat model

Spinto is an operator’s tool. It assumes the people the host application lets in may see every run, with secrets redacted. It defends against:

  • Anyone who isn’t let in, signed in or not, reading run data through a page, an Inertia visit, a partial reload, a JSON request, or the MCP endpoint.
  • Run data that attacks the browser. Workflow input often comes from end users, so a customer named </script><script>… must render as text on the operator’s screen.
  • Secrets in run data reaching an operator’s screen, a screenshot, a browser cache, or an AI agent through MCP.
  • Other sites framing Spinto, reading it through a shared cache or search index, receiving its URLs as a referrer, or making an operator’s browser change something.

It doesn’t defend against an operator who is let in, a compromised host application or database, or someone who can read the server’s memory or logs. Spinto runs inside the host application with the host’s database credentials, so it is exactly as trusted as the host.

Access: closed by default

Spinto refuses every request until the host tells it who may look, by registering an Authorize:

// src/http/spinto_access.rs
use laravel::http::Request;

use crate::models::User;

pub struct SpintoAccess;

impl spinto::Authorize for SpintoAccess {
    async fn authorize(&self, request: &Request) -> laravel::Result<bool> {
        let user: Option<User> = request.user().await?;

        Ok(user.is_some_and(|user| user.is_operator()))
    }
}
// src/app.rs
providers.add(spinto::Spinto::new().authorize(SpintoAccess));

Spinto asks authorize before every request to its routes, before anything is read from the workflow store. false refuses the request. An error fails it with a 500, the way an error in a policy does: it is never read as a yes.

Guests, other users, and JSON clients

When authorize says no, the refusal depends on who asked:

Request Response
A guest’s browser, when the host marked a login page with #[laravel::auth::page(login)] A redirect to the login page. After logging in, Redirect::intended brings them back to the Spinto page they asked for
A guest’s Inertia visit, such as following a link inside Spinto after the session expired 409 with X-Inertia-Location: /login, so Inertia does a full page visit to the login page instead of trying to render it as a Spinto page
A guest, when the host has no login page 401
A signed-in user who isn’t allowed 403
Any request that expects JSON 403
Any request, when the host has no session guard 403

Spinto redirects guests because a bare 403 tells someone who simply isn’t logged in that they are forbidden, and gives them no way forward. The redirect goes through the framework’s own Authenticate middleware, so it is the same redirect the host’s other pages give, intended URL included. No refusal carries any workflow data, and every refusal carries the headers below.

Boot checks

Spinto checks its settings when the application boots:

  • Settings that could show more than intended, or send an operator somewhere unsafe, stop the boot, in every environment: a SPINTO_PAYLOADS other than redacted or hidden, a SPINTO_PATH that doesn’t start with /, or a SPINTO_CLOUD_URL that doesn’t start with https://. Spinto won’t guess what an operator meant by a payload policy it doesn’t know.
  • A missing Authorize logs a warning and boots, in every environment, production included. Without one Spinto already refuses every request, so nothing can leak. Failing the boot would take the host’s web server and queue workers down over a dashboard setting, which costs more than a dashboard that says no.
  • A SPINTO_MCP_TOKEN shorter than 32 characters logs a warning.

Browser protections

Every response from Spinto’s routes carries, whatever its status:

Header Value Why
Cache-Control no-store, private Run data stays out of browser caches, the back-forward cache, and shared proxies
Referrer-Policy same-origin Run IDs and filters in Spinto’s URLs aren’t sent to other sites
X-Frame-Options DENY No other site can frame Spinto to trick an operator into clicking
X-Robots-Tag noindex, nofollow Search engines never index a page that slipped past a gate
X-Content-Type-Options nosniff Responses are only ever read as what they say they are
Content-Security-Policy See below. Refusals and the host’s error pages get frame-ancestors 'none' only  

Every document Spinto renders gets the full policy, including its own pages for a run that doesn’t exist (404) or a store it can’t read (503). Error pages from the host’s error handler get only the framing rule; the host’s own policy applies to the rest of them.

Content Security Policy and the nonce

Spinto’s pages are served with:

default-src 'self'; script-src 'self' 'nonce-…'; style-src 'self' 'nonce-…'; img-src 'self' data:;
font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; form-action 'self';
frame-ancestors 'none'

There is no unsafe-inline and no unsafe-eval. Spinto’s script and stylesheet are its own prebuilt files, served from the host’s origin. The one inline script, which picks light or dark mode before the page paints, carries a nonce that is new for every request.

Spinto’s frontend reads that nonce from the root view’s script and passes it to createInertiaApp({ nonce }), so the style elements Inertia adds, such as the progress bar’s, carry it too. Pages also get it as the cspNonce prop, the name Flux’s Inertia provider reads.

If the host already set a nonce for the request with laravel::view::use_csp_nonce, Spinto reuses it, as long as it is plain base64, so a host-wide policy and Spinto’s agree.

Run data reaches the browser only inside Inertia’s page JSON, which Inertia escapes for its <script type="application/json"> element, and React renders it as text. The frontend never renders run data as HTML. examples/onboarding/tests/security_escaping.rs puts </script><script>… markup into the data of one of Spinto’s pages and checks that the page’s script still holds whole, valid JSON with the markup intact as a string, and that no markup is live.

Read-only, and GET only

Spinto reads the workflow store’s tables and never writes to them. It has no retry, cancel or resume buttons.

Spinto’s pages are GET routes only (which also answer HEAD), and a test checks route:list for anything else. A GET can’t change anything, so Spinto has nothing for a forged cross-site request to do.

The one route that takes a POST is the MCP endpoint, POST /spinto/mcp, and it exists only when SPINTO_MCP_TOKEN is set. It sits outside the web group and reads no session or cookie. Every request must carry the token as a bearer token, which a browser can’t attach to a forged request, and its tools only read.

Any future action that changes something must be a POST (or PUT, PATCH, DELETE) route in the host’s web middleware group, so the framework’s PreventRequestForgery checks its CSRF token. It must also pass the Authorize gate and a separate check that the user may take that action, and it must never be reachable with GET. The demo’s approval page, in examples/onboarding, shows the pattern: a form with csrf_field(), posted to a route that authorizes the operator through a policy before it resumes the run.

What is and isn’t redacted

Spinto’s reader applies the payload policy, in src/workflows/redaction.rs, to every value before it returns it, so every page, Inertia visit, partial reload and MCP result gets the same treatment. With SPINTO_PAYLOADS=redacted, the default, payloads are shown with secrets replaced by [redacted], and each payload lists the JSON pointers it replaced. With hidden, no payload is shown at all.

Redacted:

  • The whole value of a key that names a secret, at any depth, inside arrays too, even when the value is an object or an array. A key is secret when it contains password, passwd, secret, token, api_key, apikey, authorization, authkey, cookie, credential, private, creditcard, cardnumber, sessionid or sessid, in any case. It is also secret when one of its words is auth, oauth, session, card, cvv, cvc, iban or ssn, when its last word is key, or when it contains one of the SPINTO_REDACT_KEYS. Words split at anything that isn’t a letter and at camel-case boundaries, so cardNumber, userSSN and x-api-key are secret while author, discard and classname aren’t.
  • Credential-shaped text anywhere, including inside other strings, attribute values and error messages:
    • Bearer and Basic credentials
    • passwords in URLs, with or without a user name: https://user:password@host and redis://:password@host keep everything but the password. The password runs to the last @ before the host, so a raw @ in it is hidden too. A raw / can’t be part of a URL password, so localhost:5173/@vite keeps its port
    • the value of a name=value, name: value or "name": "value" pair whose name is secret by the key rule above, also with JSON-escaped quotes as in {\"password\":\"…\"}. So client_secret=…, STRIPE_KEY=…, x-api-key: …, Cookie: … and Authorization: Token … are hidden. A quoted value is hidden up to its closing quote. Otherwise the value runs to the next space, quote, comma, semicolon or &, and a capitalized scheme word before it, such as Token, goes with it
    • JWTs
    • provider keys such as sk_live_…, sk_test_…, tok_…, whsec_…, GitHub, GitLab and Slack tokens, AWS access key IDs and Google API keys, also when joined to other text by _, as in stripe_sk_live_…
    • runs of 32 or more hex digits, also when joined to other text by -, _, / or +, as in Mailgun’s key-…, deploy_… or a path such as objects/…. A token joined by -, _ or + is replaced whole, while a path keeps its other parts, so http://jaeger:16686/trace/<hex> keeps /trace/. A path that as a whole looks like base64 (40 or more characters mixing upper case, lower case and digits, as Org/Repo/commit/<hex> can) is hidden whole, because base64 holds / too and its pieces would otherwise show. A run after a . is replaced on its own. Also runs of 40 or more mixed-case base64 characters
  • The whole value of an attribute whose name looks secret. Other attribute values get the text checks.
  • Context values. Spinto shows the names of the logged context values a run started with, never their values. Hidden context values aren’t even named.
  • Names that look like credentials. A step, sleep, wait or resume name, an attribute name, a JSON key or a logged context key that the text checks would change is replaced whole with [redacted 1], [redacted 2] and so on, numbered within its run or payload, and its value is hidden. The original never appears in an entry ID, a URL or a reported JSON pointer. Job names, batch names, and workers’ hosts and queues get the text checks too.
  • Search and filters. They match only what the pages show: a secret attribute name, a replaced name, or a value that would be redacted matches nothing, so a result or its count can’t confirm a guess.

Not redacted, so don’t put secrets in them:

  • Workflow names, and step, sleep and wait names that don’t look like credentials, such as customers.42.approval.
  • Run IDs, job IDs, trace IDs, statuses, timestamps, connection and queue names, and counts. These come from the runtime, OpenTelemetry or the application’s code, not from run data. A trace ID is 32 hex digits by design, and Spinto needs it whole to link to the trace viewer.
  • Personal data that doesn’t look like a secret, such as names and email addresses. Add the keys that hold it to SPINTO_REDACT_KEYS, or use SPINTO_PAYLOADS=hidden.
  • A secret in free text with no recognisable shape, such as a short password quoted in a sentence. Redaction by shape is a backstop, not a guarantee.
  • A password in a URL that holds a raw /, ? or #, such as amqp://guest:x/pw@host. A URL can’t hold them there, so they read as a path, a query or a fragment. Percent-encode them. A URL password longer than 256 characters isn’t read as one either; it is hidden only when it looks random.
  • A quoted value with no closing quote. Only its first word is hidden, up to a space or a backslash.
  • JSON escaped twice, such as {\\\"password\\\":…}: the pair rule reads quotes escaped once.
  • A pair in text whose name isn’t secret by the key rule, such as pass=… or pwd=…. The SPINTO_REDACT_KEYS apply to JSON keys and attribute names, not to pairs inside text.
  • A credential split across a key and its value, where neither looks secret alone: an attribute named Bearer holding the token, {"Bearer": "…"}, {"name": "api_key", "value": "…"} or a header list such as [["X-Api-Key", "…"]].

Payloads whose redacted JSON is larger than SPINTO_PAYLOAD_LIMIT bytes are cut, and marked as cut.

These rules are held by two test files. tests/security_leaks.rs stores fourteen credential shapes in every text column and JSON key and value of every table Spinto reads, as whole names, keys, values, nested and inside arrays, then scans every route Spinto registers (the HTML, the Inertia page and a partial reload of every prop), every report as JSON and as its printed page, and every MCP tool and resource over stdio. It fails on any shape it finds, naming the surface and the JSON path, and it checks that searching or filtering by any stored credential finds nothing. Because it scans what Spinto returns rather than a list of fields, a new route, tool or field falls under it. In examples/onboarding/tests/security_redaction.rs, a test workflow stores live-looking tokens, API keys, a JWT, Bearer headers and a URL with a password in its input, in nested step output, in attribute values, in its error, and in logged and hidden context. The tests check that none of them comes back from the reader’s run detail, lists or overview, while benign values next to them still do. no_page_shows_a_secret makes the same check against the run page, its Inertia JSON, a partial reload of each of its props, and the list pages, and mcp_never_returns_a_secret against the MCP tools.

Configuration

Variable Default Meaning
SPINTO_PATH /spinto Where Spinto is served. Must start with /
SPINTO_ENABLED true false registers no routes at all
SPINTO_PAYLOADS redacted redacted or hidden. Anything else stops the boot
SPINTO_REDACT_KEYS   Extra keys to redact, comma-separated
SPINTO_PAYLOAD_LIMIT 65536 Payloads larger than this many bytes are cut
SPINTO_POLL_SECONDS 5 How often open pages re-read the store
SPINTO_MCP_TOKEN   The bearer token for the HTTP MCP endpoint. Unset keeps the endpoint off. Use at least 32 random characters
SPINTO_CLOUD_URL   Your environment’s page in Laravel Cloud, for the queue pages’ links. Must start with https://. Anything else stops the boot

Limiting a user to some runs (planned)

Authorize answers one question: may this request see Spinto at all? A multi-tenant host may want a second one: which runs may it see? That is planned for after the first release, as an addition that doesn’t break existing Authorize implementations:

pub trait Authorize: Send + Sync + 'static {
    fn authorize(&self, request: &Request) -> impl Future<Output = laravel::Result<bool>> + Send;

    /// The runs this request may see. Every run, unless the host says otherwise.
    fn scope(&self, request: &Request) -> impl Future<Output = laravel::Result<RunScope>> + Send {
        async { Ok(RunScope::All) }
    }
}

pub enum RunScope {
    All,
    /// Only runs with all of these attributes, such as `tenant = acme`.
    Attributes(Vec<(String, String)>),
}

The scope would be applied inside the reader, to every query: lists, counts, the overview, a run’s detail, and the MCP tools. A run outside the scope would be a 404, never a 403, so its existence isn’t confirmed. Attributes are the natural key because hosts already set them at start() and the store indexes them. It isn’t in the first release because enforcing it means every reader query, every handler, and the MCP server must thread it through, and a scope that is honoured in some places and not others is worse than none.

Known limits

  • One gate for everything. Until run scoping lands, anyone authorize lets in sees every run.
  • Redaction is a backstop. See what isn’t redacted. For data that must never be displayed, use SPINTO_PAYLOADS=hidden or keep it out of workflow payloads and attributes.
  • Error pages are the host’s. A refusal or failure is rendered by the host’s error handler. Spinto adds its headers, but the page’s content and any policy beyond frame-ancestors are the host’s.
  • The database is trusted. Spinto shows what the store’s tables say. Anyone who can write to those tables can make Spinto show anything, and redaction can only hide what it recognises.
  • Spinto shows what was recorded. The store keeps one record for a step that a killed worker was running and that ran again. Spinto’s observer shows the try that was cut short, but only from a process that registers Spinto’s provider, after Spinto was installed. Otherwise Spinto shows one execution where the side effect happened twice. See what the observer can’t see and recovery.