
FSouza026416 (Community Member) asked a question.
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.
.png)
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:
Thank you,
Boy Baukema