Skip to content

Add new rule persist-via-shellserviceobjectdelayload-registry-key.yml#1117

Merged
mike-hunhoff merged 4 commits intomandiant:masterfrom
xpzhxhm:master
Feb 26, 2026
Merged

Add new rule persist-via-shellserviceobjectdelayload-registry-key.yml#1117
mike-hunhoff merged 4 commits intomandiant:masterfrom
xpzhxhm:master

Conversation

@xpzhxhm
Copy link
Contributor

@xpzhxhm xpzhxhm commented Feb 12, 2026

Add new rule persist-via-shellserviceobjectdelayload-registry-key.yml
Closes #1114
Ref mandiant/capa-testfiles#303
https://blog.virustotal.com/2024/03/com-objects-hijacking.html

Copy link
Collaborator

@mike-hunhoff mike-hunhoff left a comment

Choose a reason for hiding this comment

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

Great, thanks @xpzhxhm . I've left comments for your review.

Update rules and description, improve scope to function/basic block by adding HKLM constant, remove blank line.
@xpzhxhm
Copy link
Contributor Author

xpzhxhm commented Feb 18, 2026

Hi @mike-hunhoff.
Thanks for the review!
I've updated a more detailed description and removed the blank line.
For the scope, I successfully narrowed it to function by adding number: 0x80000002 = HKEY_LOCAL_MACHINE in the features. The rule now correctly detects the sample at function scope.

@xpzhxhm
Copy link
Contributor Author

xpzhxhm commented Feb 18, 2026

I confirmed in IDA that this sample uses a helper function to write to the registry. The HKLM constant 0x80000002 and the string ShellServiceObjectDelayLoad reside in the parent function (sub_405224 in the sample), while RegSetValue is in a child function (sub_4053CD in the sample). My understanding is that adding the feature number: 0x80000002 will allow the rule to match the parent function.

@mike-hunhoff
Copy link
Collaborator

I confirmed in IDA that this sample uses a helper function to write to the registry. The HKLM constant 0x80000002 and the string ShellServiceObjectDelayLoad reside in the parent function (sub_405224 in the sample), while RegSetValue is in a child function (sub_4053CD in the sample). My understanding is that adding the feature number: 0x80000002 will allow the rule to match the parent function.

@xpzhxhm capa does not match across functions, so, specifying function scope enforces that all features are matched within a single function.

@xpzhxhm
Copy link
Contributor Author

xpzhxhm commented Feb 23, 2026

Hi @mike-hunhoff , thanks for clarifying! I understand now that with function scope, capa does not match across functions.
Since the RegSetValue action and the ShellServiceObjectDelayLoad string are in different functions in this sample, I changed the scope to file. Does it sound like a right approach?
I have pushed the updates. Could you please take another look when you have a chance? Thanks!

@xpzhxhm xpzhxhm requested a review from mike-hunhoff February 23, 2026 21:43
@mike-hunhoff
Copy link
Collaborator

Hi @mike-hunhoff , thanks for clarifying! I understand now that with function scope, capa does not match across functions. Since the RegSetValue action and the ShellServiceObjectDelayLoad string are in different functions in this sample, I changed the scope to file. Does it sound like a right approach? I have pushed the updates. Could you please take another look when you have a chance? Thanks!

@xpzhxhm no, capa rules must match the smallest reasonable scope possible. In this case , that would likely be function scope. Please find another sample or remove the example meta entry and move this rule to the nursery directory.

@xpzhxhm
Copy link
Contributor Author

xpzhxhm commented Feb 23, 2026

Hi @mike-hunhoff, thank you so much for your guidance :)

I'm switching the scope back to function. I initially assumed a broader scope was required, but the current sample shows the relevant features are in a single function.
On the sample, both 0x80000002 (HKLM) and Software\\Microsoft\\Windows\\CurrentVersion\\ShellServiceObjectDelayLoad appear in the same function, So the rule matches correctly under function scope.
Linter output and IDA screenshot are attached for reference.

Please let me know if I’m on the right track.
Thanks!
linter output
IDA

@mike-hunhoff mike-hunhoff merged commit 5da6426 into mandiant:master Feb 26, 2026
4 checks passed
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.

persist via Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad

2 participants