Agent skill

Write Cve Rule

by evdenis in evdenis/cvehound

Write, debug, or validate a CVEhound detection rule (.cocci or .grep) for a Linux kernel CVE.

GPL-3.0Auto-check passedSecurity

Install Write Cve Rule

skills CLI
$ npx skills add evdenis/cvehound --skill write-cve-rule -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install evdenis/cvehound write-cve-rule --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/evdenis/cvehound.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/write-cve-rule .claude/skills/write-cve-rule && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
write-cve-rule
GitHub stars
138
Token cost
~2.5k tokens
SKILL.md length
1,295 words
Files
3 (incl. scripts)
Skills in repo
1
Repo updated
First seen
Licence
GPL-3.0

At a glance

Write, debug, or validate a CVEhound detection rule (.cocci or .grep) for a Linux kernel CVE.

  • Works in 6 steps: Gather the inputs → Decide what to match → Write it → …
  • Adding a rule under cvehound/cve/
  • SKILL.md covers 1. Gather the inputs, 2. Decide what to match, 3. Write it and 4. Validate, plus 3 more sections
  • Runs Shell scripts from its folder; calls git and uv

What it does

Write Cve Rule is an agent skill from evdenis/cvehound. Write, debug, or validate a CVEhound detection rule (.cocci or .grep) for a Linux kernel CVE. Use when adding a rule under cvehound/cve/, when a rule's slow tests fail, or when asked why a rule does or doesn't fire on a kernel tree. Not for general Coccinelle work outside this repository.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files, including scripts (for example `scripts/compare-rule.sh` and `scripts/validate-rule.sh`).

It sits in Security, covering Vulnerability scanning. It works with Linux. The repository describes itself as: Check linux sources dump for known CVEs. The licence is GPL-3.0.

When your agent uses it

  • Adding a rule under cvehound/cve/
  • A rules slow tests fail
  • Asked why a rule does
  • Doesnt fire on a kernel tree

Example prompts

  • “s slow tests fail, or when asked why a rule does or doesn”
  • “/write-cve-rule”

Requirements

  • A Bash shell

Workflow steps

6 steps, taken from the step headings in SKILL.md.

  1. Gather the inputs
  2. Decide what to match
  3. Write it
  4. Validate
  5. Repository gotchas
  6. .grep rules

What it can do on your machine

Read from SKILL.md and the folder at commit ad72a1c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 2 files in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • git
    • uv

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and uv, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Write Cve Rule loads about 2.5k tokens when it runs. Until then it costs about 76 tokens; SKILL.md has 1,295 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~76
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from evdenis/cvehound at commit ad72a1c, republished under its GPL-3.0 licence (© evdenis). 1,295 words, ~2,512 tokens.

Download SKILL.mdSave it as .claude/skills/write-cve-rule/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
write-cve-rule
description
Write, debug, or validate a CVEhound detection rule (.cocci or .grep) for a Linux kernel CVE. Use when adding a rule under cvehound/cve/, when a rule's slow tests fail, or when asked why a rule does or doesn't fire on a kernel tree. Not for general Coccinelle work outside this repository.

Writing a CVEhound detection rule

A rule is one file in cvehound/cve/CVE-YYYY-NNNNN.cocci (or .grep). That is the entire change. Do not add, edit, or parametrize tests — tests/conftest.py discovers every rule and generates the whole suite from the file's metadata headers.

Syntax questions go to docs/COCCINELLE_CHEATSHEET.md. Everything below is workflow and the things about this repository that will otherwise trip you up.

1. Gather the inputs

You cannot start without these:

  • CVE ID
  • the mainline fix commit hash
  • the commit that introduced the bug, if it is known
  • the affected file paths, relative to the kernel root
bash
git -C tests/linux show <fix_commit>          # the diff is the specification
git -C tests/linux log -1 --format=%H <fix_commit>

Look for a Fixes: trailer in the fix commit message — that is usually the introducing commit. If there is none and you can only guess, you will use Detect-To: instead.

2. Decide what to match

Read the diff and take the first branch that applies:

The fix…ApproachMatch
adds code (a check, an init)Missing Fix Detectionthe absence of it, via ... when != <the new code>
changes a value or flagUnfixed Code Detectionthe old value
removes codeUnfixed Code Detectionthe presence of the removed code
refactors logicUnfixed Code Detection / hybridthe distinctive vulnerable shape

