When entering wildcard domains like *.openai.com, the tool was accepting wildcard DNS records discovered by enumeration tools (e.g., *.cdn.openai.com, *.static.openai.com). While this didn't directly cause recursive job creation, it was incorrect behavior that could lead to confusion and potential issues.
The is_valid_subdomain() function in main.py was explicitly allowing wildcards in its validation regex pattern:
# OLD CODE (incorrect)
domain_pattern = r'^(\*\.)?[a-z0-9]...' # Accepts *.domain.comThis function is used to validate tool output (discovered subdomains), where wildcards should NEVER appear. Wildcard handling should only occur in user input via expand_wildcard_targets().
Modified is_valid_subdomain() to explicitly reject any string containing the * character:
# NEW CODE (correct)
def is_valid_subdomain(text: str) -> bool:
"""
Validate that a string looks like a valid domain or subdomain.
Returns False for ANSI codes, error messages, status messages, wildcards, etc.
NOTE: This function is used to validate tool output (discovered subdomains).
Wildcards are rejected here because tools should return concrete subdomains,
not wildcard patterns. Wildcard inputs are handled separately by expand_wildcard_targets().
"""
# ... (validation code)
# Reject wildcards - these should not appear in tool output
if '*' in cleaned:
return False
# ... (rest of validation)When a user enters *.openai.com:
expand_wildcard_targets()strips the*.prefix- Creates exactly ONE job for
openai.comwithbroad_scope=True - No recursive jobs are created
When enumeration tools discover subdomains:
- Normal subdomains like
api.openai.comare accepted - Wildcard DNS records like
*.cdn.openai.comare filtered out - Only valid concrete subdomains are added to the state
- No new jobs are created from discovered subdomains
User Input: *.openai.com
1. expand_wildcard_targets('*.openai.com')
→ [('openai.com', True)]
→ Creates 1 job for openai.com
2. Enumeration tools discover:
- api.openai.com ✓ Valid
- chat.openai.com ✓ Valid
- *.cdn.openai.com ✗ Filtered (wildcard)
- auth.openai.com ✓ Valid
- *.static.openai.com ✗ Filtered (wildcard)
3. State updated with valid subdomains only
- api.openai.com
- chat.openai.com
- auth.openai.com
4. No new jobs created
→ Still only 1 job for openai.com
Added comprehensive test suite in test_main.py:
TestWildcardSubdomainFilteringclass with 7 test cases- Tests cover wildcard rejection, filtering, expansion, and integration
- All tests pass successfully
- Wildcard Rejection: Verify
is_valid_subdomain()rejects wildcards - File Filtering: Verify
read_lines_file()filters wildcard entries - Single Job Creation: Verify
*.domain.comcreates exactly 1 job - TLD Expansion: Verify
domain.*expands to multiple TLDs correctly - Integration: End-to-end test of the complete flow
main.py: Modifiedis_valid_subdomain()functiontest_main.py: AddedTestWildcardSubdomainFilteringtest classWILDCARD_FIX.md: This documentation file
Run the tests:
python3 test_main.pyOr test manually:
python3 main.py '*.openai.com' --skip-niktoThe tool will:
- Create exactly 1 job for
openai.com - Filter out any wildcard DNS records discovered
- Never create recursive jobs
- Fixes: Prevents wildcard DNS records from being stored in state
- Maintains: All existing wildcard expansion functionality for user input
- Improves: Code clarity by separating concerns (user input vs tool output)
- No Breaking Changes: All existing tests pass
This fix ensures that:
- User wildcard input (
*.domain.com) is handled correctly byexpand_wildcard_targets() - Tool output is validated properly by
is_valid_subdomain() - The two concerns remain separated and well-defined
- The codebase is protected against any future issues with wildcard handling