Skip to content

Commit 062a2ad

Browse files
committed
C#: Include exception property accesses in the exception information exposure query.
1 parent 197642c commit 062a2ad

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

csharp/ql/src/Security Features/CWE-209/ExceptionInformationExposure.ql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,17 @@ import ExceptionInformationExposure::PathGraph
2323
*/
2424
module ExceptionInformationExposureConfig implements DataFlow::ConfigSig {
2525
predicate isSource(DataFlow::Node source) {
26-
exists(Expr exceptionExpr |
26+
exists(Expr expr |
2727
// Writing an exception directly is bad
28-
source.asExpr() = exceptionExpr
28+
source.asExpr() = expr
29+
or
30+
// Writing a property of an exception is bad
31+
source.asExpr().(PropertyAccess).getQualifier() = expr
2932
|
3033
// Expr has type `System.Exception`.
31-
exceptionExpr.getType().(RefType).getABaseType*() instanceof SystemExceptionClass and
34+
expr.getType().(RefType).getABaseType*() instanceof SystemExceptionClass and
3235
// And is not within an exception callable.
33-
not exists(Callable enclosingCallable |
34-
enclosingCallable = exceptionExpr.getEnclosingCallable()
35-
|
36+
not exists(Callable enclosingCallable | enclosingCallable = expr.getEnclosingCallable() |
3637
enclosingCallable.getDeclaringType().getABaseType*() instanceof SystemExceptionClass
3738
)
3839
)

0 commit comments

Comments
 (0)