chillzhuang / SpringBlade

SpringBlade 是一个由商业级项目升级优化而来的SpringCloud分布式微服务架构、SpringBoot单体式微服务架构并存的综合型项目,采用Java17 API重构了业务代码,完全遵循阿里巴巴编码规范。采用Spring Boot 3.2 、Spring Cloud 2023 、Mybatis 等核心技术,同时提供基于React和Vue的两个前端框架用于快速搭建企业级的SaaS多租户微服务平台。
https://bladex.cn
Apache License 2.0
6.53k stars 1.33k forks source link

Authorization bypass in blade-gateway #8

Open s31k31 opened 4 years ago

s31k31 commented 4 years ago

src/main/java/org/springblade/gateway/filter/AuthFilter.java

isSkip() method in AuthFilter.java, url.replace(AuthProvider.TARGET, AuthProvider.REPLACEMENT)) is equal to url.replace("/**", ""), which is to remove /** in defaultSkipUrl then determines whether the path contains one of the URLs.

Note that contains is used, that is, path::contains, which means that as long as the incoming path contains the URL in /token or defaultSkipUrl, authorization can be bypassed.

You can use the URL parsing feature to add ;%2ftoken after the request to be considered that the Url contains the /token, and the route can be correctly resolved by the gateway, resulting in unauthorized access.

image

The origin without Blade-Auth is blocked. http://localhost/blade-gateway/discovery/instances image

Add %2ftoken to the end of the URL to bypass authorization. http://localhost/blade-gateway/discovery/instances;%2ftoken image