Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Stop Data Leaks in Multi-Tenant Apps with PostgreSQL Row-Level Security

Most multi-tenant SaaS bugs are not complex logic failures. They are simple, silent data leaks. They happen when a query is missing a single WHERE tenant_id = $1 clause. That one missing condition is all it takes for Tenant A to see Tenant B’s data. When you rely solely on application code to filter every database query, you are placing 100% trust in every developer who touches the…

Multi-tenant SaaS applications often suffer from simple data leaks caused by missing WHERE clauses in queries. Relying solely on application code to filter database queries is insecure as it places trust in developers. The solution is to move isolation to the database layer using PostgreSQL's Row-Level Security (RLS).

RLS enforces row isolation automatically, regardless of the application code. To implement RLS, enable it on tables and define policies that check session variables. Set the tenant context in your backend by configuring the session variable when opening a transaction. This eliminates the need for application code to append WHERE clauses.

Considerations for production include proper connection pooling, avoiding bypass of RLS by superusers, and maintaining indexes on tenant_id. By shifting isolation to PostgreSQL, you remove human error and keep tenant boundaries secure by default.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

HackerGadgets 4-in-1 Pi 5 HAT: RTL2832U, SX1262, GPS & RTC

The Guangzhou-based HackerGadgets RTL-SDR/LoRa/GPS/RTC HAT is a 4-in-1 RF expansion board for Raspberry Pi. It eliminates external USB dongles, though it still requires an internal USB bridge and caps…

  • HackerGadgets releases 4-in-1 Pi 5 HAT
  • Features RTL2832U, SX1262, GPS, and RTC
  • Compatible with Raspberry Pi 5's GPIO header

I benchmarked 5 ways to auto-tune a robot arm's PID gains. Random search broke the safety limits in 73.8% of trials. Safe BO: 1.8%.

Hand-tuning PID gains is slow, and every payload change means starting over. Letting an optimiser explore on the real machine is tempting — but a "trial" there isn't a wasted data point, it's a torque…

  • Random search broke safety limits in 73.8% of trials
  • Safe Bayesian Optimization achieved only 1.8% unsafe trials
  • Warm-starting proved more effective than advanced acquisition functions

Why I moved my file tools to the browser (and what broke along the way)

Every "convert HEIC to PNG" or "compare two files" site I used had the same quiet problem: my file went to someone's server. For a holiday photo, fine.

  • Author moved file tools to browser to reduce server storage and improve privacy.
  • Encountered issues with image conversion, diffing, and JSON handling in browser processing.

More from Tuesday 24 November →