Skip to content

Cross-site request forgery (CSRF) protection missing

Description

The controller does not enable cross-site request forgery protections using `protect_from_forgery`. This vulnerability can allow attackers to submit unauthorized requests on behalf of authenticated users, potentially leading to unauthorized actions being performed.

Examples

Insecure Code

ruby
class YourController < ApplicationController
  # Your controller actions here
end

Secure Code

ruby
class YourController < ApplicationController
  protect_from_forgery with: :exception
  # Your controller actions here
end

Remediation

Add `protect_from_forgery with: :exception` to your controller class.

Rule Details

FieldValue
IDCODE-0523
CategoryWeb
SeverityMEDIUM
CWECWE-352
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagscsrf, rails
OWASPA5:2017-Broken Access Control, A01:2021-Broken Access Control

References