QueryFence is an open-source library for Java that helps detect SQL queries that may lead to data leaks between tenants during the integration testing process, before the code is deployed to production.
THE PROBLEM
In multi-tenant SaaS applications that share a database, each customer's data is often separated by a tenant_id column. A single query that forgets this condition can inadvertently allow a customer to access another customer's data.
This error is very difficult to detect during code reviews, especially when SQL is automatically generated by Hibernate, JPA, or Spring Data. Integration tests can still succeed even if the SQL does not ensure tenant isolation.
KEY FEATURES
HOW TO USE
QueryFence supports Java 17+, JUnit 5, Maven, Gradle, Spring Boot, Hibernate/JPA, MyBatis, and JdbcTemplate on PostgreSQL and MySQL.
Simply add the dependency com.steelreed:queryfence-spring-test:0.1.0 with scope test, create the file src/test/resources/queryfence.yml to declare the tables that need protection, and then run the integration tests as usual.
No need to modify test code or add annotations.
DIFFERENCE
Unlike static analysis tools that only analyze source code, QueryFence checks the actual SQL queries executed by the application, including SQL generated automatically by ORM.
QueryFence does not replace Row-Level Security or Hibernate Filters but adds an additional layer of checks in CI, helping to early detect risks of lacking tenant isolation.
QUALITY AND TESTING
The project is developed with the support of AI, but I have directly reviewed and tested it thoroughly through 260 standard test cases, mutation testing, and experiments on real applications to assess the error detection capability and false positive rates.
The goal of QueryFence is to help Java Backend teams build safer multi-tenant SaaS applications, reduce the risk of data leaks between customers, and detect errors early in the development phase rather than waiting until production.
No talks yet. Create the first talk

The SQL query forgot to filter tenant_id when running the integration test.
Auto-translated ·No reviews yet

Lớp bộ nhớ dành cho phát triển ứng dụng AI

Dán URL website nhận ngay phiên bản nướng chín tầm cỡ Product Hunt

Thiết kế chi tiết cơ khí 3D tham số và chuẩn bị in 3D, mã nguồn mở

Switch Claude Code and ChatGPT accounts without signing again

Stay close to the command line

Animated web backgrounds your AI coding agent can install
Reviews & comments