Tainted Format High

User input serves as the basis for print formatting, which may expose sensitive data. Attackers may be able to use this to gain information on how to trigger other attacks, or exploit weaknesses.

Detector ID
ruby/tainted-format@v1.0
Category
Common Weakness Enumeration (CWE) external icon
Tags
-

Noncompliant example

1class TaintedFormat < ActionController::Base
2  def unsanitized_input
3    # Noncompliant: untrusted user input is being used directly in format sting.
4    printf(params[:format], arg)
5  end
6end

Compliant example

1class TaintedFormat < ActionController::Base
2  def sanitized_input
3    # Compliant: User-input is not used to format output.
4    printf(params[:format])
5  end
6end