Skip to content

refactor(signature): Overhaul cache keying and async verification pipeline#681

Open
rabbitstack wants to merge 4 commits into
masterfrom
improve-signature-verification
Open

refactor(signature): Overhaul cache keying and async verification pipeline#681
rabbitstack wants to merge 4 commits into
masterfrom
improve-signature-verification

Conversation

@rabbitstack

Copy link
Copy Markdown
Owner

What is the purpose of this PR / why it is needed?

The signature verification subsystem has been redesigned to address
correctness, performance, and observability concerns that accumulated
as the codebase grew.

Cache keying was fundamentally broken by relying on the module base
address as the primary index. ASLR randomises base addresses across
processes, causing every process spawn to produce a full cache miss
for system DLLs that were already verified moments earlier. The new
key is derived entirely from data available in the image-load
event including a normalised NT device path, PE timestamp, checksum,
and mapped image size. This requires zero additional syscalls and no
file handle acquisition at key construction time. It also eliminates
stale hit and false miss scenarios caused by DLL unload/reload at
the same virtual address, and collapses redundant verification work
for the same physical file loaded across multiple processes.

The synchronisation model has been reworked throughout. The global
mutex has been replaced with a reader-writer lock, and the signature
accessed timestamp is updated via an atomic store, eliminating the
need to upgrade to a write lock on every cache hit. All fields on
the Signature struct that are written by worker goroutines and read
by the rule engine are now accessed through the appropriate atomic
primitives, closing a class of data races that the previous implementation
left undetected.
Certificate parsing no longer holds the write lock across file I/O
and WinTrust calls, which previously serialised all cache readers
for the full duration of a catalog hash operation.

Cache invalidation on CreateFile events with FILE_OVERWRITE and
FILE_OVERWRITE_IF dispositions remove stale signatures from the store.

The async verification pipeline has been designed around the
observation that the enrichment stages between raw ETW delivery
and rule engine evaluation (stack walk correlation, symbol
resolution, and evasion scanner execution) provide a natural
latency budget that covers the median catalog hash duration. Image
rundown events emitted at session start are used to prewarm the
cache during bootstrap, ensuring that common system modules are
fully verified before the first live event reaches the rule engine.

What type of change does this PR introduce?


Uncomment one or more /kind <> lines:

/kind feature (non-breaking change which adds functionality)

/kind bug-fix (non-breaking change which fixes an issue)

/kind refactor (non-breaking change that restructures the code, while not changing the original functionality)

/kind breaking (fix or feature that would cause existing functionality to not work as expected

/kind cleanup

/kind improvement

/kind design

/kind documentation

/kind other (change that doesn't pertain to any of the above categories)

Any specific area of the project related to this PR?


Uncomment one or more /area <> lines:

/area instrumentation

/area telemetry

/area rule-engine

/area filters

/area yara

/area event

/area captures

/area alertsenders

/area outputs

/area rules

/area filaments

/area config

/area cli

/area tests

/area ci

/area build

/area docs

/area deps

/area evasion

/area other

Special notes for the reviewer


Does this PR introduce a user-facing change?


@rabbitstack rabbitstack force-pushed the improve-signature-verification branch 2 times, most recently from 6fce62d to b90d2ce Compare June 24, 2026 08:49
…eline

The signature verification subsystem has been redesigned to address
correctness, performance, and observability concerns that accumulated
as the codebase grew.

Cache keying was fundamentally broken by relying on the module base
address as the primary index. ASLR randomises base addresses across
processes, causing every process spawn to produce a full cache miss
for system DLLs that were already verified moments earlier. The new
key is derived entirely from data available in the image-load
event including a normalised NT device path, PE timestamp, checksum,
and mapped image size. This requires zero additional syscalls and no
file handle acquisition at key construction time. It also eliminates
stale hit and false miss scenarios caused by DLL unload/reload at
the same virtual address, and collapses redundant verification work
for the same physical file loaded across multiple processes.

The synchronisation model has been reworked throughout. The global
mutex has been replaced with a reader-writer lock, and the signature
accessed timestamp is updated via an atomic store, eliminating the
need to upgrade to a write lock on every cache hit. All fields on
the Signature struct that are written by worker goroutines and read
by the rule engine are now accessed through the appropriate atomic
primitives, closing a class of data races that the previous implementation
left undetected.
Certificate parsing no longer holds the write lock across file I/O
and WinTrust calls, which previously serialised all cache readers
for the full duration of a catalog hash operation.

Cache invalidation on CreateFile events with FILE_OVERWRITE and
FILE_OVERWRITE_IF dispositions remove stale signatures from the store.

The async verification pipeline has been designed around the
observation that the enrichment stages between raw ETW delivery
and rule engine evaluation (stack walk correlation, symbol
resolution, and evasion scanner execution) provide a natural
latency budget that covers the median catalog hash duration. Image
rundown events emitted at session start are used to prewarm the
cache during bootstrap, ensuring that common system modules are
fully verified before the first live event reaches the rule engine.
@rabbitstack rabbitstack force-pushed the improve-signature-verification branch from b90d2ce to 563d3ce Compare June 24, 2026 09:14
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.

1 participant