A sophisticated tool for analyzing CVE vulnerabilities against Linux kernel configurations
VEX Kernel Checker is an advanced vulnerability analysis tool that correlates CVE (Common Vulnerabilities and Exposures) data with Linux kernel configurations to determine whether specific vulnerabilities affect a given kernel build. It processes VEX (Vulnerability Exploitability eXchange) files and provides automated analysis of vulnerability impact based on:
- Kernel configuration analysis - Maps CVEs to required CONFIG options
- Patch analysis - Extracts source files from security patches
- Makefile parsing - Analyzes build system dependencies
- Architecture awareness - Considers target architecture implications
vex-kernel-checker/
βββ vex-kernel-checker.py # Main CLI application (modular implementation)
βββ vex_kernel_checker/ # Modular Python package
β βββ __init__.py # Package initialization
β βββ common.py # Shared data structures and utilities
β βββ base.py # Base classes and performance tracking
β βββ cve_manager.py # CVE data fetching and management
β βββ config_analyzer.py # Kernel configuration analysis
β βββ vulnerability_analyzer.py # Core vulnerability analysis logic
β βββ patch_manager.py # Patch fetching and analysis
β βββ architecture_manager.py # Architecture-specific logic
β βββ report_generator.py # VEX report generation
β βββ main_checker.py # Main orchestration logic
βββ tests/ # Clean, comprehensive test suite
β βββ run_tests.py # Modern test runner with coverage
β βββ test_common.py # Tests for shared utilities
β βββ test_base.py # Tests for base functionality
β βββ test_cve_manager.py # CVE management tests
β βββ test_config_analyzer.py # Configuration analysis tests
β βββ test_vulnerability_analyzer.py # Core analysis tests
β βββ test_patch_manager.py # Patch management tests
β βββ test_architecture_manager.py # Architecture tests
β βββ test_report_generator.py # Report generation tests
β βββ test_integration.py # End-to-end integration tests
βββ examples/ # Sample data and configurations
β βββ README.md # Usage examples
β βββ test_demo.config # Sample kernel config
β βββ test_vex.json # Sample VEX file
β βββ [other samples] # Test data and examples
βββ docs/ # Comprehensive documentation
βββ scripts/ # Development and utility scripts
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container build configuration
βββ Makefile # Build and test automation
βββ [other config files] # Project configuration
- Multi-level caching system (Makefile, config, source analysis)
- Parallel processing for large vulnerability datasets
- Smart search ordering and aggressive optimization
- Cache hit/miss tracking with performance statistics
- Kernel CVE filtering: Automatically identifies and analyzes only kernel-related CVEs (use
--analyze-all-cvesto override) - Driver-specific CONFIG detection: Intelligently extracts specific driver configs (e.g.,
CONFIG_DRM_XE) from CVE descriptions to avoid false positives from broad parent configs (e.g.,CONFIG_DRM) - GitHub-prioritized patch analysis: Fetches and analyzes security patches with GitHub as the primary source for reliability
- Config-only fallback: Graceful degradation when patch data unavailable
- Makefile intelligence: Recursive parsing with variable expansion
- Architecture filtering: ARM-focused analysis with multi-arch support
- AI-assisted triage (optional): Uses Claude AI to reduce manual triage by analyzing CVE relevance against actual kernel configuration
- Thread-safe NVD API rate limiting with exponential backoff
- Comprehensive error handling and validation
- Existing analysis preservation (only modifies with
--reanalyse) - Detailed progress reporting with status indicators
- Automatic patch checking when API credentials provided
- Intuitive command-line interface with helpful error messages
- Verbose mode for debugging and development
- Cache management with
--clear-cacheoption
- Comprehensive test suite with >90% code coverage
- Performance benchmarking and optimization tracking
- Configuration validation and environment verification
- Continuous integration with automated quality checks
- MIT licensed with comprehensive documentation
- Python 3.8 or higher
- Linux environment (tested on Ubuntu/Debian)
- Internet connection for CVE data fetching
pip install vex-kernel-checker
# With AI assistant support (OpenAI/Anthropic)
pip install vex-kernel-checker[ai]
# With all optional dependencies
pip install vex-kernel-checker[all]git clone https://github.com/laerdal/vex-kernel-checker.git
cd vex-kernel-checker
pip install -e .
# Or with AI support
pip install -e ".[ai]"pip install requests selenium beautifulsoup4 lxml- NVD API Key: Register at NVD API
- Microsoft Edge WebDriver: Download from Microsoft Edge WebDriver
After installation, use vex-kernel-checker command (or vex-kernel-checker if running from source).
vex-kernel-checker \
--vex-file vulnerabilities.json \
--kernel-config /boot/config-$(uname -r) \
--kernel-source /lib/modules/$(uname -r)/build# Create a configuration file
vex-kernel-checker --create-config my-config.ini
# Edit the file with your settings, then run
vex-kernel-checker --config my-config.iniPath Resolution in Config Files:
- Input paths (vex-file, kernel-config, kernel-source, edge-driver): Relative paths are resolved relative to the config file location
- Output paths (output, log-file): Relative paths are resolved relative to the current working directory where you run the command
This allows you to store config files anywhere and have outputs generated in your current working directory.
vex-kernel-checker \
--vex-file vulnerabilities.json \
--kernel-config /path/to/kernel/.config \
--kernel-source /path/to/kernel/source \
--api-key YOUR_NVD_API_KEY \
--edge-driver /path/to/msedgedriver \
--verbose# Override config file settings with command-line arguments
vex-kernel-checker --config my-config.ini --verbose --reanalysevex-kernel-checker \
--vex-file vulnerabilities.json \
--kernel-config /path/to/.config \
--kernel-source /path/to/source \
--reanalyse \
--output updated_vulnerabilities.json| Option | Description | Required |
|---|---|---|
--config |
Path to configuration file (.ini, .json, .cfg, .config) | β |
--create-config |
Create a sample configuration file and exit | β |
--config-format |
Format for created config file (ini/json) | β |
--vex-file |
Path to VEX JSON file | β * |
--kernel-config |
Path to kernel config file (.config) | β * |
--kernel-source |
Path to kernel source directory | β * |
--output |
Output file path (default: update in place) | β |
--log-file |
Log file path for detailed logging | β |
--reanalyse |
Re-analyze CVEs with existing analysis | β |
--cve-id |
Process only specific CVE ID | β |
--verbose, -v |
Enable detailed logging | β |
--config-only |
Disable patch checking (faster) | β |
--api-key |
NVD API key for patch analysis | β |
--edge-driver |
Path to Edge WebDriver executable | β |
--clear-cache |
Clear all internal caches | β |
--performance-stats |
Show detailed performance metrics | β |
--detailed-timing |
Show detailed method timing (very verbose) | β |
--analyze-all-cves |
Analyze all CVEs (default: kernel-related only) | β |
| Option | Description | Default |
|---|---|---|
--ai-enabled |
Enable AI-powered vulnerability analysis | false |
--ai-provider |
AI provider: openai or anthropic |
openai |
--ai-model |
AI model to use | gpt-4 |
--ai-api-key |
API key for AI provider (or set env var) | - |
| Option | Description | Default |
|---|---|---|
--local-access |
Local shell access available on device | true |
--no-local-access |
No local shell access (filters AV:L CVEs) | - |
--adjacent-network |
Adjacent network access available | true |
--no-adjacent-network |
Network-isolated device (filters AV:A CVEs) | - |
--network-access |
Network/internet access available | true |
--no-network-access |
No network connectivity (filters AV:N CVEs) | - |
| Option | Description |
|---|---|
--dt-url |
Full URL to download VEX (includes project UUID) |
--dt-api-url |
Dependency-Track API URL (e.g., https://deptrack.example.com/api) |
--dt-api-key |
API key for authentication (or set DT_API_KEY env var) |
--dt-project-uuid |
Project UUID |
--dt-project-name |
Project name (alternative to UUID) |
--dt-project-version |
Project version (default: latest) |
--dt-parent-name |
Parent project name (for hierarchical projects) |
--dt-parent-uuid |
Parent project UUID |
--dt-upload |
Upload analyzed results back to Dependency-Track |
--dt-upload-url |
Custom upload URL (defaults to {api-url}/v1/vex) |
Note: Options marked with β
* are required unless provided in a configuration file or using Dependency-Track integration (--dt-url or --dt-project-name).
The VEX Kernel Checker supports configuration files to simplify usage by storing commonly used settings. This is particularly useful for repeated analysis with the same parameters.
- INI format (
.ini,.cfg,.config) - Human-readable with section headers - JSON format (
.json) - Machine-readable structured format
# Create a sample INI configuration file
vex-kernel-checker --create-config my-config.ini
# Create a sample JSON configuration file
vex-kernel-checker --create-config my-config.json --config-format jsonINI Format (my-config.ini):
[vex-kernel-checker]
vex-file = /path/to/vulnerabilities.json
kernel-config = /path/to/.config
kernel-source = /path/to/kernel/source
api-key = your-nvd-api-key
edge-driver = /usr/bin/msedgedriver
verbose = true
performance-stats = trueJSON Format (my-config.json):
{
"vex-file": "/path/to/vulnerabilities.json",
"kernel-config": "/path/to/.config",
"kernel-source": "/path/to/kernel/source",
"api-key": "your-nvd-api-key",
"edge-driver": "/usr/bin/msedgedriver",
"verbose": true,
"performance-stats": true
}Note: Config file keys use hyphens to match CLI argument names (e.g.,
kernel-configmatches--kernel-config). Underscores are also supported for backward compatibility.
# Use configuration file
vex-kernel-checker --config my-config.ini
# Override config settings with command-line arguments
vex-kernel-checker --config my-config.ini --verbose --reanalyse
# Mix configuration file with additional options
vex-kernel-checker --config my-config.ini --cve-id CVE-2023-1234Command-line arguments take precedence over configuration file settings, allowing you to override specific options while keeping others from the config file.
The examples/ directory contains sample configuration files:
examples/sample-config.ini- Basic INI format exampleexamples/sample-config.json- Basic JSON format exampleexamples/production-config.ini- Comprehensive production example
When NVD API key and WebDriver are available:
- Fetches CVE details from NVD API
- Extracts patch URLs from CVE references, prioritizing GitHub sources
- Downloads patch content using optimized fetching strategy:
- GitHub direct access (fastest, most reliable)
- GitHub alternatives using extracted commit IDs
- Original URLs with Selenium WebDriver fallback
- Other patch repositories (kernel.org, lore.kernel.org) as last resort
- Analyzes affected source files and configuration dependencies
- Maps to kernel configuration options
When patch data is unavailable:
- Fetches basic CVE information
- Performs heuristic analysis based on CVE metadata
- Provides conservative assessment requiring manual review
Input VEX files should follow this structure:
{
"vulnerabilities": [
{
"id": "CVE-2023-XXXXX",
"details": "Vulnerability description",
"analysis": {
"state": "not_affected|affected|under_investigation",
"justification": "component_not_present|requires_configuration|...",
"detail": "Detailed analysis explanation",
"timestamp": "2025-01-01T12:00:00Z"
}
}
]
}The tool uses CycloneDX v1.6 vulnerability states:
not_affected: Vulnerability does not affect this kernel configurationexploitable: Vulnerability affects this kernel configuration and requires attentionin_triage: CVE has been analyzed but requires manual review to determine impactresolved: Vulnerability has been patched or mitigatedresolved_with_pedigree: Resolved with additional tracking informationfalse_positive: Incorrectly identified as a vulnerability
When viewing analysis reports, CVEs are categorized as:
- β Not Affected: Vulnerable code/component not present or not configured
- π§ Resolved: Security patch already applied or vulnerability mitigated
β οΈ Exploitable: Requires immediate attention - vulnerable and exploitable- π In Triage: Analyzed but needs manual review to determine exact impact
- β Unanalyzed: Not yet analyzed (run without
--cve-idfilter to analyze all) - β False Positive: Incorrectly flagged (rare)
code_not_present: Vulnerable component/code not compiled or includedvulnerable_code_not_present: Specific vulnerable code path not presentrequires_configuration: Specific configuration needed for vulnerabilityrequires_dependency: External dependency required for vulnerabilityrequires_environment: Specific runtime environment needed (e.g., network access, local shell)
Filter out CVEs based on CVSS attack vector requirements. This is useful for embedded devices with restricted access:
# Device has no local shell access (e.g., SSH requires certificate auth) - filter out AV:L CVEs
vex-kernel-checker --config my-config.json --no-local-access
# Device is network-isolated - filter out AV:A and AV:N CVEs
vex-kernel-checker --config my-config.json --no-adjacent-network --no-network-access
# Device has no network at all - filter out all network-based CVEs
vex-kernel-checker --config my-config.json --no-network-access| Option | Description | CVSS Attack Vector |
|---|---|---|
--no-local-access |
No local shell access (e.g., SSH requires certificate auth) | AV:L (Local) |
--no-adjacent-network |
Device is network-isolated from adjacent systems | AV:A (Adjacent) |
--no-network-access |
Device has no network connectivity | AV:N (Network) |
CVEs filtered by attack vector are marked as not_affected with justification requires_environment.
You can also set these in your JSON config file:
{
"local-access": false,
"adjacent-network": true,
"network-access": true
}VEX Kernel Checker integrates with Dependency-Track to download VEX files and upload analysis results.
# Download VEX from Dependency-Track, analyze, and save locally
vex-kernel-checker \
--dt-url "https://deptrack.example.com/api/v1/bom/cyclonedx/project/{uuid}" \
--dt-api-key "your-api-key" \
--kernel-config /path/to/.config \
--kernel-source /path/to/kernel/source \
--output analyzed-vex.json# Full round-trip: download, analyze, and upload back to Dependency-Track
vex-kernel-checker \
--dt-url "https://deptrack.example.com/api/v1/bom/cyclonedx/project/{uuid}" \
--dt-api-key "your-api-key" \
--dt-upload \
--kernel-config /path/to/.config \
--kernel-source /path/to/kernel/source# Look up project by name (optionally with parent)
vex-kernel-checker \
--dt-api-url "https://deptrack.example.com/api" \
--dt-api-key "your-api-key" \
--dt-project-name "my-firmware" \
--dt-project-version "1.0.0" \
--dt-parent-name "my-product" \
--dt-upload \
--kernel-config /path/to/.config \
--kernel-source /path/to/kernel/source[vex-kernel-checker]
kernel-config = /path/to/.config
kernel-source = /path/to/kernel/source
# Dependency-Track settings
dt-api-url = https://deptrack.example.com/api
dt-api-key = your-api-key
dt-upload = true
# Option 1: Use project UUID directly
dt-project-uuid = your-project-uuid
# Option 2: Use project name (with optional parent)
dt-project-name = my-firmware
dt-project-version = 1.0.0
dt-parent-name = my-productexport DT_API_KEY="your-dependency-track-api-key"The tool implements sophisticated caching for optimal performance:
- Makefile Cache: Parsed Makefile content and variables
- Config Cache: Resolved configuration option mappings
- Source Analysis Cache: Source file analysis results
- Path Cache: File path resolution results
Run with --performance-stats to see cache hit rates and timing information:
Cache Performance:
makefile: 145 hits, 23 misses (86.3% hit rate)
config: 89 hits, 15 misses (85.6% hit rate)
Overall Cache Hit Rate: 86.1%
Primary focus on ARM architectures with support for:
- ARM32 (arm)
- ARM64 (aarch64, arm64)
- Limited x86/x86_64 support
Architecture-specific configuration options are automatically filtered.
The tool provides comprehensive error handling:
- Network failures: Automatic retry with exponential backoff
- API rate limiting: Thread-safe rate limiting with global coordination
- Missing files: Clear error messages with suggestions
- Invalid configurations: Validation with helpful diagnostics
- Bot detection: Automatic fallback to alternative patch sources
When accessing patch repositories, you may encounter access restrictions. The tool uses an optimized GitHub-first strategy to minimize these issues:
- Prioritizes GitHub sources - Direct access without bot detection issues
- Extracts commit IDs - Converts other URLs to reliable GitHub alternatives
- Detects bot protection pages (Cloudflare, "Just a moment", etc.)
- Tries multiple fallback sources (kernel.org, lore.kernel.org) as last resort
- Falls back gracefully to config-only analysis when needed
The GitHub-first approach significantly reduces bot detection issues while providing faster and more reliable patch access.
For detailed troubleshooting, see docs/BOT_DETECTION.md.
VEX Kernel Checker includes a comprehensive testing framework to ensure reliability and performance:
# Run quick smoke tests
make test-quick
# Validate your configuration
make validate VEX_FILE=examples/test_real_cve.json KERNEL_CONFIG=/path/to/.config KERNEL_SOURCE=/path/to/kernel# Run full test suite with coverage
make test-coverage
# Run performance benchmarks
make benchmark
# Format code and run quality checks
make workflow-fix- Unit Tests: Core functionality, configuration analysis, pattern matching
- Integration Tests: End-to-end workflows, file system operations
- Performance Tests: Scalability testing with datasets up to 200 CVEs
- Validation Tests: Environment setup, configuration verification
- Code coverage: >90% target
- Performance benchmarking for all major operations
- Automated configuration validation
- Cross-platform compatibility testing
See docs/TESTING.md for comprehensive testing documentation.
VEX Kernel Checker includes a GitHub Actions workflow for automated analysis with deptracker integration:
Automatically fetch VEX files from deptracker, analyze vulnerabilities, and upload results:
# Trigger manually or on schedule
uses: ./.github/workflows/vex-analysis.yml
with:
vex_url: 'https://deptracker.example.com/api/vex/latest'
kernel_config_url: 'https://example.com/kernel-configs/6.1.config'
kernel_source_git_url: 'https://github.com/torvalds/linux.git'
kernel_branch: 'v6.1'
upload_enabled: true
upload_url: 'https://deptracker.example.com/api/vex/upload'
secrets:
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
VEX_API_TOKEN: ${{ secrets.VEX_API_TOKEN }}Features:
- π₯ Fetch VEX files from deptracker or any HTTP(S) source
- π Automated vulnerability analysis with kernel config
- π Automated Edge WebDriver setup for patch checking
- π Flexible kernel branch/tag selection
- π€ Upload completed analysis back to deptracker (optional)
- β° Scheduled runs (weekly by default)
- π Detailed reports and artifacts
- π PR comments with analysis results
- π Secure execution with command injection protection
Quick Start:
See .github/workflows/QUICKSTART.md for setup instructions.
Full Documentation:
We welcome contributions from the cybersecurity and Linux kernel communities!
- π Report bugs via GitHub Issues
- π‘ Suggest features through feature requests
- π§ Submit pull requests following our Contributing Guidelines
- π Improve documentation and examples
- Additional architecture support (RISC-V, PowerPC, etc.)
- Enhanced patch parsing algorithms
- Performance optimizations
- Integration with CI/CD pipelines
- Web-based interface development
- Additional vulnerability database support
For detailed contribution guidelines, see CONTRIBUTING.md.
GitHub: https://github.com/Laerdal/vex-kernel-checker Issues: https://github.com/Laerdal/vex-kernel-checker/issues Releases: https://github.com/Laerdal/vex-kernel-checker/releases
This project is licensed under the MIT License - see the LICENSE file for details.
- Karsten S. Opdal (karsten.s.opdal@gmail.com) - Initial work and ongoing development
- AI Assistant - Architecture design and optimization contributions
- National Vulnerability Database (NVD) for CVE data
- Linux Kernel Community for patch information
- MITRE Corporation for CVE standards
- VEX Working Group for vulnerability exchange format
"Patch checking disabled"
- Ensure both
--api-keyand--edge-driverare provided - Verify WebDriver is executable:
chmod +x /path/to/msedgedriver
Rate limiting errors
- NVD API has rate limits (10 requests/minute without key, 50/minute with key)
- Tool automatically handles rate limiting with delays
WebDriver issues
- Ensure Microsoft Edge browser is installed
- Download WebDriver version matching your Edge browser version
- Check WebDriver permissions and path
Performance issues
- Use
--config-onlyfor faster analysis - Clear caches periodically with
--clear-cache - Monitor cache hit rates with
--performance-stats
- Web-based interface for easier access
- Integration with CI/CD pipelines
- Support for additional vulnerability databases
- Enhanced reporting and visualization
- Container-based deployment options