1. Aim
To design and implement an intrusion detection system with a lightweight web application firewall that inspects incoming HTTP requests, detects common web attacks using signature-based rules and behavioural analysis, decides an action (allow, monitor, block or rate-limit), logs every decision and raises alerts for high-risk events.
2. Theory
- IDS vs WAF — an IDS observes and reports; a WAF sits inline and can reject the request. SentinelShield does both: it logs everything and blocks when confidence is high.
- Signature detection — regular expressions match known malicious patterns (e.g. ' OR 1=1, <script>, ../).
- Normalisation — payloads are URL-decoded twice, lower-cased and whitespace-collapsed so encoded attacks cannot evade the rules.
- Behavioural analysis — per-IP counters detect scanning, bursts and repeated failures even when no signature matches.
- Rate limiting — a fixed window counter limits requests per IP and temporarily blocks abusive sources.
3. Architecture
Client / attacker
|
v
[ Request Inspection ] normalise URL, query, body, headers
|
v
[ Rule Engine ] regex signatures -> attack type + confidence
|
v
[ Behaviour Analysis ] per-IP counters, scanning, bursts
|
v
[ Rate Limiter ] window counter -> RATE_LIMIT / temp block
|
v
[ Decision Engine ] ALLOW | MONITOR | BLOCK | RATE_LIMIT
| |
| +--> [ Logging ] security_events
| +--> [ Alerts ] high / critical
v
[ Mock Test App ] echoes the request, never executes it4. Algorithm
- Receive the request and extract method, endpoint, query, body and user agent.
- Normalise every surface (double URL decode, lower-case, collapse whitespace).
- Load enabled rules from the signature database.
- Match each rule; keep the highest-confidence hit and its severity.
- Update per-IP counters and compute behaviour metrics for the current window.
- If the request count exceeds the limit, return RATE_LIMIT and block the IP temporarily.
- Otherwise map confidence to a decision: ≥ BLOCK_CONFIDENCE → BLOCK, ≥ MONITOR_CONFIDENCE → MONITOR, else ALLOW.
- Sanitise the payload and write the event to the log.
- Raise an alert when the decision is BLOCK or the severity is CRITICAL.
- Forward allowed requests to the mock application and return its response.
5. Test table
| ID | Test case | Category | Payload | Expected decision |
|---|---|---|---|---|
| TC-01 | Normal request | Normal Request | laptop bags | ALLOW |
| TC-02 | SQL injection tautology | SQL Injection | ' OR '1'='1 | BLOCK |
| TC-03 | UNION SELECT extraction | SQL Injection | 1 UNION SELECT username, password FROM users | BLOCK |
| TC-04 | Reflected XSS script tag | XSS | <script>alert(1)</script> | BLOCK |
| TC-05 | XSS event handler | XSS | <img src=x onerror=alert(document.cookie)> | BLOCK |
| TC-06 | Directory traversal | Directory Traversal | ../../../../var/log/app.log | BLOCK |
| TC-07 | Encoded traversal | Directory Traversal | %2e%2e%2f%2e%2e%2fconfig | BLOCK |
| TC-08 | Local file inclusion | LFI | /etc/passwd | BLOCK |
| TC-09 | File wrapper inclusion | LFI | file:///etc/shadow | BLOCK |
| TC-10 | Command injection | Command Injection | ping 127.0.0.1; whoami | BLOCK |
| TC-11 | Command substitution | Command Injection | echo $(uname -a) | BLOCK |
| TC-12 | Scanner user agent | Suspicious | scan | MONITOR |
| TC-13 | Rate limit burst | Rate Limit | burst | RATE_LIMIT |
6. Observations
- Clean requests pass with confidence 0 and are logged as ALLOW.
- Classic SQLi and XSS payloads match with high confidence and are blocked immediately.
- Double-encoded payloads are only caught because of the normalisation step.
- Scanner user agents and burst traffic are caught by behaviour analysis, not signatures.
- Every blocked or critical event produces an alert in the alert queue.
7. Conclusion
A layered approach — normalisation, signatures, behaviour analysis and rate limiting feeding a single decision engine — detects the common OWASP-style web attacks reliably while keeping false positives low on legitimate traffic. The measured accuracy, precision, recall and F1 score for the practical test suite are shown on the Reports page. Signature detection alone is not sufficient; behavioural signals are what catch reconnaissance and abuse.