File tree Expand file tree Collapse file tree
csharp/ql/lib/semmle/code/csharp/security/auth Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import csharp
44import semmle.code.csharp.dataflow.flowsources.Remote
5+ import DataFlow as DF
6+ import TaintTracking as TT
57import ActionMethods
68
79/**
@@ -12,8 +14,6 @@ import ActionMethods
1214// Other queries check that there are authorization checks in place for admin methods.
1315private predicate needsChecks ( ActionMethod m ) { m .isEdit ( ) and not m .isAdmin ( ) }
1416
15- private Expr getParentExpr ( Expr ex ) { result .getAChildExpr ( ) = ex }
16-
1717/**
1818 * Holds if `m` has a parameter or access a remote flow source
1919 * that may indicate that it's used as the ID for some resource
@@ -23,9 +23,10 @@ private predicate hasIdParameter(ActionMethod m) {
2323 src .asParameter ( ) .getName ( ) .toLowerCase ( ) .matches ( [ "%id" , "%idx" ] )
2424 or
2525 // handle cases like `Request.QueryString["Id"]`
26- exists ( StringLiteral idStr |
26+ exists ( StringLiteral idStr , IndexerCall idx |
2727 idStr .getValue ( ) .toLowerCase ( ) .matches ( [ "%id" , "%idx" ] ) and
28- getParentExpr * ( src .asExpr ( ) ) = getParentExpr * ( idStr )
28+ TT:: localTaint ( src , DataFlow:: exprNode ( idx .getQualifier ( ) ) ) and
29+ DF:: localExprFlow ( idStr , idx .getArgument ( 0 ) )
2930 )
3031 )
3132}
You can’t perform that action at this time.
0 commit comments