Unsanitized user input in OS command

Description

Applications should not execute OS commands that are formed from user input. This rule checks for external commands containing user-supplied data.

Remediations

❌ Avoid using user input when executing commands:

system(params[:command])

✅ Use user input indirectly when executing commands:

command =
case params[:action]
when "option1"
"command1"
when "option2"
"command2"
end

system(command)

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_exec_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_exec_using_user_input