Interactive database inference attack simulator. Practice aggregation queries, discover inference vulnerabilities, and learn defensive countermeasures.
Database inference is a security threat in which an attacker derives sensitive information from seemingly innocuous query results. Even when direct access to confidential data is restricted, the combination of permitted queries, aggregate functions, and metadata can reveal protected information. This is a particular concern for statistical databases, data warehouses, and systems that provide analytical query access to multiple users with different privilege levels.
Unlike SQL injection, which exploits input validation flaws, inference attacks exploit the legitimate functionality of a database. An attacker uses authorized queries — counting, averaging, filtering — to narrow down results until they can deduce specific records or values that they should not be able to access.
Inference attacks exploit the mathematical relationship between aggregate query results and individual records:
| Technique | Method | Example |
|---|---|---|
| Direct inference | Query results directly reveal sensitive data | "SELECT AVG(salary) WHERE department = 'CEO Office'" returns one person's salary |
| Indirect inference | Combining multiple queries isolates individuals | Two queries with overlapping filters differ by one record |
| Tracker attacks | Crafting complementary queries that sum to the full database | Query for condition C plus query for NOT C equals all records |
| Homogeneity attacks | All records in a group share the same sensitive value | Every person in a filtered result has the same diagnosis |
| Background knowledge | External data combined with query results | Knowing someone is in a specific department plus aggregate data |
An inference attack uses legitimate queries on non-sensitive data to deduce sensitive information. For example, querying the average salary of a department with only one person reveals that person's exact salary. Even when direct access is denied, aggregation functions (COUNT, AVG, SUM) can leak individual data points.
When a query returns aggregate results for a small group, individual values can be deduced. If you know the sum of salaries for 5 people and the sum for 4 of them, simple subtraction reveals the 5th person's salary. This simulator demonstrates these attacks with guided scenarios on mock databases.
Polyinstantiation creates multiple instances of the same data at different classification levels. A Top Secret user sees the real data, while a Secret user sees a plausible but different version. This prevents inference attacks by eliminating the ability to detect that data exists at a higher classification level.
Key countermeasures include: cell suppression (hiding values in small groups), noise injection (adding random perturbation to query results), query restriction (limiting queries that return small result sets), polyinstantiation (multiple data versions by clearance), and differential privacy (mathematical guarantees against inference).
Database security is covered in CISSP Domain 8: Software Development Security. Key topics include database inference and aggregation attacks, polyinstantiation, views for access control, database encryption, and the role of the DBMS in enforcing security policies. Understanding these attacks is essential for the CISSP exam.
Format and beautify SQL queries with proper indentation, keyword capitalization, and line breaks. Supports MySQL, PostgreSQL, SQL Server, Oracle, and more.
Generate CONVERT() and CAST() syntax for MySQL, PostgreSQL, SQL Server, Oracle, and SQLite with dialect-specific type mappings.
Design comprehensive data classification policies with government (TS/S/C/U) or commercial (Restricted/Confidential/Internal/Public) schemas. Define handling rules for storage, transmission, disposal, and access with compliance overlays for HIPAA, PCI-DSS, GDPR, and CMMC.