【问题标题】:Directory traversal issue occurs while using spring boot 1.5.8 ,Spring 4.3.21.RELEASE, tomcat 8.5.35使用spring boot 1.5.8、Spring 4.3.21.RELEASE、tomcat 8.5.35时出现目录遍历问题
【发布时间】:2021-09-27 00:52:00
【问题描述】:

在使用 1.5.8 版本的 Spring-boot Web 应用程序时,我面临目录遍历问题,仅在 .war 扩展包中。

项目结构。

app.war-->
      ->css
      ->images
      ->js
      ->META-INF
      ->org-
            ->springframework->boot->loader->jar->Bytes.class
      ->WEB-INF

in which directly able to access. 
http://localhost:3737/app/org/springframework/boot/loader/jar/Bytes.class


If I used 2.x of spring-boot then the issue is not comming.

Spring-boot-->1.5.8.RELEASE
Spring-mvc-->4.3.25.RELEASE
Spring-Security-->security-web-4.2.8.RELEASE
Tomcat-->tomcat-embed-core-8.5.35.jar

同样,我正在尝试使用 Spring Boot 使用 web.xml 安全约束来防止访问。 Use web.xml security constraints with Spring Boot 但同样不工作

【问题讨论】:

  • 欢迎来到 Stack Overflow。请改进问题的格式,使其更易于阅读。问题的描述不应该使用代码片段的降价。在此处查看更多信息:stackoverflow.com/editing-help

标签: java spring-boot spring-mvc spring-security tomcat8


【解决方案1】:

这种行为是improved in Spring Boot 2.0。 Spring Boot 1.5 reached the end of its supported life in August 2019 因此,理想情况下,您应该升级到 Spring Boot 2.x。在撰写本文时,2.4.x 和 2.5.x 是受支持的版本。

如果您被困在 Spring Boot 1.5 上,您的选择会受到一定限制。您可以使用 jar 打包,也可以构建一个普通的 war 文件(不能使用 java -jar 运行的文件)并将其部署到 Tomcat(或另一个 servlet 容器)。您还可以使用Filter 以 404 响应不需要的请求。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 2019-05-05
    • 1970-01-01
    相关资源
    最近更新 更多