Regexploit

1.0.0 · active · verified Thu Apr 16

Regexploit is a Python library designed to identify Regular Expression Denial of Service (ReDoS) vulnerabilities in regular expressions. It analyzes a given regex string to determine if it can be exploited by crafted input, potentially leading to excessive backtracking and application slowdowns or crashes. The current version is 1.0.0, and releases appear to be infrequent, focusing on stable major versions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the Regexploit class with a regex pattern and check it for ReDoS vulnerabilities. It prints detailed findings if a vulnerability is detected, using the `to_dict()` method for structured output.

from regexploit.regexploit import Regexploit
import json

# Define a potentially vulnerable regex pattern
regex_pattern = r"^(a+)+$"

# Initialize the Regexploit engine with the pattern
# It's recommended to set a timeout to prevent excessively long analysis
exploit = Regexploit(regex_pattern, timeout=5)

# Check the regex for ReDoS vulnerabilities
result = exploit.check()

# Process and display the results
if result.is_vulnerable():
    print(f"The regex '{regex_pattern}' is potentially vulnerable to ReDoS.")
    print("Vulnerability Details:")
    print(json.dumps(result.to_dict(), indent=2))
else:
    print(f"The regex '{regex_pattern}' appears to be safe from common ReDoS patterns.")

view raw JSON →