Commit 0e1cc3c
Block redirect-based SSRF bypass in Swagger imports (#6320)
* goalx: snapshot before shenyu-analysis
* Block redirect-based SSRF bypass in Swagger imports
Swagger import requests were validating only the initial URL while the
shared OkHttp client silently followed redirects. Disabling redirect
following at the HTTP utility layer prevents callers from reaching
unvalidated internal targets through 3xx responses.
Constraint: Keep the fix in the shared HTTP client so all callers inherit the safer default
Rejected: Add Swagger-specific redirect validation only | leaves other HttpUtils callers exposed to the same redirect class
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Do not re-enable redirect following without validating every redirect target before the request is sent
Tested: mvn -pl shenyu-admin -Dtest=HttpUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite and end-to-end Swagger import against live remote servers
* Scope redirect blocking to Swagger import requests
This follow-up preserves the default redirect-following behavior of the
shared HttpUtils client and moves no-redirect handling onto the
Swagger import path only. The regression tests now cover both the
explicit no-redirect mode and the original default behavior.
Constraint: Avoid changing shared HTTP client semantics for unrelated admin features
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: SSRF hardening for one feature should not silently redefine shared client behavior without an explicit compatibility review
Tested: mvn -pl shenyu-admin -Dtest=HttpUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite
* Replace redirect test literals with named constants
This follow-up removes repeated path, status, and body literals from the
HttpUtils redirect tests so the cases read in terms of the HTTP behavior
being verified instead of raw values.
Constraint: Keep the cleanup test-only and local to the redirect SSRF fix
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Name repeated HTTP semantics in tests when they describe protocol behavior rather than incidental values
Tested: mvn -pl shenyu-admin -Dtest=HttpUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite
* Fix redirect test URL construction
The no-redirect regression test was composing redirect URLs from a base
string that already ended with a slash, which produced invalid host/port
combinations in CI. This follow-up switches the test to a dedicated host
prefix constant so the dynamically allocated port is embedded correctly.
Constraint: Keep the fix limited to the test harness; production redirect handling is unchanged
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Avoid composing dynamic host:port URLs from request path fixtures that carry trailing slash semantics
Tested: mvn -pl shenyu-admin -Dtest=HttpUtilsTest,SwaggerImportServiceTest test
Not-tested: Full shenyu-admin test suite
---------
Co-authored-by: moremind <hefengen@apache.org>1 parent aceaf5b commit 0e1cc3c
3 files changed
Lines changed: 101 additions & 3 deletions
File tree
- shenyu-admin/src
- main/java/org/apache/shenyu/admin
- service/impl
- utils
- test/java/org/apache/shenyu/admin/utils
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
328 | 344 | | |
329 | 345 | | |
330 | 346 | | |
331 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
332 | 352 | | |
333 | 353 | | |
334 | 354 | | |
| |||
Lines changed: 78 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
| 32 | + | |
28 | 33 | | |
29 | 34 | | |
30 | 35 | | |
| |||
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
| |||
113 | 130 | | |
114 | 131 | | |
115 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
116 | 194 | | |
0 commit comments