如何使用route-detect在Web应用程序路由中扫描身份认证和授权漏洞

关于route-detect

route-detect是一款功能强大的Web应用程序路由安全扫描工具,该工具可以帮助广大研究人员在Web应用程序路由中轻松识别和检测身份认证漏洞和授权漏洞。

Web应用程序HTTP路由中的身份认证(authn)和授权(authz)漏洞是目前最常见的Web安全问题,下列行业标准也足以突出证明了此类安全问题的严重性:

2021 OWASP Top 10 #1 - 访问控制中断

2021 OWASP Top 10 #7 - 身份验证失效

2023 OWASP API Top 10 #1 - 对象级别授权中断

2023 OWASP API Top 10 #2 - 身份验证失效

2023 OWASP API Top 10 #5 - 功能级别授权中断

2023 CWE Top 25 #11 - CWE-862: 缺少授权

2023 CWE Top 25 #13 - CWE-287: 不正确的身份验证

2023 CWE Top 25 #20 - CWE-306: 关键功能缺少身份验证

2023 CWE Top 25 #24 - CWE-863: 不正确的授权

支持的Web框架

当前版本的route-detect支持下列Web框架:

Python: Django (django, django-rest-framework), Flask (flask), Sanic (sanic)

PHP: Laravel (laravel), Symfony (symfony), CakePHP (cakephp)

Ruby: Rails* (rails), Grape (grape)

Java: JAX-RS (jax-rs), Spring (spring)

Go: Gorilla (gorilla), Gin (gin), Chi (chi)

JavaScript/TypeScript: Express (express), React (react), Angular (angular)

工具安装

由于该工具使用Python开发,因此我们首先需要在本地设备上安装并配置好Python环境。

接下来,广大研究人员可以直接使用下列命令将该项目源码克隆至本地:

git clone https://github.com/mschwager/route-detect.git

或者直接使用pip工具安装最新版本的route-detect:

$ python -m pip install --upgrade route-detect

安装完成后,我们可以使用下列命令检测route-detect是否安装成功:

$ echo 'print(1 == 1)' | semgrep --config $(routes which test-route-detect) -

Scanning 1 file.

 

Findings:

 

  /tmp/stdin

     routes.rules.test-route-detect

        Found '1 == 1', your route-detect installation is working correctly

 

          1┆ print(1 == 1)

 

 

Ran 1 rule on 1 file: 1 finding.

工具使用

route-detect提供了routes命令并使用semgrep来搜索路由信息。

使用which子命令可以将semgrep指向正确的Web应用程序规则:

$ semgrep --config $(routes which django) path/to/django/code

使用viz子命令可以在浏览器中可视化查看路由信息:

$ semgrep --json --config $(routes which django) --output routes.json path/to/django/code

$ routes viz --browser routes.json

如果你不确定目标Web应用程序所使用的框架,可以使用all ID检索和查看:

$ semgrep --json --config $(routes which all) --output routes.json path/to/code

如果你有自己自定义的authn或authz逻辑,可以拷贝route-detect的规则:

$ cp $(routes which django) my-django.yml

我们还可以根据需求修改并运行规则:

$ semgrep --json --config my-django.yml --output routes.json path/to/django/code

$ routes viz --browser routes.json

工具运行截图

许可证协议

本项目的开发与发布遵循BSD-3-Clause开源许可证协议。

项目地址

route-detect:【GitHub传送门

参考资料

A01 Broken Access Control - OWASP Top 10:2021

A07 Identification and Authentication Failures - OWASP Top 10:2021

API1:2023 Broken Object Level Authorization - OWASP API Security Top 10

API2:2023 Broken Authentication - OWASP API Security Top 10

API5:2023 Broken Function Level Authorization - OWASP API Security Top 10

CWE - 2023 CWE Top 25 Most Dangerous Software Weaknesses

GitHub - semgrep/semgrep: Lightweight static analysis for many languages. Find bug variants with patterns that look like source code.

  • 26
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值