Skip to content

Commit bb2083d

Browse files
committed
Remove database directory and add WebCacheDeceptionLib.qll
1 parent bc81201 commit bb2083d

File tree

6 files changed

+79
-60
lines changed

6 files changed

+79
-60
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
edges
2+
nodes
3+
subpaths
4+
#select
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* @name Web Cache Deception
3-
* @description A caching system has been detected on the application and is vulnerable to web cache deception. By manipulating the URL it is possible to force the application to cache pages that are only accessible by an authenticated user. Once cached, these pages can be accessed by an unauthenticated user.
3+
* @description A caching system has been detected on the application and is vulnerable to web cache deception on Gofiber. By manipulating the URL it is possible to force the application to cache pages that are only accessible by an authenticated user. Once cached, these pages can be accessed by an unauthenticated user.
44
* @kind problem
55
* @problem.severity error
66
* @security-severity 9
@@ -11,17 +11,10 @@
1111
*/
1212

1313
import go
14+
import WebCacheDeceptionLib
15+
import WebCacheDeception::Flow::PathGraph
1416

15-
from
16-
DataFlow::CallNode httpHandleFuncCall, DataFlow::ReadNode rn, Http::HeaderWrite::Range hw,
17-
DeclaredFunction f
18-
where
19-
httpHandleFuncCall.getTarget().hasQualifiedName("net/http", "HandleFunc") and
20-
httpHandleFuncCall.getArgument(0).getStringValue().matches("%/") and
21-
httpHandleFuncCall.getArgument(1) = rn and
22-
rn.reads(f) and
23-
f.getParameter(0) = hw.getResponseWriter() and
24-
hw.getHeaderName() = "cache-control"
25-
select httpHandleFuncCall.getArgument(0),
26-
"Wildcard Endpoint used with " + httpHandleFuncCall.getArgument(0) + " and '" + hw.getHeaderName()
27-
+ "' Header is used"
17+
from WebCacheDeception::Flow::PathNode source, WebCacheDeception::Flow::PathNode sink
18+
where WebCacheDeception::Flow::flowPath(source, sink)
19+
select sink.getNode(), source, sink, "$@ is used as wildcard endpoint.", source.getNode(),
20+
"Web Cache Deception"

go/ql/src/experimental/CWE-525/WebCacheDeceptionFiber.ql

Lines changed: 0 additions & 22 deletions
This file was deleted.

go/ql/src/experimental/CWE-525/WebCacheDeceptionGoChi.expected

Lines changed: 0 additions & 1 deletion
This file was deleted.

go/ql/src/experimental/CWE-525/WebCacheDeceptionGoChi.ql

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import go
2+
import StringOps
3+
4+
module WebCacheDeception {
5+
abstract class Source extends DataFlow::Node { }
6+
7+
abstract class Sink extends DataFlow::Node { }
8+
9+
private class GoNetHTTP extends Sink {
10+
GoNetHTTP() {
11+
exists(
12+
DataFlow::CallNode m, DataFlow::ReadNode rn, Http::HeaderWrite::Range hw, DeclaredFunction f
13+
|
14+
m.getTarget().hasQualifiedName("net/http", "HandleFunc") and
15+
m.getArgument(0).getStringValue().matches("%/") and
16+
m.getArgument(1) = rn and
17+
rn.reads(f) and
18+
f.getParameter(0) = hw.getResponseWriter() and
19+
hw.getHeaderName() = "cache-control" and
20+
this = m.getArgument(0)
21+
)
22+
}
23+
}
24+
25+
private class GoFiber extends Sink {
26+
GoFiber() {
27+
exists(ImportSpec i |
28+
i.getPath() = "github.com/gofiber/fiber" or
29+
i.getPath() = "github.com/gofiber/fiber/v2"
30+
|
31+
exists(DataFlow::MethodCallNode m |
32+
m.getCall().getArgument(0).toString().matches("%/*%") and
33+
this = m.getArgument(0)
34+
)
35+
)
36+
}
37+
}
38+
39+
private class GoChi extends Sink {
40+
GoChi() {
41+
exists(ImportSpec i |
42+
i.getPath() = "github.com/go-chi/chi/v5" or
43+
i.getPath() = "github.com/go-chi/chi/v5/middleware"
44+
|
45+
exists(DataFlow::MethodCallNode m |
46+
m.getCall().getArgument(0).toString().matches("%/*%") and
47+
this = m.getArgument(0)
48+
)
49+
)
50+
}
51+
}
52+
53+
deprecated class Configuration extends TaintTracking::Configuration {
54+
Configuration() { this = "Web Cache Deception" }
55+
56+
override predicate isSource(DataFlow::Node source) { source instanceof Source }
57+
58+
override predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
59+
}
60+
61+
private module Config implements DataFlow::ConfigSig {
62+
predicate isSource(DataFlow::Node source) { source instanceof Source }
63+
64+
predicate isSink(DataFlow::Node sink) { sink instanceof Sink }
65+
}
66+
67+
module Flow = TaintTracking::Global<Config>;
68+
}

0 commit comments

Comments
 (0)