Rails Security Checklist (a Practical Audit You Can Run Before Launch)

By Bruce Hansen, Off the Rails Software Consulting · Updated · 5 min read

Ruby on Rails gives you strong defaults — CSRF protection, encrypted cookies, SQL binding helpers, has_secure_password. Most Rails incidents I see in small products are not exotic framework bugs; they are skipped defaults, string-built queries, and authorization that lives only in the UI. This checklist is for founders and Rails developers preparing to launch or raise. It follows the spirit of the official Rails Security Guide and the OWASP Top 10:2025. It is not a penetration test or a compliance certification.

How to use this checklist

  • Work from a tagged commit. Note the SHA in your notes.
  • Prefer staging with dummy data. Do not paste production secrets into chat tools.
  • Mark each item: Pass / Fail / N/A. Failures need an owner and a date.
  • Run free tools for coverage, then verify by hand — scanners miss business-logic gaps and invent noise.

Suggested tools: Brakeman, bundler-audit, gitleaks, Trivy or bundle outdated, and your test suite.

1. Dependencies and supply chain (OWASP A03:2025)

  • bundle-audit check is clean, or every remaining advisory has a written accept/mitigate note.
  • Rails and Rack are on a supported series; you know your EOL date.
  • CI fails on new High/Critical advisories (bundler-audit or Dependabot).
  • No vendored copies of old JS/CSS with known XSS helpers you do not need.

2. Secrets and credentials

  • secret_key_base comes from credentials or ENV, never a committed literal.
  • config/master.key and .env are not in git; history has been checked with gitleaks.
  • filter_parameters includes password, token, secret, ssn, etc. (guide).
  • Active Storage / cloud credentials are environment-specific.

3. Sessions, cookies, and CSRF

  • protect_from_forgery is enabled for HTML controllers (Rails default — do not comment it out).
  • config.force_ssl = true in production (HSTS).
  • Session cookie flags are sane (httponly, secure, appropriate same_site).
  • Login calls reset_session (or Devise's defaults) to mitigate fixation.
  • You are not stuffing balances or roles into a cookie you later trust without a server check.

4. Authentication

  • Passwords use bcrypt/argon2 (has_secure_password or Devise), not MD5/SHA1.
  • Password reset tokens are random, single-use, time-limited; email change requires re-auth.
  • Login and reset endpoints are rate-limited (rate_limit in Rails 8 or Rack::Attack).
  • Error messages do not reveal whether an email is registered.
  • "Remember me" tokens rotate and can be revoked.

5. Authorization and tenancy (OWASP A01:2025 Broken Access Control)

This is the section that pays the rent.

  • Every resource lookup is scoped: current_user.projects.find(params[:id]), not Project.find(params[:id]) followed by hope.
  • Multi-tenant apps enforce tenant on queries, jobs, exports, search, and files.
  • Admin actions check role on the server; params[:admin] is never writable by end users.
  • APIs use the same authorization as HTML (no "JSON is internal" fantasy).
  • Background jobs re-check authorization or run with explicit system principals.

6. Injection and unsafe sinks

  • No string interpolation into SQL (where("id = '#{params[:id]}'")). Use where(id: params[:id]) or bound ?.
  • No params[:class].constantize / params[:type].constantize without a strict allowlist.
  • No Marshal.load / YAML.load on user input (use safe_load with permitted classes only when you must).
  • Shell calls use argv form: system("cp", src, dst), never interpolated strings.
  • open("| …") and similar Kernel footguns are absent.
  • Rendered HTML escapes by default; raw / html_safe are justified and rare.

7. Files, redirects, SSRF

  • Uploads validate type/size; stored outside the web root or via Active Storage with private ACLs.
  • Downloads do not concatenate user paths (send_file params[:path]).
  • redirect_to params[:url] is banned; use allowlists or only relative paths you control.
  • Server-side HTTP to user-supplied URLs (previews, webhooks) is allowlisted and blocked from link-local/metadata IPs.

8. Headers, hosting, and config

  • Default Rails security headers left on or tightened (guide §9).
  • Content Security Policy configured for your asset host; prefer nonces over unsafe-inline when you can.
  • config.hosts set in production.
  • Detailed exceptions and verbose logging off in production.
  • Preview/staging apps do not share production databases.

9. Mailers, webhooks, and jobs

  • Inbound webhooks verify signatures before side effects.
  • Outbound mailers do not reflect unsanitized HTML into inboxes.
  • Sidekiq/Solid Queue dashboards are not public.

10. Tests you should have

  • Request specs for IDOR on each sensitive resource (user A cannot read user B).
  • CSRF examples for sensitive POSTs if you customize APIs.
  • Brakeman in CI with a checked-in baseline so new High confidence warnings fail the build.

Brakeman, bundler-audit, and manual review

Brakeman is excellent at classic Rails sinks (SQL, XSS, dangerous send, mass assignment). It does not understand your product's tenancy rules. bundler-audit does not know whether a vulnerable code path is reachable. Scanners help with coverage — still verify every finding yourself or with an engineer you trust.

Sample: what a checklist finds in a training app

Against the public OWASP RailsGoat training application, this style of review surfaces intentional issues such as SQL string interpolation in account update, Marshal.load on password reset, commented-out CSRF protection, committed secret_key_base, and MD5 password hashing. Those are teaching bugs — and they look a lot like the bugs that slip into rushed production apps. See our sample Ship-Ready Review report.

When to go beyond a checklist

You need a formal penetration test when a contract, regulator, or enterprise security questionnaire demands it. You need a senior engineer review when you want the common Rails mistakes caught before launch by someone who can read your app and open a PR.

OTR's Ship-Ready Review is the second thing: human-verified findings, fix-first report, clear statement that it is not a penetration test or SOC 2 audit. Quick Check: $490.

Further reading

A one-sprint hardening plan

If your checklist is mostly red, do not boil the ocean. A realistic one-sprint order for a small Rails SaaS:

  1. Stop the bleeding: rotate any committed secrets; force SSL; re-enable CSRF; remove permit(:admin)-style mass assignment.
  2. Scope the queries: add request specs for the top five models customers care about; change Model.find to association finds.
  3. Auth hygiene: bcrypt, reset tokens, rate limits, generic errors.
  4. Scanner CI: Brakeman + bundler-audit on main.
  5. Schedule the rest: CSP tighten, dependency train, admin IP allowlists if you need them.

Ship the sprint with a short "what we fixed / what remains" note. That note is gold in a fundraising data room even though it is not a SOC 2 report.

Want a second set of eyes before launch?

A Ship-Ready Review is a senior engineer's pre-launch code and security review with human-verified findings. Quick Check $490. It is not a penetration test or compliance audit.

Book a Free 30-Minute Consult

Tell me what you're building or what's stuck. I'll reply with next steps, usually within one business day.

Get In Touch

Email
hello@offtherails.pro
Phone
(385) 743-8966
Location
Salt Lake City, UT · Remote across the US

Why Choose Me?

  • 10 years shipping production software
  • 5 long-term fractional clients, most for 2+ years
  • AI agents, MCP servers, Rails + React
  • Based in Salt Lake City, working remotely US-wide

What happens next

  1. I read your message and reply within one business day.
  2. We schedule a free 30-minute consult call.
  3. You get a clear recommendation and next steps, no obligation.

Prefer email? hello@offtherails.pro