Skip to content

fix(callstack): Fix private allocation size #417

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

Merged

Conversation

rabbitstack
Copy link
Owner

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

Attackers exploit the memory of the benign module (dll) to inject their own shellcode. When the memory of the DLL is tampered, the backing memory pages release the shared attribute and become private pages. If the callstack contains such memory regions, it is a strong indicator of module stomping.
To accomplish the detection of stomped modules, we use the QueryWorkingSet API to examine the pages starting from the stack return address. If the Shared or SharedOriginal bits are not set, we increment the private allocation size by OS page size.

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 other

Special notes for the reviewer


Does this PR introduce a user-facing change?


@rabbitstack rabbitstack force-pushed the private-allocation-bytes-via-shared-original-attribute branch 2 times, most recently from ba97fe8 to 5129724 Compare December 23, 2024 15:00
Attackers exploit the memory of the benign module (dll) to inject their own shellcode. When the memory of the DLL is tampered, the backing memory pages release the shared attribute and become private pages. If the callstack contains such memory regions, it is a strong
indicator of module stomping.
To accomplish the detection of stomped modules, we use the `QueryWorkingSet` API to examine the pages starting from the stack return address.
@rabbitstack rabbitstack merged commit 97e5764 into master Dec 28, 2024
6 checks passed
@rabbitstack rabbitstack deleted the private-allocation-bytes-via-shared-original-attribute branch December 28, 2024 08:12
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