mandiant / mandiant/capa

Problem : Rule loader should reject unsupported logic edge cases

Open
#2,920 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
6.2k
Forks
726
Avg merge
11d 11h
Merged PRs (30d)
7

Description

## Problem

While experimenting with capa rule logic, I noticed that some rule constructs are currently accepted during rule loading even though they are not safe for the optimized matcher/indexer.

In particular, certain logical edge cases can lead to ambiguous or incorrect evaluation behavior.

Examples include:

- top-level `not` statements
- nested `not` constructs (e.g. `not: not: ...`)
- top-level `count(...): 0` statements

These patterns may conflict with assumptions made by the optimized rule matcher and rule indexer.

## Example

For example, a rule containing something like:

```yaml
not:

api: CreateFileA
Or
not:
not:
api: CreateFileA
Similarly, constructs like:
count(api(CreateFileA)): 0
may introduce ambiguity or unexpected behavior during rule evaluation.

Expected Behavior

Rules containing unsupported logic constructs should be rejected during rule loading with a clear validation error.

This would:
• prevent subtle evaluation bugs
• ensure rules remain compatible with the optimized matcher/indexer
• provide clearer feedback to rule authors when invalid constructs are used.

Related Work #2913

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the rule-loading validation path and the optimized matcher/indexer assumptions, then compare the related work in #2913. Verify how top-level or nested not constructs and count(...): 0 are currently accepted. Done means unsupported constructs are rejected during loading with clear validation errors and existing rule behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
reverse-engineering, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.