Add KernelCryptoDriverAbuse signature for ransomware detection#531
Add KernelCryptoDriverAbuse signature for ransomware detection#531kevross33 wants to merge 1 commit intoCAPESandbox:masterfrom
Conversation
This detects a process that is using the KsecDD to mass encrypt data (likely ransomware encrypting files). It also limits the marked calls to 20.
Summary of ChangesHello @kevross33, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a significant enhancement to ransomware detection capabilities by adding a new signature that specifically targets suspicious interactions with the Windows Kernel Security Device Driver (KsecDD). The new detection logic focuses on identifying processes that perform an unusually high volume of IOCTL calls to KsecDD, which is a strong indicator of hardware-accelerated mass encryption often employed by ransomware or wiper malware. This aims to provide more robust and accurate threat detection. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a new signature, KernelCryptoDriverAbuse, to detect potential ransomware activity by monitoring IOCTL calls to KsecDD. The overall logic is sound. I've provided a suggestion to improve robustness by handling missing process information more gracefully. I've also included recommendations to enhance maintainability by replacing magic numbers with named constants.
| pname = process.get("process_name", "").lower() | ||
| if pname in self.ignore_procs: | ||
| return None | ||
|
|
||
| pid = process.get("process_id") |
There was a problem hiding this comment.
The current implementation does not handle cases where process_id is missing, which could lead to None being used as a dictionary key and incorrectly grouping unrelated events. Additionally, if process_name is an empty string, it is still processed, which can lead to uninformative report messages. It's better to exit early if either pid or pname is missing or invalid.
| pname = process.get("process_name", "").lower() | |
| if pname in self.ignore_procs: | |
| return None | |
| pid = process.get("process_id") | |
| pid = process.get("process_id") | |
| if not pid: | |
| return None | |
| pname = process.get("process_name", "").lower() | |
| if not pname or pname in self.ignore_procs: | |
| return None |
| if (handle in self.ksec_handles[pid]) or (handle_name and "\\device\\ksecdd" in handle_name.lower()): | ||
| self.ioctl_counts[pid] += 1 | ||
|
|
||
| if self.ioctl_counts[pid] <= 20: |
There was a problem hiding this comment.
| ret = False | ||
|
|
||
| for pid, count in self.ioctl_counts.items(): | ||
| if count > 50: |
There was a problem hiding this comment.
This detects a process that is using the KsecDD to mass encrypt data (likely ransomware encrypting files). It also limits the marked calls to 20.
Lockbit
