CRLF 序列的不当中和 ('CRLF Injection') (CWE ID 93)

Improper Neutralization of CRLF Sequences ('CRLF Injection') (CWE ID 93)

在 Veracode 报告中,我在某些 java 文件中收到错误 CWE 93。在静态扫描实例中,一些代码是

  1. MimeMessage msg = new MimeMessage(session); msg.setFrom(new InternetAddress(msmtpfrom));

2.msg.setRecipients(Message.RecipientType.TO, address);

我该如何解决?

提前致谢

只需将字符串变量(如 msmtpfrom、地址)中出现的 CRLF 替换为空字符串 ("")。查看具有相关答案的类似问题: