Find authentication (authn) and authorization (authz) security bugs in web application routes.
Project description
route-detect
Find authentication (authn) and authorization (authz) security bugs in web application routes.
Web application HTTP route authn and authz bugs are some of the most common security issues found today. These industry standard resources highlight the severity of the issue:
- 2021 OWASP Top 10 #1 - Broken Access Control
- 2021 OWASP Top 10 #7 - Identification and Authentication Failures (formerly Broken Authentication)
- 2019 OWASP API Top 10 #2 - Broken User Authentication
- 2019 OWASP API Top 10 #5 - Broken Function Level Authorization
- 2022 CWE Top 25 #14 - CWE-287: Improper Authentication
- 2022 CWE Top 25 #16 - CWE-862: Missing Authorization
- 2022 CWE Top 25 #18 - CWE-306: Missing Authentication for Critical Function
- #21 most CVEs by CWE - CWE-284: Access Control (Authorization) Issues
- #47 most CVEs by CWE - CWE-639: Access Control Bypass Through User-Controlled Key
Routes from koel
streaming server
Supported web frameworks (route-detect
IDs in parentheses):
- 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
)
*Rails support is limited. Please see this issue for more information.
Installing
Use pip
to install route-detect
:
$ python -m pip install --upgrade route-detect
You can check that route-detect
is installed correctly with the following command:
$ 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.
Using
route-detect
provides the routes
CLI command and uses semgrep
to search for routes.
Use the which
subcommand to point semgrep
at the correct web application rules:
$ semgrep --config $(routes which django) path/to/django/code
Use the viz
subcommand to visualize route information in your browser:
$ semgrep --json --config $(routes which django) --output routes.json path/to/django/code
$ routes viz --browser routes.json
If you're not sure which framework to look for, you can use the special all
ID to check everything:
$ semgrep --json --config $(routes which all) --output routes.json path/to/code
If you have custom authn or authz logic, you can copy route-detect
's rules:
$ cp $(routes which django) my-django.yml
Then you can modify the rule as necessary and run it like above:
$ semgrep --json --config my-django.yml --output routes.json path/to/django/code
$ routes viz --browser routes.json
Contributing
route-detect
uses poetry
for dependency and configuration management.
Before proceeding, install project dependencies with the following command:
$ poetry install --with dev
Linting
Lint all project files with the following command:
$ poetry run pre-commit run --all-files
Testing
Run Python tests with the following command:
$ poetry run pytest --cov
Run Semgrep rule tests with the following command:
$ poetry run semgrep --test --config routes/rules/ tests/test_rules/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file route_detect-0.7.0.tar.gz
.
File metadata
- Download URL: route_detect-0.7.0.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.1.0-9-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce6e0c171b328e8a7e02ddc6a33e49bb0d6a2339a5871747325c6a1c4b4d3a33 |
|
MD5 | 8b508a40395ef45258e8fe36e5e12e26 |
|
BLAKE2b-256 | 795387a14622e758b18b6d76f81205027eaea69e5c8723758d0d43d00d4646d5 |
File details
Details for the file route_detect-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: route_detect-0.7.0-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.2 Linux/6.1.0-9-amd64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fd7380ba214a800572aa79501ff68dfc546e6859f262c8ecafcab361f0ec22c |
|
MD5 | 5a66696031ff8f0c660ae41b5067873a |
|
BLAKE2b-256 | 9c2c8bd55b4abb094eebe9b84fd12a2152b0dd28e1f1d5f44e2c9953a3dfee4c |