-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Insecure Certificate Validation. #17603
base: main
Are you sure you want to change the base?
C#: Insecure Certificate Validation. #17603
Conversation
QHelp previews: csharp/ql/src/experimental/CWE-295/InsecureCertificateValidation.qhelpUnsafe
|
csharp/ql/src/experimental/CWE-295/InsecureCertificateValidationQuery.qll
Fixed
Show fixed
Hide fixed
any(CertificateValidationProperty p).getAnAssignedValue(), | ||
any(SslStreamCreation yy).getServerCertificateValidationCallback() | ||
] and | ||
not e.getFile().getAbsolutePath().matches("example") |
Check notice
Code scanning / CodeQL
Use of regexp to match a set of constant string Note
11c5de4
to
0a82c34
Compare
any(CertificateValidationProperty p).getAnAssignedValue(), | ||
any(SslStreamCreation yy).getServerCertificateValidationCallback() | ||
] and | ||
not e.getFile().getAbsolutePath().matches("example") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@intrigus-lgtm : Here you can insert a "filter" that excludes sinks located in files matching specific names.
private predicate ignoreCertificateValidation(Guard guard, AbstractValue v) { | ||
guard = | ||
any(PropertyAccess access | | ||
access.getProperty().hasFullyQualifiedName("", "Settings", "IgnoreCertificateValidation") and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@intrigus-lgtm : This is somewhat similar to the Java implementation of flags that you mentioned. There doesn't exist similar library functionality for C# and thus we need to implement it here.
This is hardcoded specifically to the test flag Settings.IngoreCertificateValidation
just to illustrate, how this can be achieved. This code needs to be modified to the flags/conditions that fits the purposes of certificate validation.
/** | ||
* Holds if `c` always returns `true`. | ||
*/ | ||
private predicate alwaysReturnsTrue(Callable c) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@intrigus-lgtm : Maybe consider to improve this: Inspiration can be found in isExpressionAlwaysTrue
in JsonWebTokenHandlerLib.qll
0a82c34
to
18db405
Compare
No description provided.