Skip to main content

A reproducer component that can compile OSS-Fuzz projects at specific versions and run test cases

Project description

OSV Reproducer

A Python package for reproducing OSS-Fuzz bugs listed by OSV (Open Source Vulnerabilities) as vulnerabilities.

Description

OSV Reproducer is a tool that helps security researchers and developers reproduce vulnerabilities reported in the OSV database. It provides a simple CLI that takes an OSV-ID, fetches the vulnerability data, and reproduces the bug in a containerized environment.

The tool automates the following workflow:

  1. Fetch OSV record by ID
  2. Extract metadata (project name, vulnerable commit, fixed commit, etc.)
  3. Retrieve OSS-Fuzz artifacts (test case, issue report)
  4. Prepare the versioned environment (clone repository at specific commit)
  5. Build and run the vulnerable version with the test case
  6. Verify if the test case crashes the program and matches the issue report
  7. Build and run the fixed version with the test case
  8. Verify if the fix addresses the vulnerability

Installation

pip install osv-reproducer

Usage

OSV Reproducer provides two main commands:

  • reproduce: Reproduces a vulnerability by building the vulnerable version and running it with the test case
  • verify: Verifies if a fix addresses a vulnerability by building the fixed version and running it with the test case

Basic Usage

# Reproduce a vulnerability
osv-reproducer -oid OSV-2023-XXXX reproduce

# Verify a fix
osv-reproducer -oid OSV-2023-XXXX verify

Options

# Required arguments
-oid, --osv_id          Identifier of the vulnerability in the OSV database (e.g., OSV-2023-XXXX)

# Optional arguments
-v, --version           Show version information
-vb, --verbose          Enable verbose output
-o, --output-dir        Directory to store output artifacts (default: ./osv-results)
--build-extra-args      Additional build arguments to pass to the fuzzer container as environment variables
                        Format: 'KEY1:VALUE1|KEY2:VALUE2'

Examples

# Reproduce a vulnerability with verbose output and custom output directory
osv-reproducer -vb -o ~/path/to/results/OSV-2023-1276 -oid OSV-2023-1276 reproduce

# Verify a fix with verbose output and custom output directory
osv-reproducer -vb -o ~/path/to/results/OSV-2023-1276_fix -oid OSV-2023-1276 verify

# Reproduce with additional build arguments
osv-reproducer -vb -o ~/path/to/results/OSV-2021-1361 -oid OSV-2021-1361 --build-extra-args "CFLAGS:-Werror,-Wunused-but-set-variable|CXXFLAGS:-Werror,-Wunused-but-set-variable" reproduce

Workflow

graph TD
    A[Input: OSV-ID] --> B[Fetch OSV Record]
    B --> C[Extract Metadata]
    C --> D[Retrieve OSS-Fuzz Artifacts]
    D --> E[Prepare Versioned Environment]
    
    subgraph Reproduction Mode
        E --> F[Build Vulnerable Version]
        F --> G[Run Test Case]
        G --> H[Verify Crash]
    end
    
    subgraph Verification Mode
        E --> I[Build Fixed Version]
        I --> J[Run Test Case]
        J --> K[Verify No Crash]
    end

Architecture

OSV Reproducer is built using the Cement framework and follows a modular architecture with handlers for different functionalities:

  • BuildHandler: Builds Docker images and runs containers for fuzzing projects
  • DockerHandler: Provides core Docker functionality
  • GCSHandler: Interacts with Google Cloud Storage to retrieve project snapshots
  • GithubHandler: Interacts with GitHub repositories to retrieve commits
  • OSSFuzzHandler: Interacts with OSS-Fuzz to retrieve issue reports and test cases
  • OSVHandler: Interacts with the OSV API to retrieve vulnerability records
  • ProjectHandler: Manages project information and initialization
  • RunnerHandler: Reproduces crashes and verifies them

This modular approach allows for flexibility in how core behaviors are implemented or swapped out, even at runtime or by user command-line options.

Requirements

  • Python 3.8+
  • Docker
  • Internet connection (to access OSV database, GitHub, and Google Cloud Storage)

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osv_reproducer-0.0.1.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

osv_reproducer-0.0.1-py3-none-any.whl (45.5 kB view details)

Uploaded Python 3

File details

Details for the file osv_reproducer-0.0.1.tar.gz.

File metadata

  • Download URL: osv_reproducer-0.0.1.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for osv_reproducer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2e04494364d499d0917af3dbbd0e12cb04946864bb2d24636f507e467b9245fc
MD5 6f8503cb9146101937c6e6bd45fbe33b
BLAKE2b-256 1830414fb4b3d342366466a828bec1000e832b8e9cf2a29a75c1ec0a7b0e1803

See more details on using hashes here.

File details

Details for the file osv_reproducer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: osv_reproducer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 45.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for osv_reproducer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 812d30391c859b9e53c17977dd5dbb7366d0585dda1ba3b8bf1e88ac44f79a7b
MD5 02570f3a5cc962e8af1a05384da81879
BLAKE2b-256 8962a9bb28e65045243a0d0ce54a1b3ba4e13e6707cfdad6353136e57d8ba5c7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page