Commit bec32f3
authored
Align SSRF URL validation with OkHttp parsing (#6321)
* goalx: snapshot before shenyu-analysis
* Align SSRF URL validation with the OkHttp request target
The Swagger import SSRF guard was parsing URLs with java.net.URL while
the actual request path was interpreted by OkHttp. This mismatch let
parser-confusion payloads pass validation but resolve to internal
hosts during request execution. The fix validates against OkHttp's
HttpUrl semantics and adds regression coverage for the known payload.
Constraint: Keep validation semantics aligned with the HTTP client actually used for outbound requests
Rejected: Add ad-hoc blacklist checks for backslash or @ combinations | brittle and would miss future parser edge cases
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Any future SSRF validation must use the same parser and canonicalization rules as the outbound HTTP client
Tested: mvn -pl shenyu-admin -Dtest=UrlSecurityUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite and live end-to-end Swagger import against a running admin instance
* Name parser-confusion SSRF payload in tests
This follow-up replaces the repeated parser-confusion exploit string with
a single named constant in the SSRF regression tests.
Constraint: Limit the cleanup to the dedicated parser-confusion test surface
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep security regression payloads named when reused across multiple assertions
Tested: mvn -pl shenyu-admin -Dtest=UrlSecurityUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite
* Name allowed URL schemes in SSRF validation
This follow-up replaces the raw http/https string checks in
UrlSecurityUtils with named protocol constants.
Constraint: Keep the cleanup local to the SSRF validation utility without changing behavior
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Protocol allowlists should use named constants when shared across security-sensitive validation logic
Tested: mvn -pl shenyu-admin -Dtest=UrlSecurityUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite1 parent 2c44e7e commit bec32f3
4 files changed
Lines changed: 68 additions & 15 deletions
File tree
- shenyu-admin/src
- main/java/org/apache/shenyu/admin/utils
- test/java/org/apache/shenyu/admin
- service
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
Lines changed: 17 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | | - | |
22 | | - | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
| |||
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | | - | |
61 | | - | |
| 60 | + | |
62 | 61 | | |
63 | | - | |
64 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
65 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
66 | 69 | | |
67 | 70 | | |
68 | 71 | | |
| |||
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
54 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments