SQL Injection Attempts

A Debian-first guide to identifying suspicious parameter-based database attack attempts, reviewing web logs, and reducing application exposure.

What this is

SQL injection is an attack that tries to manipulate database queries through unsafe application input handling. Attackers often place SQL syntax into URL parameters, form fields, headers, or cookies in an attempt to trigger unintended database behavior.

Even failed attempts are worth studying because they reveal what parts of the application attackers think may be weak.

What it looks like

Detect

Review recent web service logs

sudo journalctl -u caddy --since "1 hour ago"

Search for common SQL injection indicators in logs

sudo grep -Ei "union|select|sleep\(| or 1=1|--|%27|%22|information_schema|concat\(" /var/log/caddy/*.log 2>/dev/null | tail -n 100

Review application logs for database or query errors

sudo journalctl --since "1 hour ago" | grep -Ei "sql|database|query|exception|error"

Count repeated source IPs

sudo awk '{print $1}' /var/log/caddy/*.log 2>/dev/null | sort | uniq -c | sort -nr | head

Review targeted endpoints

sudo grep -Ei "\?|id=|search=|query=|user=|login=" /var/log/caddy/*.log 2>/dev/null | tail -n 100

Contain

Block a clearly abusive source IP

sudo ufw deny from <IP_ADDRESS>

Temporarily limit exposure of the affected endpoint if needed

# Restrict or shield targeted parameter-heavy paths during active abuse if operationally possible

Review application error exposure

# Make sure database or stack errors are not being revealed publicly

Recover

Review whether any suspicious requests caused real database impact

sudo journalctl --since "24 hours ago" | grep -Ei "sql|database|query|error|exception"

Identify the affected application paths and parameters

sudo grep -Ei "\?|id=|search=|query=|user=|login=" /var/log/caddy/*.log 2>/dev/null | tail -n 200

Review application code or query handling at the affected path

# Inspect the application logic behind the targeted endpoint

Recovery means confirming whether requests were only probes or whether they caused real application or database-side impact.

Prevent

Option 1 — Use safe query handling in the application

# Avoid unsafe string-based query construction in application code

Option 2 — Reduce public exposure of unnecessary endpoints

sudo ss -tulnp
sudo ufw status numbered

Option 3 — Review logs for parameter abuse regularly

sudo journalctl -u caddy --since "24 hours ago"

Option 4 — Keep the application stack updated

sudo apt update
sudo apt upgrade

Option 5 — Avoid exposing detailed database errors publicly

# Use safer production error handling and logging practices

Optional Tools & Hosting

Manual log review and secure application handling come first. Future recommendations may include tools that improve visibility, but the most important control is safe application design and smaller public exposure.

Notes

Environment Note

All commands shown are based on Debian-based systems unless otherwise noted.