SQL Injection Risk Analysis API + Web UI — A full-stack security service that analyzes SQL query strings, detects suspicious injection patterns, assigns a risk score, and surfaces results through authenticated API endpoints and a React dashboard.
SQL injection is one of the most common and dangerous vulnerabilities in web applications. QueryShield acts as a pre-execution inspection layer — analyzing SQL query strings before they are executed and returning a structured security risk report.
The system inspects queries for suspicious constructs, assigns weighted scores, and classifies severity levels.
Example attack query caught by QueryShield:
SELECT * FROM users WHERE username = 'admin' OR 1=1 --QueryShield response:
{
"id": 1,
"query_text": "SELECT * FROM users WHERE username = 'admin' OR 1=1 --",
"risk_score": 60,
"severity": "high",
"flags": "OR_ALWAYS_TRUE,COMMENT_INJECTION",
"analysis_summary": "Multiple indicators consistent with injection behavior",
"created_at": "2026-03-09T03:39:11.208111",
"user_id": 1
}| Layer | Technology |
|---|---|
| Backend | Python, FastAPI |
| Frontend | React, TypeScript, Vite, Tailwind CSS |
| Database | PostgreSQL, SQLAlchemy ORM |
| Auth | JWT (python-jose), Passlib (bcrypt) |
| Infrastructure | Docker, Docker Compose |
| Cloud | AWS EC2 |
| API Tooling | Uvicorn, Pydantic |
- JWT Authentication — Secure user registration and login with token-based access control
- SQL Risk Analysis Engine — Detects injection indicators such as always-true conditions, comment truncation, UNION-based attacks, and suspicious schema enumeration
- Risk Scoring System — Assigns numeric scores and severity levels (
low,medium,high,critical) based on matched detection rules - Query Logging — Stores every analyzed query in PostgreSQL, tied to the authenticated user
- Protected Endpoints — History retrieval and high-risk filtering behind auth middleware
- Modern Web Dashboard — React + Tailwind UI that lets you sign up, log in, paste queries, view live analysis, and browse history/high-risk queries
- UX* — Clear navigation, color-coded severity badges, and thoughtful empty/loading/error states that showcase practical product thinking
- Containerized Deployment — Full Docker Compose stack with persistent PostgreSQL volume
- Cloud Hosted — Live on AWS EC2, accessible via public IP
| Method | Endpoint | Description |
|---|---|---|
POST |
/auth/register |
Create a new user account |
POST |
/auth/login |
Authenticate and receive a JWT |
POST |
/auth/token |
OAuth2 token endpoint used by Swagger UI |
| Method | Endpoint | Description |
|---|---|---|
POST |
/query/analyze |
Analyze a SQL query and store the result |
GET |
/query |
Retrieve all stored analyses |
GET |
/query/high-risk |
Retrieve only high-risk queries |
Client Request
│
▼
JWT Authentication Middleware
│
▼
POST /query/analyze
│
▼
SQL Risk Analysis Engine
├── Pattern Detection
├── Risk Score Calculation
└── Severity Classification
│
▼
Store Result → PostgreSQL
│
▼
Structured JSON Response → Client
# Clone the repo
git clone https://github.com/The1keyy/queryshield.git
cd queryshield
# Set up Python virtual environment
python3 -m venv venv
source venv/bin/activate
# Install backend dependencies
pip install -r requirements.txt
# Run the API (FastAPI + PostgreSQL)
uvicorn app.main:app --reloadVisit the interactive docs at: http://127.0.0.1:8000/docs
On top of the API, QueryShield ships with a small frontend dashboard non-technical users can try without writing any code.
- Landing Page — High-level overview with an example analysis and calls-to-action (“Try live analyzer”, “View API docs”)
- Auth — Email + password registration and login, backed by the same JWT auth used by the API
- Live Analyzer — Paste a SQL query, run analysis, and see:
- Color-coded severity (
low,medium,high,critical) - Risk score out of 100
- Matched rule flags (e.g.
OR_ALWAYS_TRUE,COMMENT_INJECTION) - Human-readable summary of why the query is risky
- Color-coded severity (
- History — Table of all your past analyses with timestamps, severities, scores, query preview, and flags
- High-Risk Only — Focused view of queries whose scores exceed the configured
high_risk_threshold
In a second terminal, from the project root:
cd frontend
# Install frontend dependencies
npm install
# Point the UI at your local API (optional if you keep defaults)
echo 'VITE_API_URL=http://127.0.0.1:8000' > .env
# Run the React dev server
npm run devThen open the UI at http://127.0.0.1:5173:
- Register a new account in the UI (or via
/auth/register) - Login to receive a JWT stored in the browser
- Use the Live Analyzer to inspect queries
- Explore History and High-Risk views to see persisted results
# Build and start full stack (API + PostgreSQL)
docker compose up -dThis spins up:
- API container running FastAPI on port
8000 - PostgreSQL container with a persistent volume
QueryShield is live on an AWS EC2 instance:
- Launch EC2 instance (Ubuntu)
- Install Docker & Docker Compose
- Clone repository and build image
- Run stack with
docker compose up -d - Open port
8000via EC2 security group
Built by Keyshawn Jeannot — Computer Science student at UMass Boston, focused on backend engineering, cloud infrastructure, and defensive security systems.
QueryShield demonstrates backend API architecture, secure authentication design, database modeling and persistence, containerized deployment, and cloud infrastructure workflows — applied to a real-world security problem.