Unsanitized user input in format string
- Rule ID: javascript_lang_format_string_using_user_input
- Languages: javascript
- Source: format_string_using_user_input.yml
Description
Including user input directly in a format string can lead to security vulnerabilities. This issue arises when an attacker manipulates the format specifiers in the user input, resulting in misleading or fabricated messages.
Remediations
- Do not incorporate user input directly into format strings. This approach can be exploited by attackers to manipulate output or execute malicious code.
console.log(`The value was ${req.params.value}`); // unsafe
- Do use a literal format string and pass user input as additional arguments. This method safely incorporates user input without exposing the application to format string vulnerabilities.
console.log("The value was %s", req.params.value);
Associated CWE
Configuration
To skip this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --skip-rule=javascript_lang_format_string_using_user_input
To run only this rule during a scan, use the following flag
bearer scan /path/to/your-project/ --only-rule=javascript_lang_format_string_using_user_input