Skip to content

Instantly share code, notes, and snippets.

@saghaulor
Created April 19, 2019 17:59
Show Gist options
  • Save saghaulor/e57e28d627ef399529937e979c3ebfe6 to your computer and use it in GitHub Desktop.
Save saghaulor/e57e28d627ef399529937e979c3ebfe6 to your computer and use it in GitHub Desktop.
A sample controller and route demonstrating CSRF vulnerabilities
class AcountsController < ApplicationController
before_action :set_current_user
def transfer
from_account = Account.find(owner_id: current_user.id)
to_account = Account.find(id: params(:to_id)
AccountTransferService.call(from: from_account, to: to_account, amount: params(:amount))
end
end
Rails.application.routes.draw do
match "accounts/transfer", to: "accounts#transfer", via [:get, :post]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment