Strong parameters and mass assignment
- params.require(:user).permit(...) lists that include :role, :admin, :account_id or :confirmed_at let users promote themselves or move records between accounts.
- params.permit! or to_unsafe_h passes everything through.
- Nested attributes (accepts_nested_attributes_for) can let a client create or modify associated records the UI never exposes.
- JSON APIs built with wrap_parameters accept fields under the root key and at the top level, so test both.
IDOR from unscoped finds
The most common serious Rails finding is a controller that does Project.find(params[:id]) instead of current_user.projects.find(params[:id]). Authentication with Devise is correct, the controller still serves any record. Pundit or CanCanCan only help if every action calls authorize. Testing means replaying requests with IDs that belong to another account.
SQL, rendering and configuration
- where("name = '#{params[:q]}'"), order(params[:sort]) and pluck with user input are injectable even though Active Record is safe when used with placeholders.
- render inline: or render with user-controlled template names leads to template injection or file disclosure.
- A leaked secret_key_base (from a public repo, an exposed .env or a debug page) lets attackers forge signed and encrypted cookies.
- redirect_to params[:return_to] is an open redirect unless restricted; Rails 7 can raise on external redirects via raise_on_open_redirects, which new apps enable by default.
A practical Rails test order
Start unauthenticated: look for exposed /rails/info routes left over from development, ActiveStorage blob URLs that never expire, and error pages. Then authenticate as an ordinary user and walk every resource with another account's IDs. Finish with admin namespaces and background-job dashboards such as Sidekiq Web, which are often mounted without a constraint.
Pointing Pentest-Swarm at a Rails app
Pentest-Swarm tests the Rails app as deployed, over HTTP. It does not parse your controllers; it discovers routes and tests how they behave.
- Run the owasp-top10 playbook against staging for the server-rendered app and api-security for JSON endpoints.
- Give it two test users' session cookies in separate runs with
--cookieso it can attempt cross-account access to records. - Mass-assignment tests add extra attributes to create and update requests and check whether the stored object changed.
- Use
--verifyso SQL injection reported against order or where clauses is confirmed by timing or differential oracles.
Where it falls short
A black-box test can show that a record from another account was returned, but not list every unscoped find in your code. Brakeman is a mature Rails SAST tool that flags permit!, string SQL and unsafe redirects, and it complements a live test well. Black-box runs also only cover the roles you provide accounts for.
Questions
Do strong parameters prevent mass assignment completely?
They prevent unlisted attributes from being assigned. They do not stop you from listing a sensitive attribute, so review permit lists for role, ownership and status fields.
Is Active Record safe from SQL injection?
Hash conditions and placeholders are parameterised. String interpolation in where, order, group, pluck or find_by_sql is not.
What should I give a tester for a Rails app?
A staging URL, at least two accounts per role, and a note of any admin namespace. Those let the test cover cross-account and cross-role access, where Rails bugs tend to be.