YARA
Scan blobs and text for malware with YARA rules, straight from SQL
- Connector software
- Free and open source
- Service credentials
- Not needed
- Query Farm hosting
- Available · $10/month organization minimum
Use with an agent
Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.
npx skills add Query-farm/vgi-skills --skill orchard
Copy this request into your coding agent to get started.
Use https://query.farm/products/orchard/connectors/yara/index.md to help me query YARA with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.
Locate matching byte patterns in a sample
Example output · captured
- Connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
SELECT rule, identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset"
| rule | identifier | offset | matched |
|---|---|---|---|
| demo | $a | 19 | malware |
Quick start
Choose where to run YARA, then follow the steps below.
The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.
1. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
2. Attach the connector
Attach the release directly
Downloads the latest release for your platform and caches it locally.
ATTACH 'yara' AS yara (
TYPE vgi,
LOCATION 'github-auto://Query-farm/vgi-yara'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'yara' AS yara (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-yara:0.5.0'
);
3. Run a query
SELECT rule, identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset"
Run the connector on a server you manage. You operate the service and choose who can connect.
1. Deploy the connector on your server
Follow the connector’s deployment instructions. Use its supported HTTP transport, or launch it remotely over SSH. The connection guide explains both options.
2. Install the vgi extension
Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach the connector
For an HTTP deployment, replace the example URL with your endpoint. Add the authentication options your deployment requires. For SSH, use the SSH connection instructions.
ATTACH 'yara' AS yara
(TYPE vgi, LOCATION 'https://your-connector.example.com');
4. Run a query
SELECT rule, identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset"
Query Farm operates YARA for your team. Hosting has a $10 monthly minimum per organization; usage counts toward it. From $2.97 per instance-month ($10 monthly minimum).
1. Create your hosted connector
Open the console, choose your organization and deployment size, and add any service credentials there.
2. Install the vgi extension
SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
INSTALL vgi FROM community;
LOAD vgi;
3. Attach your deployment
Copy the ATTACH statement from your deployment in the console and run it in DuckDB or Haybarn. Use yara as the catalog alias for the query below.
4. Run a query
SELECT rule, identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset"
Technical details
- Verified connector release
- v0.5.0
- Engine
- 2.0.1
- VGI protocol
- 3.4.0
- Verified on
- December 1, 2026
Pin a version for production
When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.
Attach the release directly
Uses the verified release each time you attach the connector.
ATTACH 'yara' AS yara (
TYPE vgi,
LOCATION 'github-auto://Query-farm/[email protected]'
);
Attach the signed image
Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.
ATTACH 'yara' AS yara (
TYPE vgi,
LOCATION 'oci://ghcr.io/query-farm/vgi-yara:0.5.0'
);
Overview
Defensive YARA-X malware scanning: compile YARA rules and scan blobs/text for matches, all in SQL over Apache Arrow.
![]()
Scan blobs, files, and text columns for malware and indicators of compromise (IOCs) straight from DuckDB SQL by compiling and matching YARA rules — no external scanner, no native libyara, just functions you can call in a query.
This extension brings defensive YARA rule matching to the database, so security engineers, threat hunters, and data teams can triage suspicious files, hunt for signatures, and enforce detection rules over data they already have in DuckDB. Instead of exporting samples to a standalone tool, you write a YARA ruleset (or load one from a column) and let SQL fan it across millions of rows: filter a table of email attachments, label artifacts in an object store, or join scan verdicts back onto your metadata — all in one place.
Matching is powered by YARA-X, VirusTotal's pure-Rust rewrite of the classic YARA engine, embedded directly in the worker so there is no C dependency to install or keep patched. Rules are compiled once per batch and reused, and scanning is total: untrusted, garbage, empty, or deliberately hostile data simply yields no matches rather than crashing the worker, so you can point it at live malware safely. The full YARA syntax — string, hex, and regex patterns, conditions, namespaces, tags, and the standard pe/elf/hash/math modules — is supported.
Two shapes of access are offered. Per-row scalar functions test a whole column of blobs or text against a ruleset, giving you a filter predicate, a match count, or the name of the rule that fired — ideal for triaging a table of samples or labelling artifacts in place. Table functions instead expand a single scan into detail rows, one per matching rule or per individual pattern hit (with byte offsets and the matched bytes), for forensics and drill-down. There is also a validation helper for checking that a ruleset compiles before you scan with it, and a yara_modules reference table listing the YARA-X modules (pe, elf, hash, math, …) a rule may import.
For rule-writing syntax and module reference see the official YARA-X documentation and the yara-x crate docs.
Catalog
Everything yara exposes once attached — read straight from the worker's
released build.
main 1 table · 6 functions
YARA rule compilation and malware-scanning functions.
Schema examples (7)
Validate that a YARA ruleset compiles before scanning with it.
SELECT yara.main.yara_check('rule demo { strings: $a = "malware" condition: $a }') AS compiles;
Predicate: does the data match any rule in a ruleset?
SELECT yara.main.yara_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }') AS hit;
Name the first rule that matches the data.
SELECT yara.main.yara_first_rule('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }') AS first_rule;
Count how many rules in a ruleset match the data.
SELECT yara.main.yara_match_count('evil worm', 'rule a { strings: $a = "evil" condition: $a } rule b { strings: $b = "worm" condition: $b }') AS n;
3 more examples
Scan a constant blob into one row per matching rule, with its namespace.
SELECT rule, namespace
FROM yara.main.yara_scan('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY rule;
Locate each pattern hit in the data with its byte offset.
SELECT identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset";
List the YARA-X modules a rule may import on this worker.
SELECT module, description FROM yara.main.yara_modules ORDER BY module;
yara_modules
YARA-X modules compiled into this worker that a rule may import, one per row.
List every YARA-X module a rule may import on this worker, alphabetically.
SELECT module, description FROM yara.main.yara_modules ORDER BY module;
Check whether the PE module is available before writing a rule that imports it.
SELECT count(*) AS pe_available
FROM yara.main.yara_modules
WHERE module = 'pe';
yara_check (rules VARCHAR)
True if the YARA rule source compiles, false otherwise (validation)
Validate that a YARA ruleset compiles before using it to scan.
SELECT yara.main.yara_check('rule demo { strings: $a = "malware" condition: $a }');
yara_first_rule (data ANY, rules VARCHAR)
Identifier of the first matching YARA rule, or NULL if none match
Return the identifier of the first YARA rule that matches the data.
SELECT yara.main.yara_first_rule('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }');
yara_match_count (data ANY, rules VARCHAR)
Number of YARA rules that match the data (INT)
Count how many YARA rules in a ruleset match the data.
SELECT yara.main.yara_match_count('evil worm', 'rule a { strings: $a = "evil" condition: $a } rule b { strings: $b = "worm" condition: $b }');
yara_matches (data ANY, rules VARCHAR)
True if the data matches ANY of the YARA rules (BLOB/VARCHAR data, VARCHAR rules)
Test whether a blob/text matches any rule in a YARA ruleset.
SELECT yara.main.yara_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }');
yara_scan (data ANY, rules VARCHAR)
Scan data against YARA rules; one row per matching rule (rule, namespace, tags)
Scan a constant blob against a ruleset, one row per matching rule with its namespace.
SELECT rule, namespace
FROM yara.main.yara_scan('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY rule;
yara_string_matches (data ANY, rules VARCHAR)
Scan data against YARA rules; one row per pattern hit (rule, identifier, offset, matched)
Scan a constant blob, one row per pattern hit, with the byte offset of each match.
SELECT rule, identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset";
| rule | identifier | offset | matched |
|---|---|---|---|
| demo | $a | 19 | malware |
Try these queries
Validate that a YARA ruleset compiles before scanning with it.
SELECT yara.main.yara_check('rule demo { strings: $a = "malware" condition: $a }') AS compiles;
Uses yara_check
Predicate: does the text match any rule in a ruleset?
SELECT yara.main.yara_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }') AS hit;
Uses yara_matches
Name the first rule that matches the data.
SELECT yara.main.yara_first_rule('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }') AS first_rule;
Uses yara_first_rule
Count how many rules in a ruleset match the data.
SELECT yara.main.yara_match_count('evil worm', 'rule a { strings: $a = "evil" condition: $a } rule b { strings: $b = "worm" condition: $b }') AS n;
Uses yara_match_count
Scan a constant blob into one row per matching rule, with its namespace.
SELECT rule, namespace
FROM yara.main.yara_scan('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY rule;
Uses yara_scan
Locate each pattern hit in the data with its byte offset.
SELECT identifier, "offset", matched
FROM yara.main.yara_string_matches('this file contains malware', 'rule demo { strings: $a = "malware" condition: $a }')
ORDER BY "offset";
Uses yara_string_matches
6 more examples in the Catalog, each listed under the table or function it uses.
Questions it can answer
Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.
- Does the text 'this file contains malware' match the YARA rule rule demo { strings: $a = "malware" condition: $a }? I just need a yes/no.
- For the ruleset rule demo { strings: $a = "malware" condition: $a }, what is the name of the first rule that matches the text 'this file contains malware'?
- How many YARA-X modules are compiled into this worker and available for a rule to import? Return the total.
- Is the `pe` module (for inspecting Windows PE executables) available to import in a rule on this worker? Answer by listing the module row for it.
YARA is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.
Related workers
Indicators of compromise
Security & forensics
Pull indicators of compromise out of threat reports and defang or refang them safely
Threat intel
Security & forensics
Classify IPs, domains, URLs, and file hashes offline, then enrich them against threat-intel reputation feeds
Secret scanning
Security & forensics
Find leaked API keys, tokens and private keys in text from SQL, offline and with redacted output