Match the invariant, not the era. The rule runs on every commit in Fixes..Fix and on old stable branches — the code's exact shape drifts across that range, and a pattern that transcribes today's spelling (the precise condition, per-era disjunction branches) silently misses the eras nobody transcribed. Prefer a stable anchor that existed the whole time (the call or computation that is the bug — that line gets the star) plus a @fixed@ helper matching what the fix added, with the error rule depends on !fixed. cvehound/cve/CVE-2017-1000112.cocci is the worked example; docs/WRITING_RULES.md → "Rule 7: Match the invariant, not the era" has the full treatment and the loosening toolbox.

Then read three existing rules of the same shape before writing yours — they are the real house style, and they encode workarounds no prose captures:

bash
cd cvehound/cve
grep -l "memset" *.cocci              # initialization bugs
grep -l "copy_to_user" *.cocci        # information leaks
grep -l "when != if" *.cocci          # missing checks
grep -l 'depends on' *.cocci          # inter-rule dependencies
grep -l 'depends on .*&&' *.cocci     # conjunctions: several conditions must hold

3. Write it

Start from contrib/blank.cocci. The skeleton:

cocci
/// Files: <paths from kernel root, space-separated, one line>
/// Fix: <full hash of the fixing commit>
/// Fixes: <full hash of the introducing commit>   // or Detect-To: <hash>

@err@
@@

vulnerable_function(...)
{
	...
*	<the line that identifies the vulnerability>
	...
}

A rule is match rules only. The report is the *: on a match spatch prints a unified diff of the starred lines, and CVEhound reads that. No output means no detection. There is no script rule and no position/@p for reporting — the rules must run under a spatch built without Python. (A position used as a match constraint is still fair game; see cvehound/cve/CVE-2020-27777.cocci.)

Non-negotiables:

  • Anchor the pattern in a named function. A bare return -1; or kfree(x); with no enclosing context is the single largest source of false positives here.
  • Never declare a virtual rule. CVEhound passes no -D, so a rule gated on one is dropped before translation and reports nothing, silently. To turn a rule off, comment it out and say why.
  • * is not decoration. It switches the patch into match mode, which flips the default quantification of un-annotated ... from forall to exists. Adding or removing it changes what matches. Every rule stars a line, so that flip is always in force: never write exists in a rule header — it is a no-op. To make one ellipsis hold on all paths (a when != guard otherwise only constrains a single witness path), annotate that ellipsis with when forall.
  • Star the deciding rule only, and only its identifying line. A starred rule prints whenever it matches, whatever the other rules did — so a * on a helper (classically a @fix@ rule that recognises the fix) reports on fixed trees, and starring several lines across ... reports a partial match.
  • Star a line spatch can delete — in every version of the range. A star on a lone } is silently dropped (the branch matches and reports nothing); a star on a token an older version builds via a macro aborts spatch with "try to delete an expanded token".
  • Independent sites are separate starred rules (OR); a conjunction needs depends on. Chain the rules so the last one depends on all the others — @err_c depends on err_a && err_b@ — and star only that last rule. See cvehound/cve/CVE-2021-3347.cocci and cvehound/cve/CVE-2021-3609.cocci for the AND, cvehound/cve/CVE-2016-5195.cocci for the OR.
  • Filter by function with the pattern, not after the fact. "Only in foo()" is written by anchoring inside the definition — foo(...) { ... when any <pattern> ... when any }, with \(foo1\|foo2\) for several. Never wrap a statement body in <+... ...+>: same meaning, orders of magnitude slower. See cvehound/cve/CVE-2021-28971.cocci, cvehound/cve/CVE-2017-1000112.cocci.
  • The rule's literal tokens decide how much of the tree spatch parses. A name left literal where a metavariable would do, or more than five rules that star something in one file, and spatch stops skipping files it cannot match. validate-rule.sh measures it; docs/WRITING_RULES.md → "Rule 8: Keep the grep query selective" explains it.

docs/WRITING_RULES.md → "Rule 2: Star discipline" has the full treatment of the star rules — the corpus exceptions, the failure symptoms, and the measured costs.

When the rule is a judgement call, prefer a false positive — a missed CVE is worse than a noisy one.

Show full SKILL.md (479 more words)Show less

4. Validate

bash
.agents/skills/write-cve-rule/scripts/validate-rule.sh cvehound/cve/CVE-YYYY-NNNNN.cocci

It checks the filename, the metadata block, that the rule parses, that no star sits on a lone brace, that the Files: paths resolve at both ends of the range -- the fix commit and Fixes:/Detect-To: -- and that the rule fires at Fix~ and at the old end of the range, and is silent at Fix. A spatch failure at any of those (the expanded-token abort, typically) is reported as its own verdict; .grep rules get the same three detection verdicts through grep. It does this by extracting just the Files: paths at each commit, so it does not touch or check out the kernel working tree.

