FSouza026416 (Community Member) asked a question.

How can I fix an Insertion of Sensitive Information Into Sent Data vulnerability in C #.

I'm making an HTTPClient request, but Veracode identifies it as a vulnerability.

 

httpClient = GetHttpClient();

 

                httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));

                var userForm = new Dictionary<string, string>

                       {

                           { "user_id", $"{client.ID}" },

                           { "username", client.CPF },

                           { "user_domain", "SCD" },

                           { "password", password },

                           { "client_name", "scd" }

                       };

 

                HttpRequestMessage userRequest = new HttpRequestMessage(HttpMethod.Post, _configuration["User:CreateURL"]);

                userRequest.Headers.Add("Authorization", $"{token.token_type} {token.access_token}");

                userRequest.Content = new FormUrlEncodedContent(userForm);

 

                HttpStatusCode result = (await httpClient.SendAsync(userRequest)).StatusCode;

 

                if (result == HttpStatusCode.OK)

                {

                    var procRes = await _clientRepository.Update(client.ID, new ClientUpdateRequest(), true);

 

                    if (procRes.Result == -1)

                        throw new Exception(procRes.ErrorMessage);

                }

 

                return result;

 

 

How can I fix the code?

 

I thought about enabling TLS 1.2 or higher.

Validate the input fields.

 


VCode likes this.
  • Hi @FSouza026416 (Community Member)​ ,

     

    Veracode Static Analysis reports flaws of CWE-201: Insertion of Sensitive Information Into Sent Data when it can detect that sensitive data (such as from configuration) is going into outgoing network traffic (for example an email or HTTP request).

    The risk is that if sensitive data is incorrectly used this may lead to leakage of information.

    We recommend verifying:

    • That sensitive data is shared, information from configuration files may not be sensitive in nature, if so document this with a mitigation proposal: https://help.veracode.com/go/improve_mitigation
    • That the functionality does not use sensitive data inappropriately (for example 'debugging emails' containing a lot of sensitive information shared over email).
    • That sensitive information is sent over a secure connection (correctly configured TLS for HTTP) https://help.veracode.com/go/improve_mitigation
    • Ask your security team for requirements and recommendations on use of sensitive data.

     

    Thank you,

    Boy Baukema

    Expand Post

Topics (4)

No articles found
Loading

Ask the Community

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