Do not support relative static resource paths
Closes gh-33687
This commit is contained in:
parent
e191c34078
commit
1a0b577bfc
|
@ -140,7 +140,7 @@ public abstract class ResourceHandlerUtils {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
|
||||
if (path.contains("../")) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(LogFormatUtils.formatValue(
|
||||
"Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]", -1, true));
|
||||
|
|
|
@ -687,6 +687,7 @@ class ResourceWebHandlerTests {
|
|||
|
||||
testResolvePathWithTraversal(method, "../testsecret/secret.txt");
|
||||
testResolvePathWithTraversal(method, "test/../../testsecret/secret.txt");
|
||||
testResolvePathWithTraversal(method, "/testsecret/test/../secret.txt");
|
||||
testResolvePathWithTraversal(method, ":/../../testsecret/secret.txt");
|
||||
|
||||
location = new UrlResource(getClass().getResource("./test/"));
|
||||
|
|
|
@ -140,7 +140,7 @@ public abstract class ResourceHandlerUtils {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (path.contains("..") && StringUtils.cleanPath(path).contains("../")) {
|
||||
if (path.contains("../")) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(LogFormatUtils.formatValue(
|
||||
"Path contains \"../\" after call to StringUtils#cleanPath: [" + path + "]", -1, true));
|
||||
|
|
|
@ -643,6 +643,7 @@ class ResourceHttpRequestHandlerTests {
|
|||
testInvalidPath("../testsecret/secret.txt");
|
||||
testInvalidPath("test/../../testsecret/secret.txt");
|
||||
testInvalidPath(":/../../testsecret/secret.txt");
|
||||
testInvalidPath("/testsecret/test/../secret.txt");
|
||||
|
||||
Resource location = new UrlResource(ResourceHttpRequestHandlerTests.class.getResource("./test/"));
|
||||
this.handler.setLocations(List.of(location));
|
||||
|
|
Loading…
Reference in New Issue