@@ -24,7 +24,7 @@ abstract class IterationsSource extends Expr { }
24
24
* A literal integer that is 1000 or less is a source of taint for iterations.
25
25
*/
26
26
class IntLiteralSource extends IterationsSource instanceof IntegerLiteralExpr {
27
- IntLiteralSource ( ) { this .getStringValue ( ) .toInt ( ) >= 1000 }
27
+ IntLiteralSource ( ) { this .getStringValue ( ) .toInt ( ) < 1000 }
28
28
}
29
29
30
30
/**
@@ -33,20 +33,13 @@ class IntLiteralSource extends IterationsSource instanceof IntegerLiteralExpr {
33
33
class InsufficientHashIterationsSink extends Expr {
34
34
InsufficientHashIterationsSink ( ) {
35
35
// `iterations` arg in `init` is a sink
36
- exists ( ClassOrStructDecl c , AbstractFunctionDecl f , CallExpr call |
37
- c .getFullName ( ) = "PKCS5. PBKDF1" and
36
+ exists ( ClassOrStructDecl c , AbstractFunctionDecl f , CallExpr call , int arg |
37
+ c .getFullName ( ) = [ " PBKDF1", "PBKDF2" ] and
38
38
c .getAMember ( ) = f and
39
39
f .getName ( ) .matches ( "init(%iterations:%" ) and
40
40
call .getStaticTarget ( ) = f and
41
- call .getArgument ( 2 ) .getExpr ( ) = this
42
- )
43
- or
44
- exists ( ClassOrStructDecl c , AbstractFunctionDecl f , CallExpr call |
45
- c .getFullName ( ) = "PKCS5.PBKDF2" and
46
- c .getAMember ( ) = f and
47
- f .getName ( ) .matches ( "init(%iterations:%" ) and
48
- call .getStaticTarget ( ) = f and
49
- call .getArgument ( 3 ) .getExpr ( ) = this
41
+ f .getParam ( pragma [ only_bind_into ] ( arg ) ) .getName ( ) = "iterations" and
42
+ call .getArgument ( pragma [ only_bind_into ] ( arg ) ) .getExpr ( ) = this
50
43
)
51
44
}
52
45
}
71
64
DataFlow:: PathNode sinkNode
72
65
where config .hasFlowPath ( sourceNode , sinkNode )
73
66
select sinkNode .getNode ( ) , sourceNode , sinkNode ,
74
- "The hash function '" + sinkNode .getNode ( ) .toString ( ) +
75
- "' has been initialized with an insufficient number of iterations from $@." , sourceNode ,
76
- sourceNode .getNode ( ) .toString ( )
67
+ "The variable '" + sinkNode .getNode ( ) .toString ( ) +
68
+ "' is an insufficient number of iterations, which is not secure for hash functions." ,
69
+ sourceNode , sourceNode .getNode ( ) .toString ( )
0 commit comments