Skip to content

Commit 2629369

Browse files
committed
Improve additional flow step for Host field
1 parent c006777 commit 2629369

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

go/ql/lib/semmle/go/security/RequestForgery.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ module RequestForgery {
2727

2828
predicate isAdditionalFlowStep(DataFlow::Node pred, DataFlow::Node succ) {
2929
// propagate to a URL when its host is assigned to
30-
exists(Write w, Field f, SsaWithFields v | f.hasQualifiedName("net/url", "URL", "Host") |
31-
w.writesFieldPreUpdate(v.getAUse(), f, pred) and
32-
succ = v.getAUse()
30+
exists(Write w, Field f | f.hasQualifiedName("net/url", "URL", "Host") |
31+
w.writesField(succ, f, pred)
3332
)
3433
}
3534

go/ql/test/query-tests/Security/CWE-918/RequestForgery.expected

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ edges
3737
| tst.go:10:13:10:35 | call to FormValue | tst.go:38:11:38:29 | ...+... | provenance | Src:MaD:1 |
3838
| tst.go:10:13:10:35 | call to FormValue | tst.go:40:11:40:40 | ...+... | provenance | Src:MaD:1 |
3939
| tst.go:10:13:10:35 | call to FormValue | tst.go:47:11:47:18 | tainted2 | provenance | Src:MaD:1 |
40-
| tst.go:47:2:47:2 | u | tst.go:48:11:48:11 | u | provenance | |
41-
| tst.go:47:11:47:18 | tainted2 | tst.go:47:2:47:2 | u | provenance | Config |
42-
| tst.go:47:11:47:18 | tainted2 | tst.go:48:11:48:11 | u | provenance | Config |
40+
| tst.go:47:2:47:2 | implicit dereference [postupdate] | tst.go:47:2:47:2 | u [postupdate] | provenance | |
41+
| tst.go:47:2:47:2 | u [postupdate] | tst.go:48:11:48:11 | u | provenance | |
42+
| tst.go:47:11:47:18 | tainted2 | tst.go:47:2:47:2 | implicit dereference [postupdate] | provenance | Config |
43+
| tst.go:47:11:47:18 | tainted2 | tst.go:47:2:47:2 | u [postupdate] | provenance | Config |
4344
| tst.go:48:11:48:11 | u | tst.go:48:11:48:20 | call to String | provenance | MaD:3 |
4445
| websocket.go:60:21:60:31 | call to Referer | websocket.go:65:27:65:40 | untrustedInput | provenance | Src:MaD:2 |
4546
| websocket.go:74:21:74:31 | call to Referer | websocket.go:78:36:78:49 | untrustedInput | provenance | Src:MaD:2 |
@@ -70,7 +71,8 @@ nodes
7071
| tst.go:36:18:36:24 | tainted | semmle.label | tainted |
7172
| tst.go:38:11:38:29 | ...+... | semmle.label | ...+... |
7273
| tst.go:40:11:40:40 | ...+... | semmle.label | ...+... |
73-
| tst.go:47:2:47:2 | u | semmle.label | u |
74+
| tst.go:47:2:47:2 | implicit dereference [postupdate] | semmle.label | implicit dereference [postupdate] |
75+
| tst.go:47:2:47:2 | u [postupdate] | semmle.label | u [postupdate] |
7476
| tst.go:47:11:47:18 | tainted2 | semmle.label | tainted2 |
7577
| tst.go:48:11:48:11 | u | semmle.label | u |
7678
| tst.go:48:11:48:20 | call to String | semmle.label | call to String |

0 commit comments

Comments
 (0)