|
10 | 10 | */ |
11 | 11 |
|
12 | 12 | import csharp |
| 13 | +import semmle.code.csharp.frameworks.system.Collections |
13 | 14 | import HashWithoutSalt::PathGraph |
14 | 15 |
|
15 | 16 | /** The C# class `Windows.Security.Cryptography.Core.HashAlgorithmProvider`. */ |
@@ -93,12 +94,17 @@ predicate hasAnotherHashCall(MethodCall mc) { |
93 | 94 |
|
94 | 95 | /** Holds if a password hash without salt is further processed in another method call. */ |
95 | 96 | predicate hasFurtherProcessing(MethodCall mc) { |
96 | | - mc.getTarget().fromLibrary() and |
97 | | - ( |
98 | | - mc.getTarget().hasFullyQualifiedName("System", "Array", "Copy") or // Array.Copy(passwordHash, 0, password.Length), 0, key, 0, keyLen); |
99 | | - mc.getTarget().hasFullyQualifiedName("System", "String", "Concat") or // string.Concat(passwordHash, saltkey) |
100 | | - mc.getTarget().hasFullyQualifiedName("System", "Buffer", "BlockCopy") or // Buffer.BlockCopy(passwordHash, 0, allBytes, 0, 20) |
101 | | - mc.getTarget().hasFullyQualifiedName("System", "String", "Format") // String.Format("{0}:{1}:{2}", username, salt, password) |
| 97 | + exists(Method m | m = mc.getTarget() and m.fromLibrary() | |
| 98 | + m.hasFullyQualifiedName("System", "Array", "Copy") // Array.Copy(passwordHash, 0, password.Length), 0, key, 0, keyLen); |
| 99 | + or |
| 100 | + m.hasFullyQualifiedName("System", "String", "Concat") // string.Concat(passwordHash, saltkey) |
| 101 | + or |
| 102 | + m.hasFullyQualifiedName("System", "Buffer", "BlockCopy") // Buffer.BlockCopy(passwordHash, 0, allBytes, 0, 20) |
| 103 | + or |
| 104 | + m.hasFullyQualifiedName("System", "String", "Format") // String.Format("{0}:{1}:{2}", username, salt, password) |
| 105 | + or |
| 106 | + m.getName() = "CopyTo" and |
| 107 | + m.getDeclaringType().getABaseType*() instanceof SystemCollectionsICollectionInterface // passBytes.CopyTo(rawSalted, 0); |
102 | 108 | ) |
103 | 109 | } |
104 | 110 |
|
|
0 commit comments