Skip to content

YARA

Scan blobs and text for malware with YARA rules, straight from SQL

Connector software
Free and open source
Service credentials
Not needed
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"
Result
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.

setup.sql
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;

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'
);

3. Run a query

query.sql
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"
More example queries →
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
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]'
);

Overview

Defensive YARA-X malware scanning: compile YARA rules and scan blobs/text for matches, all in SQL over Apache Arrow.

Catalog

Everything yara exposes once attached — read straight from the worker's released build.

yara 1 schema
main 1 table · 6 functions

YARA rule compilation and malware-scanning functions.

Schema examples (7)
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;
Tables
yara_modules 2 examples2 cols

YARA-X modules compiled into this worker that a rule may import, one per row.

Columns
modulenot null VARCHAR
The name of a YARA-X module compiled into this worker — the string a rule may `import`, e.g. `pe`, `elf`, `hash`, `math`.
descriptionnot null VARCHAR
What the module lets a rule inspect or compute (its file-format fields, hashes, or math over byte ranges).
ConstraintsPRIMARY KEY (module)
Examples (2)

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';
Link
Scalar functions
yara_check (rules VARCHAR) 1 example

True if the YARA rule source compiles, false otherwise (validation)

Arguments
rules VARCHAR
YARA rule source to validate — the text whose rules are compiled
ReturnsBOOLEAN
Example

Validate that a YARA ruleset compiles before using it to scan.

SELECT yara.main.yara_check('rule demo { strings: $a = "malware" condition: $a }');
Link
yara_first_rule (data ANY, rules VARCHAR) 1 example

Identifier of the first matching YARA rule, or NULL if none match

Arguments
data ANY
The content to scan for malware/IOC signatures
rules VARCHAR
YARA rule source whose rules are compiled and matched against the data
ReturnsVARCHAR
Example

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 }');
Link
yara_match_count (data ANY, rules VARCHAR) 1 example

Number of YARA rules that match the data (INT)

Arguments
data ANY
The content to scan for malware/IOC signatures
rules VARCHAR
YARA rule source whose rules are compiled and matched against the data
ReturnsINTEGER
Example

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 }');
Link
yara_matches (data ANY, rules VARCHAR) 1 example

True if the data matches ANY of the YARA rules (BLOB/VARCHAR data, VARCHAR rules)

Arguments
data ANY
The content to scan for malware/IOC signatures
rules VARCHAR
YARA rule source whose rules are compiled and matched against the data
ReturnsBOOLEAN
Example

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 }');
Link
Table functions
yara_scan (data ANY, rules VARCHAR) 1 example

Scan data against YARA rules; one row per matching rule (rule, namespace, tags)

Arguments
data ANY
The constant content to scan for malware/IOC signatures
rules VARCHAR
YARA rule source whose rules are compiled and matched against the data
Returns columns
rule VARCHAR
Identifier of the matching YARA rule.
namespace VARCHAR
Namespace the rule was compiled under (default 'default').
tags VARCHAR[]
Tags declared on the matching rule (empty list if none).
Example

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;
Link
yara_string_matches (data ANY, rules VARCHAR) 1 example

Scan data against YARA rules; one row per pattern hit (rule, identifier, offset, matched)

Arguments
data ANY
The constant content to scan for malware/IOC signatures
rules VARCHAR
YARA rule source whose rules are compiled and matched against the data
Returns columns
rule VARCHAR
Identifier of the matching YARA rule.
identifier VARCHAR
Pattern/string identifier that hit, e.g. $a.
offset BIGINT
Byte offset of the match within the scanned data. 'offset' is a DuckDB reserved keyword — double-quote it in SQL.
matched VARCHAR
Matched bytes as UTF-8 when printable, else lowercase hex (NULL if unavailable).
Example

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";
Result
rule identifier offset matched
demo $a 19 malware
Link

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.