Unsanitized user input in FTP request

Description

Using raw unsanitized input with FTP methods is bad practice. It could put your application at risk for code injection attacks, or lead to path traversal, by which attackers can gain access to resources outside of the intended scope

Remediations

❌ Do not form filenames or file paths for FTP from raw user input

Net::FTP.open("public/#{params["resource_name"]}.txt" do
# ...
end

❌ Do not pass raw user input as arguments to FTP methods

Net::FTP.open("example.txt", username: params[:user]) do
# ...
end

Resources

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=ruby_lang_ftp_using_user_input

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=ruby_lang_ftp_using_user_input