Database firewall
Also called SQL firewall, database gateway, SQL gateway, database activity monitoring and protection
A database firewall, also called a SQL firewall or database gateway, sits in the network path between applications and a database and checks each SQL statement against a policy before it reaches the database, then allows, alerts on or blocks it.
Most database attacks arrive as ordinary SQL: a statement that reads a whole customer table, drops a schema, or grants a role it should not. Audit trails record these after they run. A database firewall stops them before they run, by deciding each statement against a policy in the path between the application and the database.
How it works
- Sit in the path. Applications and tools connect to the firewall, which speaks the database’s own wire protocol and forwards traffic to the real database.
- Read each statement. The firewall parses the SQL, works out the statement type, the tables it touches and the identity that sent it.
- Decide. Rules match on facts such as the user, the source address, sensitive tables and the statement type, and each rule allows, alerts on or blocks the statement.
- Answer. An allowed statement goes to the database. A blocked one gets an error back, and nothing reaches the database.
- Record. Every decision is logged for investigation and audit evidence.
Why it matters
Application code should use prepared statements and parameterised queries, which the OWASP SQL Injection Prevention Cheat Sheet names as the primary defence. But many accounts reach a database without passing through that code: administrators, reporting tools, scripts and service accounts. A firewall applies one policy to all of them. Vendors document the approach in their own products, for example Oracle’s Audit Vault and Database Firewall. It also supports controls such as NIST SP 800-53 AC-6 (least privilege) by limiting what a privileged account can do in practice.
Database firewall vs DAM
| Database firewall | DAM | |
|---|---|---|
| When it acts | Before the statement runs | After, from audit records or captured traffic |
| Can it stop a statement? | Yes | No, it alerts |
| Typical output | Allow, alert or block decisions | Risk scores, alerts, forensic audit log |
Examples
- A reporting account sends
SELECT *on a card table from an unfamiliar address, and the statement is blocked. DROP TABLEon a production schema is refused outside an approved change.- A new policy runs in monitor mode for a week, showing what it would block, before it is switched to protect.
How SWOT supports it
SWOT DAM includes a database firewall, its SQL Gateway, for Oracle, SQL Server, PostgreSQL and MySQL. It decides every statement against your policy before it runs, with nothing installed on the database; a blocked statement returns the database’s own policy error and the session stays open. The same product reads each native audit trail for database activity monitoring. Each engine has its own page: Oracle database firewall, PostgreSQL database firewall, SQL Server database firewall and MySQL database firewall. See database security.
Questions
- How is a database firewall different from database activity monitoring?
- Database activity monitoring records and analyses what happened in a database, usually from audit trails or captured traffic, and alerts on it. A database firewall acts before a statement runs: it decides each statement against a policy and can stop it. Many teams use both, monitoring for evidence and investigation, and a firewall for the statements that must never run.
- Does a database firewall replace parameterised queries?
- No. Prepared statements with parameterised queries remain the primary defence against SQL injection in application code. A database firewall adds a control outside the application, which also covers accounts and tools the application team does not own, such as administrators, reporting tools and service accounts.
- Does a database firewall need software on the database server?
- Not when it runs as a gateway in the network path. The application connects to the gateway instead of the database, and the gateway forwards allowed statements. Other designs use an agent on the database host.
In SWOT
Sources
Related terms
- Database activity monitoring (DAM)Database activity monitoring (DAM) is the practice of capturing, analysing and alerting on who does what inside a database, including queries, schema changes, privilege grants and sign-ins, so that misuse is detected and every action is attributable.
- Sensitive data discoverySensitive data discovery is the automated process of finding and classifying data that needs protection, such as personal, financial, health or secret information, across databases, file stores and cloud services, so it can be inventoried, monitored and secured.
- Privileged access management (PAM)Privileged access management (PAM) is the set of controls and tools that decide who may use administrative access to critical systems, for how long and under what conditions, while keeping the credentials protected and every privileged session on record.
- Least privilegeLeast privilege is the security principle that every user, process and system should hold only the access rights it needs to perform its assigned tasks, and nothing more, so that a mistake or compromise affects as little as possible.
