Skip to content

Unscoped Find Method Call with User-Controlled Input

Description

The application is calling the `find(...)` method with user-controlled input, which may lead to Insecure Direct Object Reference (IDOR) behavior and allow users to read arbitrary records, potentially resulting in data breaches, exposure of personal information, account takeovers, and other security issues.

Examples

Insecure Code

ruby
User.find(params[:id])

Secure Code

ruby
current_user.accounts.find(params[:id])

Remediation

Scope queries to the current user or another appropriate scope that ensures users can only access data they are authorized to see, using ActiveRecord associations and scopes to limit the records that can be retrieved.

Rule Details

FieldValue
IDCODE-0535
CategoryAccessControl
SeverityMEDIUM
CWECWE-639
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
TagsInsecure Direct Object Reference, IDOR, ActiveRecord
OWASPA5:2017-Broken Access Control, A01:2021-Broken Access Control

References