Laravel Rust Production Security Checklist

A security checklist for taking a Laravel Rust application to production. Covers environment and secrets, CORS and headers, sessions, authentication, the framework's unsafe escape hatches, deployment and dependency audits. Based on the Laravel Rust 0.x beta docs.

Progress
0 / 40 completed

Environment & Secrets

Set APP_ENV=production and APP_DEBUG=false

Laravel Rust runs as production when APP_ENV is unset, but set it explicitly. With APP_DEBUG=true, browsers receive a debug page with the error, its location, its chain of causes and the incoming request, and JSON errors include the type, file and line.

Generate a unique APP_KEY for production

The key encrypts cookies and sessions. Anyone who has it can read encrypted values, forge cookies and create signed URLs. Generate it on the server with ./example-app key:generate --show and never reuse the key from your machine or another environment.

Set APP_URL to the https:// address

APP_URL decides whether session cookies get the Secure flag and which hosts the app will answer in production. An http:// value behind a TLS proxy means cookies without Secure.

Mark every secret as required

Use env.require("STRIPE_KEY") or the required attribute so the application refuses to start when a secret is missing. A failed deploy is better than a handler that fails at run time.

Keep .env out of source control and out of images

The .env file is read from the app root and holds the encryption key and database password. Prefer real environment variables in production; they take precedence over .env.

Plan APP_KEY rotation with APP_PREVIOUS_KEYS

List retired keys, comma-separated, in APP_PREVIOUS_KEYS so existing cookies and encrypted values still decrypt after a rotation. Rotate immediately if a key may have leaked.

CORS, Headers & CSRF

Restrict CORS origins in src/config/cors.rs

