AutoVuln-Builder is an autonomous DevSecOps agent that translates natural language requests into ready-to-deploy, intentionally vulnerable Infrastructure as Code (IaC) for cybersecurity training and CyberRange environments.
This project demonstrates how to tame a Large Language Model (LLM) for precise infrastructure generation by decoupling the "decision making" from the "code writing".
- The Brain (LLM & LangChain): Analyzes the user's scenario request and selects the appropriate services, ports, and vulnerabilities.
- The Guardrail (Pydantic): Enforces strict mathematical and logical rules (e.g., valid ports, allowed vulnerability types, database dependencies) to prevent AI hallucinations.
- The Factory (Jinja2): Takes the validated AI output and injects it into rigid, syntactically perfect templates to generate
docker-compose.ymland.Dockerfilefiles.
- Natural Language to Infrastructure (Prompt-to-IaC).
- Autonomous database provisioning if an application requires it.
- Built-in conditional logic (e.g., dynamically installing
mysqlionly for PHP containers). - 100% syntactically correct YAML and Dockerfile generation.
- Python 3.10+
- Docker & Docker Compose
- OpenAI API Key
-
Clone the repository:
git clone https://github.com/Augustin-Br/autovuln_builder.git cd autovuln_builder -
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up your API Key: Rename .env.example to .env and add your OpenAI API key:
OPENAI_API_KEY=sk-...
-
Generate the Scenario: Run the orchestrator script. It will call the AI and generate the infrastructure files in the output_scenario/ folder.
python main.py
-
Deploy the CyberRange:
cd output_scenario sudo docker compose up --build -
Test the Vulnerability (Example: SQLi): Open a new terminal and send an encoded payload to the generated web service:
curl -v -G "http://localhost:8080/index.php" --data-urlencode "user=' OR 1=1 -- "
Watch the Docker logs to confirm the payload successfully traversed the PHP backend and hit the database layer!