Skip to content

[pull] main from VirusTotal:main#251

Merged
pull[bot] merged 6 commits into
threatcode:mainfrom
VirusTotal:main
Jun 23, 2026
Merged

[pull] main from VirusTotal:main#251
pull[bot] merged 6 commits into
threatcode:mainfrom
VirusTotal:main

Conversation

@pull

@pull pull Bot commented Jun 23, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

nugxperience and others added 6 commits June 23, 2026 12:19
…ming modifiers (#689)

The header constraints optimization introduced in #676 prunes a pattern at
scan time when the file header can't satisfy the bytes the pattern requires
at offset 0 (e.g. `$a at 0`). The bytes were taken from the pattern's literal
text, ignoring its modifiers.

For patterns with the `xor`, `nocase`, `wide`, `base64` or `base64wide`
modifiers, the bytes that actually appear in the scanned data differ from the
literal text (they are XORed with a key, case-folded, interleaved with zeroes
or base64-encoded). Deriving a header constraint from the literal text in
those cases is incorrect: it requires the file to start with the plaintext
bytes, so a legitimate match at offset 0 gets pruned and the rule fails to
match.

For example, this rule did not match a file starting with "Hello" XORed with
key 0x01, even though the match is exactly at offset 0:

```
rule t { strings: $a = "Hello" xor condition: $a at 0 }
```

---------

Co-authored-by: Victor M. Alvarez <vmalvarez@virustotal.com>
Add the machine types from the current Microsoft PE format spec that
were missing from the `Machine` enum: ALPHA, ALPHA64/AXP64, ARM64EC,
ARM64X, LOONGARCH32/64, R3000(BE), R10000, RISCV32/64/128. Enable
allow_alias since AXP64 shares value 0x0284 with ALPHA64.

Values taken from the Microsoft PE format documentation:
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types

* tests: fix test case.

---------

Co-authored-by: Victor M. Alvarez <vmalvarez@virustotal.com>
Add a debug assertion to ensure that all `PatternFlags` are explicitly accounted for when determining if a pattern can be used to derive a header constraint. This helps prevent future regressions if new flags are added without considering their impact on this logic.
Single-byte patterns, such as `$a = "a"` or `{ 01 }`, can be very inefficient to scan as they match every occurrence of that byte. Previously, only repetitions of 0x00, 0x90, or 0xff were flagged as slow.
@pull pull Bot locked and limited conversation to collaborators Jun 23, 2026
@pull pull Bot added the ⤵️ pull label Jun 23, 2026
@pull pull Bot merged commit 496b5c8 into threatcode:main Jun 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants