Giter Site home page Giter Site logo

[漏洞]开启local或local-plus 并启用 enable-access 后,通过特定url能够下载机器的所有文件 about x-file-storage HOT 5 CLOSED

dromara avatar dromara commented on May 13, 2024
[漏洞]开启local或local-plus 并启用 enable-access 后,通过特定url能够下载机器的所有文件

from x-file-storage.

Comments (5)

1171736840 avatar 1171736840 commented on May 13, 2024

此功能是通过以下方式实现的,可以通过过滤器进行拦截,或者使用其它方式实现文件访问,例如Nginx

public class FileStorageAutoConfiguration implements WebMvcConfigurer {
     /**
      * 配置本地存储的访问地址
      */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        for (FileStorageProperties.Local local : properties.getLocal()) {
            if (local.getEnableAccess()) {
                registry.addResourceHandler(local.getPathPatterns()).addResourceLocations("file:" + local.getBasePath());
            }
        }
        for (FileStorageProperties.LocalPlus local : properties.getLocalPlus()) {
            if (local.getEnableAccess()) {
                registry.addResourceHandler(local.getPathPatterns()).addResourceLocations("file:" + local.getStoragePath());
            }
        }
    }
}

from x-file-storage.

xiwh avatar xiwh commented on May 13, 2024

上面有误, 不能通过特定url任意访问机器内所有文件,但是可以无视base-path访问storage-path内的所有文件,建议addResourceLocations时将local.getStoragePath()+local.getBasePath()添加进去解决。
但是 FileStorageService 的实现类LocalPlusFileStorage和LocalFileStorage依然有这样的漏洞,如果传入非法url将导致能够操作任意路径文件,建议在拼接路径后做一次判断,下面有个例子可以参考下:
image

from x-file-storage.

1171736840 avatar 1171736840 commented on May 13, 2024

好的,感谢你的建议,我会在新版本中处理相关问题

from x-file-storage.

1171736840 avatar 1171736840 commented on May 13, 2024

针对现有版本,可以查看文档,通过切面进行拦截处理

from x-file-storage.

1171736840 avatar 1171736840 commented on May 13, 2024

由于工作较忙,目前新版本才接近尾声
这个 本地 base-patn 和 本地升级版本 storage-path 其实就相对于对象存储的 bucket-name ,本地升级版本 base-path 和 对象存储中的 base-path 作用一致,只是用于一个存储平台通过路径区分不同的项目,并没有隔离访问的功能,只有本地升级版会这样,应该是没什么问题的
要想避免这个情况,有以下两个办法:
1、把 base-path 写在 storage-path 中
2、通过 自定义拦截器 或 Nginx 等过滤

from x-file-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.