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

regex_redos.py: Check whether location-block contains ReDoS regexp. #30

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

MegaManSec
Copy link

@MegaManSec MegaManSec commented Feb 23, 2025

This plugin queries an external server (which must be set by by the caller) to check for any regular expressions used in location-blocks that are vulnerable to ReDoS vulnerabilities.

It is with great displeasure to provide this plugin in this format: by calling a web API. However, there is simply no other solution. This plugin is disabled by default, and requires an external HTTP server to setup to be used.

At the moment, only location blocks are checked, however in the future, more directives can be checked.

Amendments to this PR are highly appreciated.

Since it requires an external server, no checks are added.

Fixes #25.

This plugin queries an external server (which must be set by by the
caller) to check for any regular expressions used in location-blocks
that are vulnerable to ReDoS vulnerabilities.
@MegaManSec MegaManSec marked this pull request as draft February 23, 2025 06:13
@MegaManSec
Copy link
Author

MegaManSec commented Feb 23, 2025

Example usage:

# gixy --regex-redos-url http://localhost:3001/recheck --tests regex_redos

==================== Results ===================

>> Problem: [regex_redos] Detect directives with regexes that are vulnerable to Regular Expression Denial of Service (ReDoS).
Description: Regular expressions with the potential for catastrophic backtracking allow an nginx server to be denial-of-service attacked with very low resources (also known as ReDoS).
Additional info: https://joshua.hu/regex-redos-nginx-gixy
Reason: Regex is vulnerable to 2nd degree polynomial ReDoS: /statis/(.*)\.js\.map.
Pseudo config:

server {
	server_name servername.com;

	location ~ /static/(.*)\.js\.map {
	}
}

TODO:

  • the additional info link does not exist yet.
  • README.md does not explain this check, or its flags. The README.md also does not explain the other flags plugins options: --origins-domains domains Default: * --origins-https-only https_only Default: False --regex-redos-url url Default: --add-header-redefinition-headers headers Default:

@MegaManSec MegaManSec changed the title regex_redos.py: Check whether location-block contains ReDoS regexp. #25 regex_redos.py: Check whether location-block contains ReDoS regexp. Feb 23, 2025
@MegaManSec MegaManSec changed the title #25 regex_redos.py: Check whether location-block contains ReDoS regexp. regex_redos.py: Check whether location-block contains ReDoS regexp. Feb 23, 2025
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

Successfully merging this pull request may close these issues.

Detect ReDOS regex
1 participant