DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

One Missing WHERE Clause Can Expose Another Customer’s Data

A record-ID lookup without a tenant ownership check can expose another customer’s data. Here’s how to enforce and test the boundary.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Yes—if a shared application relies on its queries to enforce tenant ownership, a lookup that omits the tenant condition can return another customer’s records. That is an authorization failure, not just a SQL-style mistake. Authentication tells the application who is calling; authorization must also establish that the caller may access the specific tenant-owned record.

How a missing tenant condition becomes a data leak

Suppose a table stores records for multiple customers and an application fetches a record using only its record ID. If that ID does not itself enforce ownership and no other control checks the tenant, the query may match a record belonging to a different customer. A record identifier is not necessarily an authorization boundary.

As an Amazon Associate I earn from qualifying purchases.

The lookup needs to bind the resource to a tenant context the server has verified. One common approach is to match both tenant ID and resource ID. Another is to enforce ownership through a database policy or a more isolated database or schema. Whichever design is used, every relevant access path must pass through the same enforceable boundary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Tenant context must come from verified authorization

A tenant ID supplied in a URL, request body, or header is a selector, not proof of permission. The server must verify that the authenticated user or service is authorized for that tenant, including any applicable current membership, before using the tenant context to access data.

  • Authentication: identifies the user or service making the request.
  • Tenant authorization: confirms that identity is allowed to act for the requested tenant.
  • Resource authorization: ensures that the particular record belongs to that tenant or is otherwise accessible to the caller.

Parameterized SQL helps prevent injection, but it does not establish any of these ownership permissions by itself. Opaque or hard-to-guess identifiers can make enumeration harder; they do not replace authorization checks.

Choose an isolation boundary that fits the application

OWASP describes several ways to isolate tenant data. Each has different security and operational consequences; none is universally best. The key question is what happens if an application query forgets its tenant predicate, and whether the boundary can be audited and tested.

Approach Isolation boundary Effect of a missed application predicate Operational considerations
Separate databases Database separation, when access credentials and routing are also tenant-scoped. A query sent to the wrong database can still be dangerous; separation alone does not validate routing or authorization. Requires managing database provisioning, connections, migrations, and tenant routing.
Separate schemas Schema separation within a database, enforced through access and routing controls. A query using the wrong schema can cross the intended boundary if the application or database role can access it. Requires reliable schema selection, permissions, and schema lifecycle management.
Shared tables with PostgreSQL row-level security (RLS) Database policies restrict which rows a role can read or change. A policy can guard against a forgotten predicate when it covers the table and applies to the request role. Policies, tenant context, role attributes, and connection-pool behavior require careful configuration and testing.
Hybrid arrangement Different boundaries for different tenants, data classes, or requirements. Depends on the control used for each access path; inconsistent routing or policy coverage can leave gaps. Can meet varied isolation needs but adds design and operational complexity.

OWASP’s guidance compares these isolation patterns and their trade-offs: Multi-Tenant Security Cheat Sheet.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Using PostgreSQL row-level security safely

RLS can provide a database-side guardrail for shared tables, but it is only effective when policies cover the tenant-owned tables and the ordinary application request role cannot bypass them. PostgreSQL documents that superusers and roles with the BYPASSRLS attribute bypass row security policies. FORCE ROW LEVEL SECURITY does not constrain those roles. See the PostgreSQL row security documentation.

If a policy reads tenant identity from a PostgreSQL setting and the application uses pooled connections, connection reuse matters: state left on a connection can affect a later request. Prefer setting tenant context transaction-locally where possible, and test the actual pooling mode. The policy should fail closed when tenant context is absent rather than treating missing context as permission.

RLS does not eliminate the need to check alternate access paths, uncovered tables, privileged roles, or incorrect tenant context. Treat it as one layer in a complete authorization design, not a guarantee that cross-tenant access is impossible.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the boundary, not just the query code

Testing should prove that same-tenant access works and cross-tenant access is denied. Exercise the deployed request role and pooling configuration, because a test using a privileged database role may not reflect production behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Establish tenant context: derive it from an authenticated identity and verify current membership or service authorization before data access.
  2. Exercise both outcomes: confirm that a tenant can retrieve and update its own record, then attempt the same operations against another tenant’s record. The negative case should show that data is neither returned nor changed.
  3. Test missing context: verify that a request without valid tenant context is denied, including when an RLS policy depends on a tenant setting.
  4. Use the deployed conditions: run boundary tests with the actual application role and connection-pooling mode, including connection reuse.
  5. Audit coverage: inventory tenant-owned tables and compare them with enabled policies or the chosen ownership control. Verify deployed database role attributes, not just configuration files.
  6. Keep coverage current: require each new table to be classified as tenant-owned or not, and ensure tenant-owned tables receive the appropriate control.

OWASP’s multi-tenant guidance includes implementation and testing considerations for these controls: OWASP Multi-Tenant Security Cheat Sheet.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.