Skip to content

Path Traversal in Render Function

Description

The application dynamically constructs file or path information with user input when calling the `render` function, allowing end-users to request arbitrary local files and potentially leak sensitive information.

Examples

Insecure Code

ruby
render params[:page]

Secure Code

ruby
valid_pages = ['home', 'about_us', 'contact']; render params[:page] if valid_pages.include?(params[:page])

Remediation

Avoid direct user input, use `File.basename` to normalize user input, and implement an allow-list of permitted files or directories to check user input against.

Rule Details

FieldValue
IDCODE-0532
CategoryAccessControl
SeverityMEDIUM
CWECWE-22
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
TagsPath Traversal, Local File Inclusion
OWASPA5:2017-Broken Access Control, A01:2021-Broken Access Control

References