By default any origin may call routes under api/*, with any method and header. Set origins to Allowed::only([...]) with your real front-end origins.

Never combine credentials: true with open origins

Credentials with an unrestricted origin list lets any website call your API as the signed-in user. If you enable credentials, list exact origins.

Add HSTS

The framework sets only X-Frame-Options: SAMEORIGIN and X-Content-Type-Options: nosniff. Add Strict-Transport-Security with max-age=31536000 in middleware or at your proxy.

Add a Content-Security-Policy with a nonce

No CSP is sent by default. Write the nonce middleware from the templates docs using view::use_csp_nonce, so Vite script and style tags carry the nonce, and send script-src with that nonce.

Add Referrer-Policy and Permissions-Policy

Neither is set by default. Use strict-origin-when-cross-origin and disable browser features you do not use, such as camera, microphone and geolocation.

Keep CSRF exclusions to signed webhooks only

PreventRequestForgery::new().except([...]) and without_middleware remove CSRF protection from routes. Exclude only routes called by other systems, and verify each with a signature.

Send the CSRF token on every state-changing request

Same-origin requests pass on the Sec-Fetch-Site header, but browsers do not send it over plain HTTP. Include csrf_field() in forms and the X-XSRF-TOKEN or X-CSRF-TOKEN header from JavaScript.

Sessions & Cookies

Set SESSION_DRIVER to database or redis explicitly

When SESSION_DRIVER is unset the driver falls back to cookie. With cookie sessions, a copied session cookie stays valid until it expires, so logging out cannot revoke it.

Decide on SESSION_ENCRYPT

The example configuration has SESSION_ENCRYPT=false, so session payloads are stored in plain text in your database or Redis. Enable it if sessions contain anything sensitive.

Verify the session cookie flags in production

Check the live response for Secure, HttpOnly and SameSite=Lax (or Strict). Secure is only set automatically when APP_URL is https.

Set cookies only inside the web group

Routes outside the web group, and global middleware, send cookies unencrypted and unsigned. Keep cookie-setting code on web routes and keep EncryptCookies::except to non-sensitive names.

Authentication & Authorisation

Rate limit login, registration and password reset

Nothing is throttled by default. Use the rate_limit::check, hit and clear pattern from the docs with Limit::per_minute(5), keyed on email and IP.

Rate limit API routes

Add Throttle::per_minute to API routes. Counters use the default cache store, so use the database or Redis store in production so limits hold across instances.

Hash API tokens and give them an expiry

There is no Sanctum equivalent. You write the request guard. Store a SHA-256 hash of each token, not the token, and implement expiry and revocation yourself.

Review every #[validate(anyone)]

Each input type must declare who may submit it, and anyone compiles. Confirm it appears only on genuinely public forms such as login and contact.

Scope every record lookup to the current user

The compiler cannot detect IDOR. Use policies and user.authorize, and add tests that request another user's records and expect 403 or 404.

Authenticate workflow resume routes

A workflow wait token is an identifier, not a secret. Anyone who can reach the route can resume the run unless you put authentication in front of it.

Code Escape Hatches

Search for AssertSqlSafe and native SQLx

Run grep -rn "AssertSqlSafe\|db::sqlx" src/. AssertSqlSafe embeds a string in SQL verbatim with no bindings. Every use must be built from constants or an allowlist, never request input.

Search templates for the safe filter and with_html

Output through {{ }} is escaped. The safe filter and with_html print raw HTML and are XSS if the content was not sanitised first.

Never use tojson inside a double-quoted attribute

tojson does not escape double quotes, so user data can break out of the attribute. Use the js filter for data in scripts.

Search React code for dangerouslySetInnerHTML

The default scaffold is Inertia with React. React escapes by default, and dangerouslySetInnerHTML is the bypass.

Validate uploads by content, and never store the client filename

Use the image or mimes rules, which inspect content; extensions checks only the filename. Store with .store(), which generates a random name, and never pass client_name to store_as.

Deployment & Network

Terminate TLS at a proxy and keep the binary private

The app listens on 127.0.0.1:8000 and does not handle TLS itself. Put a load balancer or reverse proxy in front, and if you set SERVER_HOST=0.0.0.0 in a container, make sure only the proxy can reach the port.

Configure trusted proxies precisely

Use middleware.trust_proxies with your load balancer's address range. Without it, request.ip() is the load balancer and all users share one rate-limit key. Avoid "*" when a CDN sits in front of a load balancer.

Confirm unknown hosts get a 400

In production the app answers only the APP_URL host and its subdomains. Send a request with a different Host header and check for 400. This is not enforced in local or testing.

Set proxy timeouts and body limits

Framework defaults are 2 MB bodies, 16 MB multipart and a 30-second handler timeout. Set matching or tighter limits and read timeouts at the proxy to protect against slow requests.

Restrict Reverb origins

Reverb accepts WebSocket connections from any origin by default. Set REVERB_APP_ALLOWED_ORIGINS to your application's origins.

Run migrations with --force as a deliberate deploy step

Migrations are compiled into the binary and production requires migrate --force. Run it once per deploy from the pipeline, not from application start-up on every instance.

Keep secrets out of URLs

OpenTelemetry tracing exports request paths and cache keys as written. Tokens in paths end up in your tracing backend.

Dependencies & Monitoring

Run cargo audit in CI and on a schedule

cargo audit checks Cargo.lock against the RustSec advisory database. Schedule it as well, because advisories are published against code that has not changed.

Run npm audit for the front end

The Inertia and React front end has its own dependency tree. Laravel Cloud's default build runs npm ci with auditing off, so do this in CI.

Track the framework version and read release notes

Laravel Rust is in beta and releases before 1.0 may change APIs and configuration. Stay on the latest 0.x release for security fixes and check each release for changed defaults.

Set up error tracking

Every response carries an X-Request-Id. Send errors to a tracker; Laravel Cloud's Issues feature does not capture Laravel Rust errors yet.

Scan the deployed application from outside

Check headers, CORS, cookie flags, TLS and exposed files on the live site after each deploy. StackShield's external scan covers these language-independent checks for Laravel Rust apps.

Frequently Asked Questions

Is Laravel Rust ready for production?

It is in beta. Laravel has said releases before 1.0 may include breaking changes and that it plans to call the framework stable after about six to eight weeks of feedback from its 1 December 2026 launch. It is reasonable for trials and low-risk services. For sensitive workloads, wait for 1.0 or do your own review.

What is the most important item on this checklist?

Restricting CORS and adding rate limits, because both are open by default and both are exploitable without any other mistake. After that, HSTS and a server-side session driver.

How is this different from the Laravel PHP production checklist?

There is no Telescope, Horizon or web-server document root to lock down, and APP_ENV defaults to production. In exchange you write API token authentication and rate limiting yourself, and you review the Rust-specific escape hatches such as AssertSqlSafe and the safe template filter.

Does this checklist apply to Laravel Go?

Most of the environment, CORS, header, session and deployment items apply to Laravel Go with different syntax. The compile-time items do not: in Go, form authorisation is optional and password hashes are hidden by a json:"-" struct tag, so those need extra review.

Related Guides

Related Fix Guides

Other Checklists

Download This Checklist as PDF

Get this checklist delivered to your inbox for easy reference.

Automate These Checks with StackShield

Stop running through checklists manually. StackShield continuously monitors your Laravel application for the security issues that matter most.

Start Free Trial