Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 使用来源白名单功能时,没有设置orgin的客户端请求会立即通过,功能失效。 #3408

Open
xiejuntao opened this issue May 29, 2024 · 3 comments

Comments

@xiejuntao
Copy link

一、详细说明:
使用来源白名单功能时,没有设置orgin的客户端请求会立即通过,功能失效。
二、漏洞证明(在这里写POC):
github上最新的代码:
https://github.com/alibaba/Sentinel/blob/master/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleChecker.java
image
三、修复方案:
应去掉StringUtil.isEmpty(requester)的判断,否则白名单功能失效,产生非法访问的漏洞。

@xiejuntao
Copy link
Author

version:1.8.6,have already solved.

version:1.8.7 There is also this bug.

@LearningGp
Copy link
Collaborator

LearningGp commented Jun 4, 2024

这部分代码看起来当初是 bydesign 的,不过从当前的需求出发,感觉为这个规则增加一个严格模式,在严格模式下没有设置 orgin 的客户端请求会被拒绝,默认模式下保持原有行为,这样会不会更合适一些,欢迎加入讨论或提交优化的 PR。
PS:我们考虑在 2.0 中和安全能力一起重构这部分功能。

@marmot-z
Copy link

一、详细说明: 使用来源白名单功能时,没有设置orgin的客户端请求会立即通过,功能失效。 二、漏洞证明(在这里写POC): github上最新的代码: https://github.com/alibaba/Sentinel/blob/master/sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/authority/AuthorityRuleChecker.java image 三、修复方案: 应去掉StringUtil.isEmpty(requester)的判断,否则白名单功能失效,产生非法访问的漏洞。

一个解决方案是:在实现 RequestOriginParser#parseOrigin 方法是默认返回一个来源(如:defaultOrigin),而不是返回为空字符串。

当然直接放行 origin 为空的请求感觉确实有点怪怪的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants