Skip to main content

GitHub Actions status Supported Versions of Python PyPI package version

CVEhound

CVEhound is a tool for checking Linux sources for known CVEs. The tool is based on coccinelle rules and grep patterns. The tool checks sources for vulnerable code patterns of known CVEs and missing fixes for them.

  • What: The tool tries to find "unfixed" code of known CVEs;
  • How: The tool uses coccinelle/grep rules with patterns that helps to detect known CVE bugs or their fixes. Thus, sources are checked either for a presence of "unfixed" code pieces (e.g. CVE-2020-12912), or for an absence of a fix (e.g. CVE-2020-26088);
  • Why: If you have a git log then it's easier to check what CVEs are fixed based on a git history. However, many vendors (samsung, huawei, various iot, routers manufacturers) publish kernel sources as archives without a development log. In most cases their kernels are based on LTS kernels, but versions are far from upstream. Linux version string from Makefile will only give you information about what CVEs were fixed by kernel developers up to this version. It will not help you to understand what fixes were backported by a vendor itself. In this case it's possible to apply the tool and check "missing" CVE fixes.

CVEHound: Audit Kernel Sources for Missing CVE Fixes

Linux Security Summit 2021 Presentation (EN)

Linux Security Summit 2021 Presentation

ZeroNights 2021 Presentation (RU)

ZeroNights 2021 Presentation

Found issues in stable trees

Prerequisites

  • Python 3 (>=3.11)
  • grep with pcre support (-P flag)
  • coccinelle (>= 1.0.7)

Install prerequisites:

# Ubuntu, coccinelle uses libpython2.7 internally
# Seems like some ppas mark libpython dependency as optional
$ sudo add-apt-repository ppa:npalix/coccinelle
$ sudo apt install coccinelle libpython2.7

# Fedora
$ sudo dnf install coccinelle

# macOS
$ brew install coccinelle

Installation

To install the latest stable version just run the following command:

$ python3 -m pip install --user cvehound

For development purposes you may install cvehound in "editable" mode directly from the repository (clone it on your computer beforehand):

$ pip install -e .

To update the cve rules from github repository:

$ cvehound_update_rules

How to use

The simplest way to start using CVEhound is to run the following command:

$ cvehound --kernel ~/linux
Found: CVE-2020-27830
Found: CVE-2020-27152
Found: CVE-2020-29371
Found: CVE-2020-26088

where dir should point to the Linux kernel sources. CVEhound will check the sources for all cve patterns that you can find in cve dir. To check the sources for particular CVEs one can use:

$ cvehound --kernel ./linux --kernel-config --cve CVE-2020-27194 CVE-2020-29371
Checking: CVE-2020-27194
Found: CVE-2020-27194
MSG: bpf: Fix scalar32_min_max_or bounds tracking
FIX DATE: 2020-10-08 09:02:53
https://www.cve.org/CVERecord?id=CVE-2020-27194
Affected Files:
 - linux/kernel/bpf/verifier.c: CONFIG_BPF & CONFIG_BPF_SYSCALL
   linux/.config: affected
Config: ./linux/.config affected

Checking: CVE-2020-29371
Found: CVE-2020-29371
MSG: romfs: fix uninitialized memory leak in romfs_dev_read()
FIX DATE: 2020-08-21 16:52:53
https://www.cve.org/CVERecord?id=CVE-2020-29371
Affected Files:
 - linux/fs/romfs/storage.c: CONFIG_ROMFS_FS
   linux/.config: not affected
Config: ./linux/.config not affected

Other args:

  • --report - will produce json file with found CVEs Most of the metainformation in the generated report is taken from kernel.org vulns.git and CIP kernel-sec
  • --kernel-config or --kernel-config <file> - will infer the kernel configuration required to build the affected code (based on Kbuild/Makefiles, ifdefs are not checked) and check kernel .config file if there is one. Files the parser can't map to CONFIG_ options are reported as unknown and counted as affected
  • --check-strict - with --kernel-config, report only CVEs whose affected files are enabled in the .config. A CVE is dropped only when the evaluation explicitly rules every affected file out (e.g. the option is disabled, or the file belongs to another architecture); files unknown to the Kbuild parser are still reported with a warning
  • --arch - kernel architecture to analyze (x86, arm64, ...; ARCH spellings like x86_64 are normalized to the arch/ source directory). Defaults to the architecture from the .config banner, or x86
  • --files - will limit the scope of checked cves to the kernel files of interest
  • --exploit - check only for CVEs that are known to be exploitable (according to the CISA Known Exploited Vulnerabilities catalog)

Contributing

Development Setup

The project uses uv for dependency and environment management.

# Install uv (once, globally)
$ curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone and create the dev environment
$ git clone https://github.com/evdenis/cvehound.git
$ cd cvehound
$ uv sync                         # creates .venv and installs dev deps

# Install pre-commit hooks
$ uv run pre-commit install

# Run all linters, formatters, and type checks
$ uv run pre-commit run --all-files

# Run the test suite
$ uv run pytest

The project uses:

  • uv for dependency and environment management
  • ruff for linting and formatting
  • ty (beta) for static type checking — replaces mypy; version is pinned via uv.lock
  • pre-commit for automated code quality checks

Writing CVE Detection Rules

If you'd like to contribute new CVE detection rules, please see our comprehensive guides:

Templates:

  • contrib/template.cocci - Enhanced template with examples and comments
  • contrib/blank.cocci - Minimal template for new rules

If you use a coding agent, the repository ships a write-cve-rule skill in .agents/skills/ (picked up by OpenAI Codex, and by Claude Code via .claude/skills/). It drives the workflow above and runs .agents/skills/write-cve-rule/scripts/validate-rule.sh, which you can also call by hand — see AGENTS.md.

License

Python code is licensed under GPLv3. All rules in cvehound/cve folder are licensed under GPLv2.

Acknowledgements

I would like to thank the following projects and people behind them:

Release files for cvehound 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cvehound 1.3.0
File Size Uploaded
cvehound-1.3.0.tar.gz 1.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cvehound 1.3.0
File Interpreter ABI Platform
cvehound-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 3.4 MB

Release files / cvehound-1.3.0.tar.gz

Download URL cvehound-1.3.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
7ddc6ebb9c0fb3c4cc13cdeb9e7f413dc3ede7ff6571578ffbac6a3e7f680e09
BLAKE2b-256 checksum
How to use checksums
0a2d9644d7ffb1821478d36b191d8b2a3f1001b30d72b6752500ae22cd93cca0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / cvehound-1.3.0-py3-none-any.whl

Download URL cvehound-1.3.0-py3-none-any.whl
Size 1.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a4976078d252b55d8c4528a7204e0e4bec6c06a4ddd9d220cff00f58b9557acc
BLAKE2b-256 checksum
How to use checksums
dd6441c182103c0b71fcb0965f9bdcb44d8360ede7f798e87b929fba44125d54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.7.0

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

This release

1.3.0 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page