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

路径判断不要写 indexOf 判断 #3

Open
everlose opened this issue Mar 21, 2021 · 5 comments
Open

路径判断不要写 indexOf 判断 #3

everlose opened this issue Mar 21, 2021 · 5 comments

Comments

@everlose
Copy link

config.ratelimiter = {
  router: [
    {
      path: '/fe/product',
      max: 1,
      time: '1s',
      message: '访问频率过高',
    },
    {
      path: '/fe/article/:aid',
      max: 1,
      time: '1s',
      message: '访问频率过高',
    },
  ],
};

上述代码访问 /fe/product 路径能生效,而 '/fe/article/JHASU1234' 无效。

我检查代码应该是路径判断惹起的

opts.router[actionKeys.indexOf(ctx.url)]

这点期望能和 router 使用一样的规则。

@everlose
Copy link
Author

还有一个漏洞,redis 存放的是

id: `${id}:${ctx.url}`

模拟 curl 请求路径后的参数每次都填不一样的,就绕过了你的限制。

@rfw
Copy link

rfw commented Apr 4, 2021

我也发这个问题了,没发匹配带参数的路由,

@ZQun
Copy link
Owner

ZQun commented Apr 4, 2021

这个版本确实只支持绝对路径,现在项目在用midway,我抽时间做个midway速率限制器组件,顺便路由路径匹配做一下,egg-ratelimiter到时也加进去

@everlose
Copy link
Author

这个版本确实只支持绝对路径,现在项目在用midway,我抽时间做个midway速率限制器组件,顺便路由路径匹配做一下,egg-ratelimiter到时也加进去

感觉最大的问题还是

id: `${id}:${ctx.url}`

容易被绕过去...这是一个比较致命的漏洞。还是改用 path 替代 url 吧。。

@leochen-g
Copy link

get请求带参数基本就用不了了

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

4 participants