Why it matters
Anyone on the network path can impersonate the server and read or change the traffic.
How to fix it
Remove the callback so the platform validates the chain. To trust a private CA, validate against that CA in the callback rather than returning true.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
using System.Net.Http;
public static class Clients
{
public static HttpClient Create()
{
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true;
return new HttpClient(handler);
}
}using System.Net.Http;
public static class Clients
{
public static HttpClient Create()
{
var handler = new HttpClientHandler();
return new HttpClient(handler);
}
}What TrustIvan reads
Runs on repository scans of C# source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Weak PBKDF2 iterations (C#)
C#Severity: Medium
trustivan-csharp-weak-pbkdf2-iterations - Insecure TLS protocol (C#)
C#Severity: Medium
trustivan-csharp-insecure-tls-protocol - Weak RSA key (C#)
C#Severity: Medium
trustivan-csharp-weak-rsa-key - Hardcoded password connection string (C#)
C#Severity: High
trustivan-csharp-hardcoded-password-connection-string - Insecure random secret (C#)
C#Severity: Medium
trustivan-csharp-insecure-random-secret - JWT hardcoded secret (C#)
C#Severity: High
trustivan-csharp-jwt-hardcoded-secret
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation