Abderrahmane Chafik
All projects

Application security · Defensive lab

Bastion-WAF

A defensive lab comparing request inspection across web application firewalls.

Project scope
Web request inspection and enforcement in a dedicated lab.
What was built
A Python reverse proxy with YAML rules and JSONL logs, alongside ModSecurity.
Evidence to review
The engineering report compares the custom prototype with established WAFs.

Technical walkthrough

Understand the request. Defend the application.

Incoming requestInspectionDecision

ARCHITECTURE STUDY · ILLUSTRATIVE

Observe first. Enforce deliberately.

Configuration checked against the README and inspection code. These are documented settings, not measured protection results.

UPSTREAM_URL

Choose the protected target

Points the reverse proxy at the application being protected in the lab.

ANOMALY_THRESHOLD = 5

Tune the decision boundary

The documented default threshold is configurable. Tuning changes how the WAF responds to detected anomalies.

WAF_MODE

Separate detection from blocking

In the main inspection path, detection-only logs threshold violations; blocking returns HTTP 403 for them. Separate rate-limit and binary-header checks can still block in either mode.

A defensive rule needs context: the target, the threshold and the enforcement mode all affect its behavior.

Read the source ↗

The question

A firewall rule is easier to trust when you understand what it sees. What does request inspection actually do between a client and a vulnerable application?

Inside the implementation

A multi-layer WAF laboratory: a custom Python reverse proxy with YAML signatures and JSONL blocked-request logs, alongside ModSecurity / OWASP CRS on Nginx and a DVWA target.

  1. Observe the request path

    Docker Compose connects the vulnerable target, open-source WAF and custom reverse proxy in a dedicated lab network.

  2. Inspect and decide

    The custom engine applies detection rules with a configurable anomaly threshold. Detection-only and blocking modes distinguish observation from enforcement in the main inspection path.

  3. Compare the defenses

    SQL injection and XSS examples support repeatable lab exercises. A documented dashboard and engineering report help compare the custom approach with established WAF systems.

Scope & lessons

A defensive learning environment, not a production security product. No independent benchmark establishes throughput or detection completeness. Rate limiting and binary-asset header checks can still block in detection-only mode. DVWA is intentionally vulnerable and belongs in an isolated, authorized laboratory.

Next project

CyberGuide-AI