Key Takeaways
- YARA rules deliver signature-based pattern matching that enables security teams to detect and classify malware across files, memory, and backups..
- Veeam integrates YARA scanning with immutable backups and Secure Restore, ensuring that recovery points are malware-free and that ransomware cannot reinfect production systems.
- Creating focused, well-tested YARA rules and storing them in Veeam’s designated folder lets organizations embed threat intelligence directly into backup scans for stronger cyber-resilience.
YARA (Yet Another Recursive Acronym) rules are a powerful pattern-matching tool used by security teams to identify and classify malware based on known signature, strings, and behaviors. In backup recovery, YARA scanning adds a valuable layer of protection. Combined with immutable backups and secure restore workflow, YARA rules ensure safe and clean recovery. In this article, we’ll explore YARA functionality, including what it does and how to write effective YARA rules for threat intelligence and malware detection.
Learn how to build a data resilience strategy and protect your organization from the effects of ransomware and other malware variants with the YARA engine in Veeam’s backup and replication servers.
The Role of YARA Rules in Cybersecurity
YARA rules scans are one of the most effective ways to help identify and classify malware, including viruses, worms, and ransomware. A YARA rules engine is an open-source tool that helps cybersecurity teams search for and detect malware to give them the opportunity to neutralize it before it does significant damage.
Strong protection against the presence of malware is a must. Even if you already deploy cybersecurity defense measures, malware can still make its way into your systems and data via stolen passwords, phishing attacks, or other avenues. If malware gains a foothold and it’s executed to encrypt or exfiltrate sensitive data, it can also be used to extort money and cause significant negative impact to your organization.
Understanding YARA Rules
Before creating YARA rules, it’s important to know what they are and how they work.
What Are YARA Rules?
YARA rules identify patterns that can be found in malware or families of malware, and in this way, they can indicate the presence of malicious software. When a rule finds a characteristic or pattern that indicates a piece of malware, then it can alert the appropriate person who can isolate or delete it.
Use Cases for YARA
YARA rules are actively used by security teams to validate clean data before it’s restored or shared. Whether it’s integrated into antivirus engines or layered into backup environments, YARA’s flexibility makes it valuable for security and data resilience. Let’s look at some of the ways organizations are putting YARA to work:
YARA Rules for Malware Detection
At its core, YARA is built for one purpose: identifying malicious code patterns quickly and accurately. Security teams use it to scan files, memory, and backups for signs of known malware or malware families, whether it’s variants of malware or specific strains of malware.
Signature-based YARA
- These YARA rules focus on specific patterns that are common in known malware, such as strings, hashes, byte sequences, code snippets, or file structures. The rules are precise and fast, which is ideal for catching variants of threats that have already been studied and classified.
YARA Rules for File Type
- YARA isn’t limited to just malware. It can also classify and filter files by type or extensions like .pdf or .exe. This allows security teams to identify executable files, detect embedded scripts, flag suspicious attachments. In storage and backups environments, YARA improves visibility and data hygiene.
YARA Rules and Threat Intelligence
YARA rules can be combined with threat intelligence tools and the latest threat data. Security teams can build or import rules based on real-world indicators, such as hash values, domain names, or attack artifacts. This helps in identifying new or emerging threats.
Ransomware Detection with YARA Rules
According to Veeam’s 2025 Ransomware Trends and Proactive Strategies Report, 69% of organizations suffered at least one ransomware attack in 2024. Top data resilience companies like Veeam offer built-in, signature-based backup malware detection scanners to maintain health and recoverability. We also expanded our features to include backup file size analyzers, anomaly detection, and indicators of compromise (IOC) tool detection.
However, for specific rules that search for specific malware or patterns that can execute a ransomware attack, a YARA rule is the best option to find malicious software and alert administrators.
One example of a YARA rule that can prevent ransomware is CTBLocker ransomware, which can be found by looking for klospad.pdb and keme132.dll filenames. A YARA rule scans for those files and alerts you immediately if they are found within the backup or at the time of recovery.
YARA Rules Syntax: What You Need to Know
YARA rules follow a simple structure and are designed for flexibility and speed. They feature syntax similar to the C programming language. Each rule includes identifiers, conditions, and strings that define what to look for in a file or memory object.
Rule Name
For the rule name, it’s recommended that you refer to the file name or malicious software you want to scan for. Within the syntax the rule name is an identifier after the word rule, which can never be a number or an underscore. For example:
rule Detect_Malicious_String
{
condition;
false
}
Strings
The string section is where patterns, signatures, or strings are defined. There are three distinct types of strings:
- Hexadecimal strings
- Text strings
- Regular expressions
Hexadecimal strings are employed to define raw byte sequences, whereas text strings and regular expressions are ideal for specifying readable text segments. Additionally, text strings and regular expressions can also represent raw bytes through the use of escape sequences.
Conditions
This is the only required section, since it refers to Boolean or arithmetical expressions commonly used in all programming languages (e.g., and, or, not, +, -,*, /, contains, etc.). Conditions must be met for the rule to match. Another type of condition could be file size or match length of string. There are many ways to create rules with conditions that meet these needs.
Metadata
Besides the string definition and condition sections, rules can also have a metadata section where additional information about your rule can be included. The metadata section is defined with the keyword “meta.” Metadata could include author’s name, the date the rule was created, the version number of the rule, and a description of what the rule finds.
Strings
The string section is where you define the patterns, signatures, or strings that the YARA rule will look for in your files or your network. A YARA rule can look for several types of strings, including those that use hexadecimals in combination with jumps, alternatives, and wildcards. Text strings can also use modifiers, such as nocase, full word, and wide, as well as regular expressions. You can learn more about advanced conditions in the YARA documentation.
Writing Effective Rules within Veeam Backup & Replication
Let’s look at how to use them within the Veeam Backup and Replication functionality.
Writing Effective Yara Rules: Define the Objective
Identify the malware you want to detect. For example, if you’re hunting for a specific malware or ransomware, you can create a rule with the strings, signatures, and patterns that are publicly available about the ransomware, and in that way, you can target the specific threat to protect your data.
To avoid excessive results and false positives, don’t write one YARA rule to find all types of malware. The recommendation is to write a YARA for each type of malicious software.
YARA rules can be written to accomplish several cybersecurity tasks. Many examples of YARA rules for well-known malware are available on GitHubExplore these examples if you’d like inspiration for writing your own!
YARA Rules during Scan Backup
For a Scan Backup session, you can run a YARA scan to perform the following operations:
- Find the last clean restore point.
- Analyze the content for specific information that was defined in the rule.
To perform the YARA scan during the Scan Backup session, do the following:
- In the Scan Backup window, enable the “Scan restore points with the following YARA rule”
- The YARA file located in the Veeam Backup & Replication product folder. The path by default is: C:\Program Files\Veeam\Backup and Replication\Backup\YaraRules. The YARA file must have the .yara or .yar extension.
View Yara Scan Results
To view YARA scan results in the backup session statistics you can:
- Open the “Home” view in the inventory pane, select “Last 24 hours” and in the working area, double-click your desired Scan Backup job. Alternatively, you can select the job and click “Statistics” on the ribbon, or right-click the job and select “Statistics.”
- Open the “History” view in the inventory pane, then select “Jobs.” In the working area, double-click your desired Scan Backup job. Alternatively, you can select the job and click “Statistics” on the ribbon or right-click the job and select “Statistics.”
To view a detailed log of the YARA scan, click the “Scan Log” button at the bottom of the window with the Scan Backup job statistics. Veeam Backup & Replication will display the most recent logs in a 1 MB file.
Best Practices for YARA Rule Development
Some best practices to make your YARA rules stronger and more effective include:
- Building templates to stay consistent and more organized.
- Using the standard YARA rule conventions and contributing to the rule repository to help the broader cybersecurity community. These conventions typically include the use of a header to identify the rule, which is a condition that describes the malware characteristics. It also includes tags to help categorize the rule you’ve created to help other cybersecurity experts.
- Keep in mind that YARA rules are just one line of defense against malware. Follow standards such as the NIST framework to give yourself the best chance of protecting against threats and detecting and responding to cybersecurity incidents. Check out the National Institute of Standards and Technology for more cybersecurity guidelines and best practices.
Testing and Validating YARA Rules
Before deploying YARA rules in a production environment, test them for accuracy, efficiency, and false positives. Make sure that your rules match the right patterns without overreaching. This way you can maintain reliable detection without unnecessary noise.
Testing YARA Rules
The YARA rule can then be integrated and added into Veeam Data Platform to scan files in real time. It’s important to test your YARA rules to ensure they’re working as intended. Since YARA rules are based on patterns or signatures, testing your YARA rule in a staging environment allows you to verify that these patterns have been identified accurately.
You don’t have to infect your network with working malware to test YARA rules. Download a dataset of known malware samples to test your rules without putting your network’s security at risk. Deploy new rules to your production environment once you’re confident they’re effective but won’t generate too many false positives.
Community YARA Rules
There’s a large community of YARA users who maintain public repositories for sharing YARA rules. By sharing rules, the community helps build an extensive database that everyone can benefit from when it comes to malware detection.
Collaborative Rule Development
When security professionals and organizations share YARA rules, the community can develop more focused malware-fighting tools. When these professionals share their rules, they’re not only sharing vital knowledge, but inviting others to improve their work too. When threat intelligence is shared, identifying dangerous attacks becomes easier for the entire community.
YARA Rules, Documentation, and Resources
There are several YARA rule repositories and communities where you can share your YARA rules and collaborate with others:
YARA GitHub Repository: This is the primary source for all things YARA. You can find the latest releases, YARA documentation, and the YARA source code here.
YARA Documentation: Hosted on ReadTheDocs, the official YARA documentation provides comprehensive information on how to use YARA and its syntax, what the rules do, and how its capabilities detect malicious software.
YARA Rules and Signatures Repository: This is a great resource where you can find a collection of community-based YARA rules and signatures. You can also contribute your own YARA rules so others can use them.
YARA rules by ransomware group: a community of sample YARA rules specific to ransomware.
Veeam Data Platform Documentation:
Conclusion
YARA rules are an effective way to enhance your organization’s cybersecurity by helping you detect malicious software more easily. You can write your own YARA rules or take advantage of one of the many free repositories of community-built rules already available. If you’re looking for a way to enhance your company’s cybersecurity efforts, YARA rules are one of the best ways to do it.
Learn more about cyber resilience and how to protect your organization against ransomware! Download our free white paper on cyber-resilient data recovery strategies today.
YARA Rules FAQs
- What are YARA rules and how do they work?
YARA rules are signature-based detection patterns that help identify malware—viruses, ransomware, Trojans—by matching specific strings, hex patterns, or binary signatures against files or memory samples. These rules can be customized to detect known threats or identify suspicious behavior by scanning backup files or memory snapshots. - Why use YARA scanning in backups?
YARA scans detect malware artifacts embedded in backup files, ensuring you identify the last clean restore point or prevent the reintroduction of hidden threats during recovery. This is especially critical for ransomware detection before restoring data into production environments.
Scanning backups with YARA rules can provide the restore point where the files are first found providing information such as timelines to assist incident response. - How does Veeam integrate YARA scanning?
Veeam Backup & Replication uses YARA scanning during operations such as “SureBackup”, “Secure Restore”, or manual ad-hoc scan.
The process mounts the backup restore point to disk and runs the YARA engine against it, using user-defined rule sets in `.yara` or `.yar` formats. - Where do I store my YARA rule files in Veeam?
To use custom rules, place your `.yara` or `.yar` files in the following folder:
C:\Program Files\Veeam\Backup and Replication\Backup\YaraRules
Once the files are in place, enable YARA scanning in your backup job settings to activate detection. - What happens when a YARA rule matches during a scan?
If malware activity is not detected, Veeam Backup & Replication will restore the machine or its disks to the target location. The malware detection event will not be created.
If malware activity is detected, Veeam Backup & Replication will perform the following steps:
Abort the restore process or restore the machine or its disks with restrictions depending on secure restore settings. Create the malware detection event and mark objects as Infected.