Then the real thing, which is the authority:

bash
uv run pytest --runslow --cve=CVE-YYYY-NNNNN

5. Repository gotchas

A Files: path that resolves nowhere is silent. If none of the paths exist, check_cve skips the rule unless the caller explicitly requests all_files=True, which turns a bad path into a false negative. A rename does this as surely as a typo: the tests run the rule across the whole Fixes..Fix range and on old stable branches, so list every name the file has had there (drivers/tty/n_hdlc.c drivers/char/n_hdlc.c). The validator checks both ends and prints the historical name when the older end has none.

The hashes are test inputs. test_03_on_fix checks out Fix: and Fix~; test_04_on_fixes does the same around Fixes:/Detect-To:; test_05_between_fixes_fix checks every commit in between. A wrong hash is a failing test, not a cosmetic error. Fixes: and Detect-To: populate the same field — set exactly one.

Register legitimate failures as data, never as xfail. If a fix was never backported to a stable branch, add the (cve, branch) pair to missing_backports in tests/conftest.py — and delete it once the backport lands: the xfail is strict, so a backported pair fails the suite. If the upstream Fixes: tag is wrong, add (cve, reason) to ownfixes in tests/test_00_metadata.py.

Disputed CVEs go in cvehound/cve/disputed/. Directory placement is the only thing that drives the all / assigned / disputed groups; the default --cve assigned skips that directory.

Headers are never resolved. CVEhound runs spatch with --no-includes, so match what is written in the .c file, not what a macro expands to after preprocessing.

A content overlay never shadows your work here — in a dev checkout cvehound uses the repo's own cvehound/cve/ unless CVEHOUND_CONTENT is set, and the test suite pins CVEHOUND_CONTENT=none. cvehound update writes only to ~/.local/share/cvehound/.

6. .grep rules

Use these only when Coccinelle cannot express the pattern (assembly, tracepoint macros). Format: the same /// metadata block, then one regex per line. All patterns must match for the CVE to be reported; the file is consumed by grep -rPzle, so the regexes are PCRE with \s, \w, and cross-line matching available. See cvehound/cve/CVE-2017-1000255.grep.

Reference

  • docs/WRITING_RULES.md — the complete guide: metadata semantics, worked examples from five real CVEs, advanced techniques, troubleshooting
  • docs/COCCINELLE_CHEATSHEET.md — syntax and the vulnerability-pattern catalog
  • contrib/blank.cocci, contrib/template.cocci — starting points
  • AGENTS.md — repository conventions (style, tests, architecture)

© evdenis, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in .agents/skills/write-cve-rule of evdenis/cvehound.

  • SKILL.md
  • scripts/compare-rule.sh
  • scripts/validate-rule.sh

Open the folder on GitHubat commit ad72a1c

Compare with similar skills

Write Cve Rule next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Write Cve Rule compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Write Cve Rule this skillevdenis/cvehound138—~2.5kAutomated safety check: PassGPL-3.0
Performing Agentless Vulnerability Scanningmukul975/Anthropic-Cybersecurity-Skills34k—~3.8kAutomated safety check: PassApache-2.0
Performing Authenticated Scan With Openvasmukul975/Anthropic-Cybersecurity-Skills34k—~2.3kAutomated safety check: WarnApache-2.0
Host Cve Validatorinfometa/workbuddyskills344—~1.8kAutomated safety check: NotesProprietary
Kernel Securitymohitmishra786/low-level-dev-skills253—~1.6kAutomated safety check: PassMIT
Alibabacloud Ecs Sec Kernelaliyun/alibabacloud-ecs-troubleshoot-skills1481 repos~2.4kAutomated safety check: NotesApache-2.0

