Skip to content

Commit 1db3132

Browse files
committed
Java: Model Spring reactive WebClient.uri as a request forgery sink
1 parent 11e75c1 commit 1db3132

5 files changed

Lines changed: 383 additions & 340 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `uri` method of Spring's reactive `WebClient` is now considered a request forgery sink. Previously only the `create` and `baseUrl` methods were considered. This may lead to more alerts for the query `java/ssrf` (Server-side request forgery).
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# Copyright © 2026 Apple Inc.
12
extensions:
23
- addsTo:
34
pack: codeql/java-all
45
extensible: sinkModel
56
data:
67
- ["org.springframework.web.reactive.function.client", "WebClient", False, "create", "", "", "Argument[0]", "request-forgery", "manual"]
78
- ["org.springframework.web.reactive.function.client", "WebClient$Builder", False, "baseUrl", "", "", "Argument[0]", "request-forgery", "manual"]
9+
- ["org.springframework.web.reactive.function.client", "WebClient$UriSpec", True, "uri", "", "", "Argument[0]", "request-forgery", "manual"]

java/ql/test/query-tests/security/CWE-918/ReactiveWebClientSSRF.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,27 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
4646
// Ignore
4747
}
4848
}
49+
50+
protected void doPut(HttpServletRequest request, HttpServletResponse response)
51+
throws ServletException, IOException {
52+
try {
53+
WebClient webClient = WebClient.create("https://example.com");
54+
55+
String p = request.getParameter("uri"); // $ Source
56+
webClient.get()
57+
.uri(p) // $ Alert
58+
.retrieve()
59+
.bodyToMono(String.class)
60+
.block();
61+
62+
String p2 = request.getParameter("uri"); // $ Source
63+
webClient.get()
64+
.uri(java.net.URI.create("https://example.com" + p2)) // $ Alert
65+
.retrieve()
66+
.bodyToMono(String.class)
67+
.block();
68+
} catch (Exception e) {
69+
// Ignore
70+
}
71+
}
4972
}

0 commit comments

Comments
 (0)