Skip to content

About

A CI/CD-integrated API fuzzing pipeline that automatically tests endpoints for vulnerabilities and edge-case crashes using OpenAPI schemas and Schemathesis.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation

Automated API Fuzzing & Documentation Pipeline

A lightweight, CI/CD-integrated API fuzzing pipeline that uses property-based testing to automatically detect unhandled server exceptions (500 errors) before they reach production.

Overview

Developers often test the "happy path" of their APIs but neglect to test how their endpoints handle malformed or malicious data. This project solves that by automatically reading an application's OpenAPI specification and generating thousands of edge-case payloads (e.g., extremely large integers, null bytes, malformed strings) to attempt to crash the server.

If the API successfully catches the bad data and returns a 4xx error (like 422 Unprocessable Entity), the test passes. If the API logic breaks and throws a 500 Internal Server Error, the pipeline catches it, fails the build, and generates a security report.

Architecture & Tech Stack

  • Target Backend: FastAPI (Python)
  • Testing Engine: Pytest & Schemathesis
  • Schema Protocol: OpenAPI 3.0
  • CI/CD Automation: GitHub Actions

Language-Agnostic Core: While the mock target API in this repository is built with FastAPI, the fuzzing engine is entirely framework-agnostic. Because it targets the OpenAPI JSON specification, this exact testing pipeline can be pointed at APIs built in Node.js, Go, Java, or Ruby.

Key Features

  1. Zero-Config CI/CD Integration: The fuzzing pipeline runs automatically on every push and pull request via GitHub Actions.
  2. Visual Security Reports: Results are piped directly into the GitHub UI using Step Summaries, providing developers with immediate feedback on which endpoints crashed without having to dig through raw terminal logs.
  3. In-Memory Testing: The fuzzer hooks directly into the ASGI/WSGI application object. This allows for lightning-fast test execution in memory without needing to orchestrate or stand up a live web server during the testing phase.
  4. Targeted Route Fuzzing: Developers can test the entire API suite or isolate specific endpoints using Pytest's test-node targeting through custom functions (e.g., pytest test_fuzzer.py::test_specific_route).

Local Setup & Usage

Prerequisites

  • Python 3.10+

Installation

Clone the repository and install the dependencies:

git clone [https://github.com/DavidOprea/Auto_API_Doc_And_Fuzzer.git](https://github.com/DavidOprea/Auto_API_Doc_And_Fuzzer.git)
cd Auto_API_Doc_And_Fuzzer
pip install -r requirements.txt

Running the Fuzzer Locally

To run the property-based fuzzer against the entire FastAPI application:

pytest test_fuzzer.py -v --tb=line

To target a specific route (configured in the test file):

pytest test_fuzzer.py::test_get_user_fuzz -v --tb=line

How to Test Your Own Application

You can easily replace the mock backend in the app/ folder with your own Python web application.

For FastAPI (ASGI) Users

  1. Replace the contents of the app/ folder with your FastAPI project.
  2. Ensure your main application object can be imported in test_fuzzer.py (e.g., from app.main import app).
  3. Run the tests. Schemathesis will automatically detect your routes via FastAPI's native /openapi.json.

For Flask (WSGI) Users

  1. Replace the app/ folder with your Flask project.
  2. Because Flask does not generate OpenAPI schemas natively, you must configure a library (like flasgger or flask-smorest) to serve your schema, or provide a static openapi.json file.
  3. Open test_fuzzer.py and modify the loader to use WSGI:
    # Change this:
    schema = schemathesis.openapi.from_asgi("/openapi.json", app)
    
    # To this:
    schema = schemathesis.openapi.from_wsgi("/openapi.json", app)

⚙️ CI/CD Pipeline Workflow

This project utilizes GitHub Actions to enforce a strict quality gate. The workflow (.github/workflows/fuzzing_pipeline.yml) executes the following lifecycle on every push:

  1. Provisions an ephemeral Ubuntu runner.
  2. Installs Python and project dependencies.
  3. Executes the Schemathesis fuzzer against the in-memory application.
  4. Generates a markdown report of all failed endpoints.
  5. Publishes the report to the GitHub Actions dashboard.
  6. Fails the build if any 500 Internal Server Error responses are detected.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A CI/CD-integrated API fuzzing pipeline that automatically tests endpoints for vulnerabilities and edge-case crashes using OpenAPI schemas and Schemathesis.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages