Skip to content

Comments

Add KernelCryptoDriverAbuse signature for ransomware detection#531

Open
kevross33 wants to merge 1 commit intoCAPESandbox:masterfrom
kevross33:patch-95
Open

Add KernelCryptoDriverAbuse signature for ransomware detection#531
kevross33 wants to merge 1 commit intoCAPESandbox:masterfrom
kevross33:patch-95

Conversation

@kevross33
Copy link
Contributor

@kevross33 kevross33 commented Feb 24, 2026

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
image

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.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 Signature Added: A new signature, KernelCryptoDriverAbuse, has been introduced to detect ransomware and wiper activity.
  • KsecDD Monitoring: The signature monitors for excessive IOCTL calls to the Kernel Security Device Driver (KsecDD), which is indicative of hardware-accelerated mass encryption.
  • False Positive Reduction: Common browser processes (e.g., chrome.exe, firefox.exe) are ignored to reduce potential false positives.
  • Call Marking Limit: Relevant API calls are marked up to a limit of 20 per process interacting with KsecDD.
  • Alert Threshold: An alert is triggered if a process makes more than 50 IOCTL calls to KsecDD.

🧠 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
  • modules/signatures/windows/ransomware_crypto.py
    • Added the KernelCryptoDriverAbuse signature to detect ransomware and wiper activity by monitoring excessive IOCTL calls to the Kernel Security Device Driver (KsecDD).
Activity
  • No specific activity has been recorded for this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +95 to +99
pname = process.get("process_name", "").lower()
if pname in self.ignore_procs:
return None

pid = process.get("process_id")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

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.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The magic number 20 is used here as a threshold for marking calls. To improve readability and maintainability, consider defining this as a class-level constant (e.g., MAX_MARKED_CALLS = 20) and referencing it here. This makes the code's intent clearer and simplifies future adjustments.

ret = False

for pid, count in self.ioctl_counts.items():
if count > 50:
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The magic number 50 is used here as a threshold for triggering the signature. To improve readability and maintainability, consider defining this as a class-level constant (e.g., IOCTL_THRESHOLD = 50) and referencing it here. This makes the code's intent clearer and simplifies future adjustments.

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