在Web应用程序路由中查找身份验证(authn)和授权(authz)安全漏洞。
项目描述
route-detect
在Web应用程序路由中查找身份验证(authn)和授权(authz)安全漏洞
Web应用程序HTTP路由身份验证和授权漏洞是目前发现的最常见的安全问题之一。这些行业标准资源强调了问题的严重性
- 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
ID)
- Python: Django (
django
,django-rest-framework
), Flask (flask
), Sanic (sanic
), FastAPI (fastapi
) - 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
)
*Rails支持有限。请参阅此问题获取更多信息。
安装
使用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
CLI命令,并使用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
如果您不确定要查找哪个框架,可以使用特殊的all
ID来检查所有内容
$ semgrep --json --config $(routes which all) --output routes.json path/to/code
如果您有自定义认证或授权逻辑,可以复制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
贡献
route-detect
使用poetry
进行依赖和配置管理。
在继续之前,使用以下命令安装项目依赖项
$ poetry install --with dev
代码检查
使用以下命令检查所有项目文件
$ poetry run pre-commit run --all-files
测试
使用以下命令运行Python测试
$ poetry run pytest --cov
使用以下命令运行Semgrep规则测试
$ poetry run semgrep --test --config routes/rules/ tests/test_rules/
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
route_detect-0.8.0.tar.gz (22.7 kB 查看哈希值)
构建分布
route_detect-0.8.0-py3-none-any.whl (29.9 kB 查看哈希值)