Skip to content

Latest commit

Β 

History

73 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RedPatch



RedPatch

Interactive Application Security Playground & Defense Simulator

Exploit vulnerable applications. Patch the source. Verify the fix.

All through one isolated, containerized security workflow.


Docker Labs License



How it works Β· Architecture Β· Labs Β· Quick Start


One vulnerability. Two perspectives. One complete security workflow.


πŸ•΅οΈ EXPLOIT Β  β†’ Β  πŸ’» PATCH Β  β†’ Β  πŸ€– VERIFY

Description

RedPatch is an interactive, containerized application security playground and defense simulator designed to bridge the gap between offensive penetration testing and defensive secure code remediation. Built with a lightweight FastAPI orchestration engine, RedPatch goes beyond traditional vulnerability discovery by guiding users through a complete three-step security lifecycle: Exploit, Patch, and Verify.

Users begin in Pentester Mode, analyzing attack surfaces and exploiting flaws such as SQL Injection or IDOR to capture flags. They then transition to Coder Mode, gaining direct real-time access to the application's source code within an isolated workspace to write and apply root-cause security fixes. Finally, an AI Security Layerβ€”built on an extensible provider abstractionβ€”evaluates the applied patch to verify whether the vulnerability has been completely resolved. By decoupling the host orchestration engine from external laboratory definitions through a declarative manifest system (manifest.json), RedPatch provides a modular, lightweight, and scalable environment for practical cybersecurity education.

Video Demo: Youtube


⚑ What makes RedPatch different?

Most security training environments teach you to find a vulnerability.

RedPatch makes you go one step further:

Exploit it β†’ understand it β†’ fix it β†’ verify the fix.

The platform combines offensive security practice with defensive code remediation inside disposable Docker-based environments.

No separate tools. No disconnected exercises. One continuous workflow.


🎯 How RedPatch Works

Pentester Mode

Interact with an intentionally vulnerable application and investigate its attack surface. Find the vulnerability. Exploit the application. Capture the flag.

demo-pentester.mp4


Coder Mode

The vulnerable application's source becomes available through the built-in workspace, allowing you to inspect and patch the underlying code. Inspect the vulnerable code. Patch it. Verify the remediation.

demo-coder.mp4

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           REDPATCH                              β”‚
β”‚                                                                 β”‚
β”‚     PENTESTER              CODER              AI AGENT          β”‚
β”‚   ─────────────          ─────────           ──────────         β”‚
β”‚   Find the flaw    β†’     Patch it      β†’     Verify it          β”‚
β”‚   Exploit the app        Modify code         Analyze fix        β”‚
β”‚                                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ€– AI Verification

Submit your remediation to the configured security analysis agent in coder mode.

The agent evaluates the patch and provides feedback on whether the vulnerability has actually been addressed.


πŸ—οΈ Architecture

RedPatch is built as a lightweight host orchestration engine rather than a collection of hardcoded labs.

flowchart LR

    USER[πŸ‘€ User]

    UI[Web Interface]
    ENGINE[FastAPI Host Engine]

    MANAGER[Lab Manager]
    DOCKER[Docker Service]
    PROXY[Async HTTP Proxy]
    AI[AI Service]

    MANIFEST[Lab Manifest]
    CONTAINERS[Isolated Lab Containers]
    PROVIDER[LLM Provider]

    USER --> UI
    UI --> ENGINE

    ENGINE --> MANAGER
    ENGINE --> DOCKER
    ENGINE --> PROXY
    ENGINE --> AI

    MANAGER --> MANIFEST
    DOCKER --> CONTAINERS
    AI --> PROVIDER
    PROXY --> CONTAINERS
Loading

Host Engine

app/main.py is the central application entry point.

It coordinates the web interface, lab lifecycle, workspace operations and request routing.

Lab Manager

app/services/module_manager/lab_manager.py handles the lab catalog and manifest.

The engine does not contain the implementation of every vulnerability lab.

Instead, it consumes metadata describing available laboratories.

Container Service

app/services/container_services/ isolates Docker-specific lifecycle operations from the rest of the application.

AI Service

app/services/ai/ provides the AI analysis layer and separates provider-specific logic from the host engine.


🧩 Labs

The labs are maintained separately from the RedPatch engine.

This repository contains the platform and orchestration layer.

The actual vulnerable applications and laboratory implementations live in:

Explore RedPatch Labs

The host engine discovers available laboratories through app/labs/manifest.json.

A simplified entry looks like:

{
  "labs": {
    "SQLi": {
      "description": "SQL Injection",
      "submodules": [
        {
          "id": "sqli-0",
          "title": "SQL Injection - Authentication Bypass",
          "category": "web",
          "image_tag": "redpatch-lab/sqli-0:v1.0.0",
          "port": 5000,
          "dev_path": "./labs/sqli-0",
          "download_url": "..."
        }
      ]
    }
  }
}

The manifest acts as the bridge between the RedPatch engine and the externally maintained RedPatch Labs ecosystem.

