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

[BUG] domain Rule Matches Too Broadly #449

Open
LoneOdDaeth opened this issue Feb 20, 2025 · 0 comments
Open

[BUG] domain Rule Matches Too Broadly #449

LoneOdDaeth opened this issue Feb 20, 2025 · 0 comments
Labels

Comments

@LoneOdDaeth
Copy link

Describe the bug

The domain rule in the YARA ruleset matches unintended strings that are not actual domains. This leads to false positives when scanning files that contain generic words, filenames, or localhost-like addresses.

To Reproduce

Steps to reproduce the behavior:

Run YARA scan with the domain rule enabled.

Scan a file that contains common words, filenames, or IP addresses.

Observe that many non-domain strings are detected.

Example false positives:

test-123
file.txt
localhost
random_text

All these strings are incorrectly flagged as domains.

Expected behavior

The domain rule should only match valid domains, such as example.com, sub.example.net, or test-site.org. It should not match:

Plain text words

Filenames like file.txt

Localhost or internal references

Additional context

The issue is caused by the overly broad regex pattern:

$domain_regex = /([\w.-]+)/ wide ascii

This matches any word that includes dots, hyphens, or alphanumeric characters, leading to many false positives.

Suggested Fix: Update the regex to a stricter pattern that ensures a valid TLD is present:

$domain_regex = /([a-zA-Z0-9-]+.[a-zA-Z]{2,6})/ wide ascii

This ensures only real domains are detected.

@LoneOdDaeth LoneOdDaeth changed the title Bug Report: domain Rule Matches Too Broadly [BUG] domain Rule Matches Too Broadly Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant