|
3 | 3 | import java |
4 | 4 | private import semmle.code.java.frameworks.OpenSaml |
5 | 5 | private import semmle.code.java.frameworks.Servlets |
6 | | -private import semmle.code.java.security.SensitiveActions |
7 | | -private import semmle.code.java.security.SensitiveApi |
8 | | -private import semmle.code.java.dataflow.TaintTracking |
9 | 6 | private import semmle.code.java.dataflow.ExternalFlow |
| 7 | +private import semmle.code.java.dataflow.TaintTracking |
| 8 | +private import semmle.code.java.security.Cookies |
10 | 9 | private import semmle.code.java.security.RandomQuery |
| 10 | +private import semmle.code.java.security.SensitiveActions |
| 11 | +private import semmle.code.java.security.SensitiveApi |
11 | 12 |
|
12 | 13 | /** |
13 | 14 | * A node representing a source of insecure randomness. |
@@ -49,16 +50,7 @@ abstract class InsecureRandomnessSink extends DataFlow::Node { } |
49 | 50 | * A node which sets the value of a cookie. |
50 | 51 | */ |
51 | 52 | private class CookieSink extends InsecureRandomnessSink { |
52 | | - CookieSink() { |
53 | | - exists(Call c | |
54 | | - c.(ClassInstanceExpr).getConstructedType() instanceof TypeCookie and |
55 | | - this.asExpr() = c.getArgument(1) |
56 | | - or |
57 | | - c.(MethodCall).getMethod().getDeclaringType() instanceof TypeCookie and |
58 | | - c.(MethodCall).getMethod().hasName("setValue") and |
59 | | - this.asExpr() = c.getArgument(0) |
60 | | - ) |
61 | | - } |
| 53 | + CookieSink() { this.asExpr() instanceof SetCookieValue } |
62 | 54 | } |
63 | 55 |
|
64 | 56 | private class SensitiveActionSink extends InsecureRandomnessSink { |
@@ -89,6 +81,17 @@ module InsecureRandomnessConfig implements DataFlow::ConfigSig { |
89 | 81 | n1.asExpr() = mc.getArgument(0) and |
90 | 82 | n2.asExpr() = mc |
91 | 83 | ) |
| 84 | + or |
| 85 | + // TODO: Once we have a default sanitizer for UUIDs, we can convert these to global summaries. |
| 86 | + exists(Call c | |
| 87 | + c.(ClassInstanceExpr).getConstructedType().hasQualifiedName("java.util", "UUID") and |
| 88 | + n1.asExpr() = c.getAnArgument() and |
| 89 | + n2.asExpr() = c |
| 90 | + or |
| 91 | + c.(MethodCall).getMethod().hasQualifiedName("java.util", "UUID", "toString") and |
| 92 | + n1.asExpr() = c.getQualifier() and |
| 93 | + n2.asExpr() = c |
| 94 | + ) |
92 | 95 | } |
93 | 96 | } |
94 | 97 |
|
|
0 commit comments