Do not use user input with FTP.

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