File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
csharp/ql/src/Security Features Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ string GeneratePassword()
15
15
password = "mypassword" + BitConverter . ToInt32 ( randomBytes ) ;
16
16
}
17
17
18
- // GOOD: Password is generated using a cryptographically secure RNG
18
+ // BAD: Membership.GeneratePassword is generates a password with a bias
19
19
password = Membership . GeneratePassword ( 12 , 3 ) ;
20
20
21
21
return password ;
Original file line number Diff line number Diff line change @@ -59,6 +59,12 @@ module Random {
59
59
this .getExpr ( ) =
60
60
any ( MethodCall mc |
61
61
mc .getQualifier ( ) .getType ( ) .( RefType ) .hasQualifiedName ( "System" , "Random" )
62
+ or
63
+ // by using `% 87` on a `byte`, this function has a bias
64
+ mc .getQualifier ( )
65
+ .getType ( )
66
+ .( RefType )
67
+ .hasQualifiedName ( "System.Web.Security" , "GeneratePassword" )
62
68
)
63
69
}
64
70
}
You can’t perform that action at this time.
0 commit comments