Skip to content

Improve v3 rules#764

Merged
christophetd merged 8 commits into
v3from
christophe.tafanidereeper/v3
Jun 15, 2026
Merged

Improve v3 rules#764
christophetd merged 8 commits into
v3from
christophe.tafanidereeper/v3

Conversation

@christophetd

@christophetd christophetd commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Note: based on v3; the parent v3-better-console-output commits will drop off once that branch merges.

Iteration Commit Precision Recall F1 MCC Reports
v3 baseline 29ec928 77.8% 90.4% 83.6% 0.73 combined · recall · report
Iteration 1 f9e6a53 87.0% 87.1% 87.1% 0.79 combined · recall · report
Iteration 2 c7f7fa6 88.7% (+1.7) 87.0% (-0.1) 87.9% 0.80 combined · recall · report
Iteration 3 a27f77e 88.8% (+0.1) 88.5% (+1.5) 88.7% (+0.8) 0.82 (+0.02) combined · recall · report
Iteration 4 6865b1e 88.8% (+0) 88.5% (+) 88.7% (+0) 0.82 (+0) (same)

Iteration 4 includes a new rule that I've confirmed does catch some real-world malware, although not in this eval sampling.

@christophetd christophetd force-pushed the christophe.tafanidereeper/v3 branch 2 times, most recently from 7e21527 to 1261014 Compare June 11, 2026 09:29
@christophetd christophetd changed the title Reduce false positives in source-code threat rules Improve v3 rules Jun 11, 2026
@christophetd christophetd marked this pull request as ready for review June 15, 2026 07:31
@christophetd christophetd requested a review from a team as a code owner June 15, 2026 07:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6865b1e687

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread guarddog/analyzer/sourcecode/threat-runtime-obfuscation-base64exec.yar Outdated
Comment thread guarddog/analyzer/sourcecode/threat-npm-http-dependency.yar Outdated
sobregosodd
sobregosodd previously approved these changes Jun 15, 2026
@christophetd christophetd force-pushed the christophe.tafanidereeper/v3 branch from 572279e to 2690f47 Compare June 15, 2026 13:34
Tighten 18 threat-* YARA rules that fired on top npm/PyPI packages without
any real threat: require command/call context instead of bare strings, add
word boundaries, exclude metadata/charset/test data, and pair weak signals
(e.g. OpenProcess only with ReadProcessMemory). Detection intent is preserved.

Rename threat_process_spawn_sysinfo -> threat_process_sysinfo and
threat_network_outbound -> threat_network_exfiltration so the rule names match
their file ids (the no-false-positive test keys on this).

Add tests/rule_fp_review: a malicious+benign fixture pair per rule and a
validator to confirm fixes keep true positives while dropping the FPs.
False-positive reductions (repeat patterns from the benign benchmark):
- runtime-environment-read: drop os.environ.copy() / dict(os.environ) /
  os.Environ() (benign subprocess plumbing, not exfiltration)
- filesystem-autostart: match .profile only as a path/string, not as a
  `.profile` attribute access
- process-download-exec: anchor requests.get and treat exec(/eval( as bare
  builtins, so JS map access and regex.exec()/.eval() no longer leak in
- obfuscation-base64exec / obfuscation-steganography: exec(/eval( as bare
  builtins; steganography no longer triggers on plain PIL.Image use
- runtime-dynamic-loader: require an execution sink alongside import+download
  (the bare co-occurrence fired on many large legit packages)
- keylogging: require an actual capture call, not a bare `import keyboard`

False-negative recovery:
- Scan *.pth files with the Python rules (.pth startup-code injection, e.g.
  the compromised litellm release)
- New rule obfuscation-hidden-code: require aliased through a global, or a
  payload pushed off-screen by a long whitespace run (react-native-aria /
  Shai-Hulud injected payloads)

Reliability:
- obfuscation: rewrite the base64 string so the base64-only marker sits in a
  bounded prefix instead of between two open-ended runs, which exploded into
  millions of candidate matches on large base64 blobs (ERROR_TOO_MANY_MATCHES)

Adds benign and positive regression fixtures for the changed/added rules.
@christophetd christophetd force-pushed the christophe.tafanidereeper/v3 branch from 2690f47 to e22a091 Compare June 15, 2026 14:40
@christophetd christophetd enabled auto-merge (squash) June 15, 2026 14:42
@christophetd christophetd merged commit ef6c317 into v3 Jun 15, 2026
6 checks passed
@christophetd christophetd deleted the christophe.tafanidereeper/v3 branch June 15, 2026 14:44
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.

2 participants