
JGe356144 (Community Member) asked a question.
I have an application that need to send out email to the email address configured in web.config file. The code snippet is like following:
protected void SendEmail(string strPDFName)
{
using (SmtpClient client = new SmtpClient())
{
using (MailMessage message = new MailMessage())
{
message.From = new MailAddress(ConfigurationManager.AppSettings["FromEmail"].ToString());
message.To.Add(new MailAddress(ConfigurationManager.AppSettings["ToEmail"].ToString()));
message.Subject = "Application";
message.Body = "This is message body.";
client.Send(message);
}
}
}
VeraCode scan reports CWE 201 issue on line "client.Send(message);". In the flaw description, VeraCode indicates it is because of the ConfigurationManager.get_AppSettings call. The email "from" address and "to" address are from web.config file. It does not make sense to report it as a flaw.
.png)
Hello @JGe356144 (Community Member) ,
Thanks for your question. We report this flaw when we observe potentially sensitive information from the application configuration leaving the application. In this case this flaw is a candidate for a "Mitigation By Design" mitigation proposal, since you have identified this data to not be sensitive.
Kind regards,
Anthony Fielding
If the data is sensitive how to fix this
Can we use any encryption here