snalitham160042 (Community Member) asked a question.

I am getting cwe-93 error for below code snippet. please help me to resolve it.
HtmlEmail htmlEmail = null;
for (int i = 0; i < recipients.length; i++) {
htmlEmail.addTo(recipients[i].trim()); //here it is showing error
}

  • Anthony Fielding (Veracode)

    Hello,

    This is most likely because the scanner considers recipients[i] to contain potentially untrusted data, and could include CR and LF characters which might allow an attacker to inject arbitrary SMTP headers into the email. Consider using a suitable cleansing function from this list of cleansers: https://docs.veracode.com/r/Supported_Java_Cleansing_Functions, as demonstrated below (assuming the code is Java):

     

    ```

    HtmlEmail htmlEmail = null;

    for (int i = 0; i < recipients.length; i++) {

    htmlEmail.addTo(org.owasp.encoder.Encode.forJava(recipients[i].trim())); //here it is showing error

    }

    ```

    Expand Post

Topics (1)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.