Similar skills

  • Performing Agentless Vulnerability Scanning

    mukul975/Anthropic-Cybersecurity-Skills

    Configure and execute agentless vulnerability scanning using network protocols, cloud snapshot analysis, and API-based discovery to assess systems without installing endpoint agents.

    34k GitHub stars~3.8k tokensUpdated 1 mo ago
    SecurityAuto-check passed
  • Performing Authenticated Scan With Openvas

    mukul975/Anthropic-Cybersecurity-Skills

    Configure and execute authenticated (credentialed) vulnerability scans using OpenVAS/Greenbone Vulnerability Management (GVM) with SSH, SMB, or ESXi credentials to detect local vulnerabilities…

    34k GitHub stars~2.3k tokensUpdated 1 mo ago
    SecurityAuto-check: warnings
  • Host Cve Validator

    infometa/workbuddyskills

    主机安全CVE漏洞修复验证引擎。从主机漏扫报告(Excel)或CVE编号自动提取漏洞,查询威胁情报(NVD/EPSS/MSRC/OVAL),生成修复脚本(fix.sh/fix.ps1),SSH验证脚本可执行性,产出修复验证报告。覆盖 Linux(centos/ubuntu/debian/suse/amazon/fedora/alpine/arch) + Windows + Web-CMS…

    344 GitHub stars~1.8k tokensUpdated today
    SecurityAuto-check: notes
  • Kernel Security

    mohitmishra786/low-level-dev-skills

    Linux kernel security skill for LSM, hardening, and exploit mitigations.

    253 GitHub stars~1.6k tokensUpdated 3 mo ago
    SecurityAuto-check passed
  • Alibabacloud Ecs Sec Kernel

    aliyun/alibabacloud-ecs-troubleshoot-skills

    Linux 内核态 CVE 漏洞检测与 PoC 验证工具,专为 AI Agent 设计. An agent skill from aliyun/alibabacloud-ecs-troubleshoot-skills.

    148 GitHub starsUsed in 1 repo~2.4k tokens
    SecurityAuto-check: notes
  • Alibabacloud Ecs Sec Userspace

    aliyun/alibabacloud-ecs-troubleshoot-skills

    Linux 用户态安全入侵检测与取证工具,专为 AI Agent 设计。自动判断服务器是否被入侵, 提供完整证据链和可执行修复建议。51 个安全分析器覆盖进程/网络/认证/持久化/Rootkit/ 恶意软件/内存取证/容器逃逸等 12 类检测维度,10 个数据采集器全面采集系统状态, 映射 103+ MITRE ATT&CK 技术,支持 standalone/docker/k8s 三种部署模式。

    148 GitHub starsUsed in 1 repo~2.6k tokens
    DevOps & CloudAuto-check: notes

Works with

Categories

Questions about Write Cve Rule

What does Write Cve Rule do?

Write, debug, or validate a CVEhound detection rule (.cocci or .grep) for a Linux kernel CVE. Write Cve Rule is an agent skill from evdenis/cvehound.grep) for a Linux kernel CVE.

When should I use Write Cve Rule?

Write Cve Rule fits situations like: adding a rule under cvehound/cve/; A rules slow tests fail; asked why a rule does; doesnt fire on a kernel tree.

How do I install Write Cve Rule in Claude Code?

Run `npx skills add evdenis/cvehound --skill write-cve-rule -a claude-code`. Or copy the skill folder (.agents/skills/write-cve-rule in evdenis/cvehound) into .claude/skills/write-cve-rule in your project. Claude Code loads it when a task matches its description.

How do I install Write Cve Rule in Codex?

Run `npx skills add evdenis/cvehound --skill write-cve-rule -a codex`. Or copy the skill folder (.agents/skills/write-cve-rule in evdenis/cvehound) into .agents/skills/write-cve-rule in your project. Codex loads it when a task matches its description.

Can I use Write Cve Rule in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add evdenis/cvehound --skill write-cve-rule -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/write-cve-rule, .gemini/skills/write-cve-rule, .github/skills/write-cve-rule and .opencode/skills/write-cve-rule in your project.

What does Write Cve Rule need to run?

Going by SKILL.md and its folder, Write Cve Rule needs a shell for the scripts in its folder and the command-line tools its instructions call (git and uv). Our summary lists: A Bash shell.

Does Write Cve Rule access the network?

SKILL.md contains no URLs. Its commands use git and uv, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Write Cve Rule safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Write Cve Rule use?

Write Cve Rule is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Write Cve Rule use?

About 2.5k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Write Cve Rule?

Skills that share tags, products or a category with Write Cve Rule: Performing Agentless Vulnerability Scanning (mukul975/Anthropic-Cybersecurity-Skills, 34k stars), Performing Authenticated Scan With Openvas (mukul975/Anthropic-Cybersecurity-Skills, 34k stars), Host Cve Validator (infometa/workbuddyskills, 344 stars) and Kernel Security (mohitmishra786/low-level-dev-skills, 253 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Write Cve Rule?

evdenis (a GitHub user) maintains it in evdenis/cvehound, which has 138 GitHub stars. The repository was last updated on October 2, 2026.

Source: evdenis/cvehound on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.