Why separate the labs?

This separation keeps the platform modular:

redpatch
β”‚
└── Host / Orchestration
        β”‚
        └── manifest.json
                 β”‚
                 β–Ό
          redpatch-labs
                 β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό        β–Ό        β–Ό
      SQLi     IDOR     Command Injection

The engine manages how labs run.

The labs repository defines what the labs are.


πŸ” Containerized Execution

When a laboratory starts, RedPatch handles the runtime lifecycle through Docker.

Manifest
   β”‚
   β–Ό
Lab Selection
   β”‚
   β–Ό
Container Creation
   β”‚
   β–Ό
Workspace Preparation
   β”‚
   β–Ό
Interactive Session
   β”‚
   β–Ό
Teardown

This gives each active laboratory its own containerized runtime while keeping the orchestration logic inside the host engine.

RedPatch is an educational security playground. Its isolation model should not be treated as a hardened production sandbox for arbitrary hostile workloads.


πŸ€– AI Security Layer

The AI service is intentionally separated behind a provider abstraction.

                 AI Agent
                    β”‚
                    β–Ό
             Provider Interface
                    β”‚
                    β–Ό
             Gemini Provider

This means the rest of RedPatch does not need to depend directly on provider-specific API implementations.

The current configuration primarily supports Google Gemini.

βš™οΈ Managing Configuration

You can manage your AI credentials and platform settings through two methods:

1. Web UI Control Panel (Recommended)

Launch the application and click the Settings icon in the navbar to open the in-app management panel. This allows you to update your settings dynamically without restarting the server:

  • LLM Provider (e.g., gemini)
  • API Key
  • Model Selection (e.g., gemini-flash-lite-latest)

2. Local Configuration File

Alternatively, you can edit app/core/config.json directly:

{
  "API_KEY": "your_gemini_api_key_here",
  "LLM_PROVIDER": "gemini",
  "MODEL": "gemini-flash-lite-latest"
}

Or specify a custom configuration file path using environment variables:

CONFIG_JSON=app/core/config.json

⚑ Quick Start

Docker

docker network create redpatch_net
docker volume create redpatch_lab_tmp

# Linux / macOS
docker run -d \
  --name redpatch-app \
  -p 8000:8000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v redpatch_lab_tmp:/app/labs/archives \
  --network redpatch_net \
  msalihberk/redpatch:latest
  
# Windows
docker run -d `
  --name redpatch-app `
  -p 8000:8000 `
  -v //./pipe/docker_engine:/var/run/docker.sock `
  -v redpatch_lab_tmp:/app/labs/archives `
  --network redpatch_net `
  msalihberk/redpatch:latest

Docker Compose

git clone https://github.com/msalihberk/redpatch.git
cd redpatch

docker compose up -d --build

Then open:

http://localhost:8000


πŸ› οΈ Development

Requirements

  • Python 3.10+
  • Docker / Docker Desktop
  • Git
git clone https://github.com/msalihberk/redpatch.git
cd redpatch

python -m venv .venv

Activate:

# Linux / macOS
source .venv/bin/activate

# Windows
.venv\Scripts\activate

Install:

pip install -r requirements.txt

Run:

uvicorn app.main:app --reload --port 8000

πŸ“ Project Structure

redpatch/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ main.py
β”‚   β”‚
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ config.py
β”‚   β”‚   └── config.json
β”‚   β”‚
β”‚   β”œβ”€β”€ labs/
β”‚   β”‚   └── manifest.json
β”‚   β”‚
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   β”œβ”€β”€ container_services/
β”‚   β”‚   └── module_manager/
β”‚   β”‚
β”‚   β”œβ”€β”€ static/
β”‚   └── templates/
β”‚
β”œβ”€β”€ docker-compose.yaml
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ SECURITY.md
└── LICENSE

The source tree follows the same separation as the runtime architecture:

Interface β†’ Engine β†’ Services β†’ External Labs


πŸ—ΊοΈ Roadmap

  • Containerized lab execution
  • Pentester Mode
  • Coder Mode
  • Manifest-driven lab discovery
  • Isolated workspaces
  • AI-assisted verification
  • Docker distribution
  • More vulnerability categories
  • Additional LLM providers
  • Automated security regression testing
  • Expanded lab ecosystem

🀝 Contributing

RedPatch is designed to grow through both engine improvements and new security laboratories.

If you want to contribute:

  • Improve the host engine
  • Add infrastructure capabilities
  • Create new labs in the redpatch-labs repository
  • Report bugs
  • Suggest new security scenarios

Read the Contributing Guide before submitting a pull request.


⭐ Like the idea?

Star the project and follow its evolution.



Built with ❀️ as a Harvard CS50x Final Project by Mustafa Salih Berk.

About

A FastAPI & Docker-powered interactive web security laboratory featuring Coder & Pentester modes, AI-assisted code analysis, and hands-on vulnerability scenarios.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages