A dual-architecture AppSec laboratory comparing vulnerable financial microservices against production-hardened implementations with custom SAST rules, weaponized PoC exploits, and automated audit reporting.
Quickstart • Architecture • Vulnerabilities vs Remediations • Exploit Demos • Custom SAST Rules • DevSecOps CI/CD
FinSec Guardian is a dual-architecture financial security laboratory designed for Application Security Engineers, Penetration Testers, and DevSecOps professionals. It demonstrates real-world OWASP API Security Top 10 (2023) vulnerabilities within banking APIs alongside enterprise-grade remediations:
- Vulnerable Core Banking API (
:8000): An intentionally vulnerable microservice demonstrating BOLA/IDOR, Mass Assignment, Hardcoded Secrets, and SSRF. - Hardened Core Banking API (
:8001): A production-ready microservice enforcing Object-Level Authorization, Pydantic DTO filtering, DNS-layer SSRF egress filters, and secure JWT handling. - AppSec Engine (
appsec-engine/): Custom Semgrep SAST rules, Bandit analyzers, and an automated audit report generator. - Automated PoC Exploit Suite (
exploits/): Weaponized scripts demonstrating exploitation and proving remediation. - DevSecOps Pipeline (
.github/workflows/): GitHub Actions workflow incorporating Gitleaks, Semgrep, Trivy SCA, and Schemathesis DAST fuzzing.
┌─────────────────────────────────┐
│ FinSec-Guardian Hub │
│ http://localhost:8000/ │
└──────────────┬──────────────────┘
│
┌──────────────────────────────┴──────────────────────────────┐
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ 🚨 Vulnerable API (:8000) │ │ 🛡️ Secure API (:8001) │
├──────────────────────────────┤ ├──────────────────────────────┤
│ ❌ No Object-Level Auth Checks│ │ ✅ get_current_user Context │
│ ❌ Hardcoded JWT Signing Key │ │ ✅ Dynamic ENV Secret Keys │
│ ❌ Unfiltered Model Updates │ │ ✅ Strict DTO (extra="forbid")│
│ ❌ Blind Webhook Egress │ │ ✅ DNS & Private IP Filter │
└──────────────┬───────────────┘ └──────────────┬───────────────┘
│ │
▼ ▼
┌──────────────────────────────┐ ┌──────────────────────────────┐
│ 💥 BOLA: Alice Balance Leaked│ │ 🔒 403 Forbidden Enforced │
│ 💥 Mass Assignment: Bob Admin│ │ 🔒 422 Extra Field Rejected │
│ 💥 SSRF: AWS IMDS Accessible │ │ 🔒 400 SSRF Filter Blocked │
└──────────────────────────────┘ └──────────────────────────────┘
| OWASP Category | Vulnerable Implementation (app/vulnerable/) |
Secure Implementation (app/secure/) |
CVSS v3.1 |
|---|---|---|---|
| API1:2023 BOLA / IDOR | Direct object access by account_id with zero caller verification. |
Depends(get_current_user) verifies caller ownership or is_admin. |
8.6 (High) |
| API2:2023 Broken Auth | Static string literal "insecure_dev_secret_key_12345" used in jwt.encode. |
os.getenv("JWT_SECRET_KEY") with algorithm and issuer restrictions. |
8.2 (High) |
| API3:2023 Mass Assignment | user.update(update.dict()) allows overwriting is_admin and role. |
Strict Pydantic DTO with ConfigDict(extra="forbid"). |
8.8 (High) |
| API7:2023 SSRF | requests.get(callback_url) blind fetch allows hitting AWS IMDS 169.254.169.254. |
DNS pre-resolution + IP subnet blocklist (10.0.0.0/8, 169.254.0.0/16, 127.0.0.0/8). |
9.8 (Critical) |
Spins up both the Vulnerable API (http://localhost:8000) and the Secure API (http://localhost:8001) simultaneously in isolated containers:
# Build and start all services
docker compose up --build
# Verify running containers
docker compose ps- Vulnerable API Swagger UI: http://localhost:8000/docs
- Secure API Swagger UI: http://localhost:8001/docs
# 1. Create and activate virtual environment
python -m venv venv
# Windows:
.\venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# 2. Install dependencies
pip install -r app/requirements.txt
# 3. Terminal A: Run Vulnerable API on port 8000
uvicorn app.vulnerable.main:app --host 0.0.0.0 --port 8000 --reload
# 4. Terminal B: Run Secure API on port 8001
uvicorn app.secure.main:app --host 0.0.0.0 --port 8001 --reloadFinSec Guardian includes standardized CLI PoC exploit scripts under exploits/. You can run them against both the vulnerable and secure APIs to observe real-time security behaviors:
Bob (User 102) steals Alice's (User 101) balance:
# Against Vulnerable API (Exploit Confirmed)
python exploits/poc_idor.py --url http://localhost:8000
# Against Secure API (Exploit Blocked with 403 Forbidden)
python exploits/poc_idor.py --url http://localhost:8001[+] Testing BOLA / IDOR against: http://localhost:8000
============================================================
[✓] Authenticated as Bob (User ID: 102)
[*] Sending unauthorized request to read Alice's Account (101)...
[🚨 VULNERABILITY CONFIRMED - BOLA/IDOR DETECTED!]
Target Account: 101
Owner Name: Alice Wonderland
Balance Leaked: $50,000.00 USD
Status Code: 200 OK (Expected 403 Forbidden)
Bob (User 102) injects {"is_admin": true, "role": "admin"} into his profile update:
# Against Vulnerable API (Privilege Escalation Confirmed)
python exploits/poc_mass_assignment.py --url http://localhost:8000
# Against Secure API (Blocked with 422 Unprocessable Entity)
python exploits/poc_mass_assignment.py --url http://localhost:8001[+] Testing Mass Assignment / BOPLA against: http://localhost:8000
=================================================================
[✓] Authenticated as Bob (User ID: 102 | Initial Role: 'user' | is_admin: False)
[*] Sending PATCH request to escalate privileges...
[🚨 VULNERABILITY CONFIRMED - MASS ASSIGNMENT SUCCESSFUL!]
Target User ID: 102
New Role: admin (Escalated from 'user')
is_admin Flag: True (Overwritten!)
Status Code: 200 OK (Property overwrite allowed)
Targeting cloud instance metadata (169.254.169.254) through webhook verification:
# Against Vulnerable API (Blind Outbound Request Confirmed)
python exploits/poc_ssrf_metadata.py --url http://localhost:8000
# Against Secure API (Blocked by Egress Filter with 400 Bad Request)
python exploits/poc_ssrf_metadata.py --url http://localhost:8001Located under appsec-engine/semgrep-rules/:
idor-check.yaml: Identifies endpoints receiving ID path parameters without an authentication dependency (Depends(...)).no-hardcoded-jwt.yaml: Flags string literals passed directly as JWT secret keys injwt.encodeorjwt.decode.ssrf-detection.yaml: Flags unvalidated dictionary parameters passed directly intorequests.get/post.
# Direct CLI Runner (Recommended on Windows, macOS, Linux):
python appsec-engine/scan.py
# Or via Docker:
docker run --rm -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config /src/appsec-engine/semgrep-rules/ /src/app/Generate an automated Markdown security assessment report and terminal audit dashboard:
python appsec-engine/report_generator.pyGenerated report is saved to: docs/appsec-audit-report.md.
The GitHub Actions pipeline (.github/workflows/appsec-pipeline.yml) implements multi-layered security gates:
- Secret Detection:
gitleaks-actiondetects committed credentials and private keys. - SAST Scanning:
semgrep-actionexecutes custom security rules and generates SARIF alerts. - SCA Dependency Audit:
trivy-actionscansrequirements.txtfor known CVEs. - DAST Dynamic Fuzzing: Launches the API and executes
schemathesisfuzzing againstopenapi.json.
| User ID | Username | Role | Initial Balance | Intended Privileges |
|---|---|---|---|---|
101 |
alice |
user |
$50,000.00 |
Standard customer account |
102 |
bob |
user |
$150.00 |
Standard customer account (Used in PoCs) |
999 |
admin |
admin |
$1,000,000.00 |
Security Officer / Administrator |
Created by: Mehdi Mejri
This project was developed independently out of curiosity, passion for Application Security (AppSec), and a drive to explore the practical boundaries of modern fintech API defenses, OWASP vulnerabilities, and DevSecOps engineering.
Made with ❤️ by Mejri Mehdi













