Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosBuilding AMD Helios: Testing and Validating Rackscale AI Solutions(24.09.2026 um 17:30 Uhr)
Podcasts & Audio Briefings9to5Google: The Googlebook could do something insane.(24.09.2026 um 17:30 Uhr)
YouTube Security VideosBack to School Raspberry Pi Quiz! #bermonths #quiz #raspberrypi(24.09.2026 um 17:24 Uhr)
YouTube Security VideosPC-WELT: Endlich hat die 2. RTX 5090 Sinn - lokale KI auf HMX 6!(24.09.2026 um 17:30 Uhr)
Windows Tipps & SecurityuBlock Origin broke on Edge, so I finally quit the browser(24.09.2026 um 17:24 Uhr)
Windows Tipps & SecurityHMX 6: Wir müssen reden(24.09.2026 um 17:30 Uhr)
Windows Tipps & SecurityWinamp Community Update Project(24.09.2026 um 16:40 Uhr)
YouTube Security VideosBuilding AMD Helios: Testing and Validating Rackscale AI Solutions(24.09.2026 um 17:30 Uhr)
Podcasts & Audio Briefings9to5Google: The Googlebook could do something insane.(24.09.2026 um 17:30 Uhr)
YouTube Security VideosBack to School Raspberry Pi Quiz! #bermonths #quiz #raspberrypi(24.09.2026 um 17:24 Uhr)
YouTube Security VideosPC-WELT: Endlich hat die 2. RTX 5090 Sinn - lokale KI auf HMX 6!(24.09.2026 um 17:30 Uhr)
Windows Tipps & SecurityuBlock Origin broke on Edge, so I finally quit the browser(24.09.2026 um 17:24 Uhr)
Windows Tipps & SecurityHMX 6: Wir müssen reden(24.09.2026 um 17:30 Uhr)
Windows Tipps & SecurityWinamp Community Update Project(24.09.2026 um 16:40 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Multi-tenant PostgreSQL: row-level security vs schema-per-tenant & when to use which

If you're building a multi-tenant SaaS, this is the first real architecture decision that will haunt you if you get it wrong. I've implemented both approaches in production. Here's the honest trade-off. Option A: Shared schema with…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

If you're building a multi-tenant SaaS, this is the first real architecture



decision that will haunt you if you get it wrong.

I've implemented both approaches in production. Here's the honest trade-off.



Option A: Shared schema with row-level security (RLS)



Every tenant's data lives in the same tables. A tenant_id column on every

row. PostgreSQL RLS policies enforce that queries only ever return rows

belonging to the current tenant.




-- Enable RLS on the table
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;

-- Policy: users only see their tenant's rows
CREATE POLICY tenant_isolation ON orders
USING (tenant_id = current_setting('app.current_tenant_id')::uuid);









# Set the tenant context before every query
async def set_tenant(conn, tenant_id: str):
await conn.execute(
"SELECT set_config('app.current_tenant_id', $1, true)",
tenant_id
)






Works well when: You have many small tenants. Hundreds or thousands.

Schema-per-tenant at that scale is unmanageable — migrations alone would take hours.



Breaks when: A noisy tenant runs heavy queries and degrades performance for others. You can't easily move one tenant's data to a separate DB. You need different retention policies per tenant.



Option B: Schema per tenant



Each tenant gets their own PostgreSQL schema — effectively a namespace.

tenant_abc.orders, tenant_xyz.orders. Same tables, different schema.




-- Create schema for a new tenant
CREATE SCHEMA tenant_abc;

-- Set search path at connection time
SET search_path TO tenant_abc, public;









# Alembic migration across all tenant schemas
from alembic import command
from alembic.config import Config

def migrate_all_tenants(tenant_schemas: list[str]):
for schema in tenant_schemas:
alembic_cfg = Config("alembic.ini")
alembic_cfg.set_main_option("sqlalchemy.url", db_url)
alembic_cfg.set_section_option("alembic", "version_table_schema", schema)
command.upgrade(alembic_cfg, "head")






Works well when: You have fewer, larger tenants. Enterprise customers

who need data isolation guarantees, custom retention, or the ability to

export their entire dataset cleanly.

Breaks when: You have 500+ tenants. Running migrations across 500

schemas sequentially is slow. Connection pool overhead grows.



What I actually use

For most SaaS products at early stage: start with RLS. It's simpler to

operate, migrations are trivial, and you can always move to schema-per-tenant

for specific large customers later by routing them to a dedicated schema

or even a dedicated database.

The hybrid approach — RLS for SMB tenants, dedicated schema for enterprise —

is what I've settled on. Your connection string is the router.




def get_db_url(tenant: Tenant) -> str:
if tenant.tier == "enterprise":
return tenant.dedicated_db_url
return f"{shared_db_url}?options=-csearch_path={tenant.schema}"






One thing nobody tells you: test your RLS policies with a superuser disabled.

PostgreSQL superusers bypass RLS by default. Your staging environment running

as a superuser will never catch a broken policy. Use a restricted role in tests.

SOC Incident Playbook: Remote Code Execution (RCE) Defense
title: Detect Exploitation - Multi-tenant PostgreSQL: row-level security vs schema-per-tenant & when to use which
id: 45b33807-0ad7-4d52-beaa-decb770676f5
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-24
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-24"
        description = "YARA Signature for "
    strings:
        $str = "Multi-tenant PostgreSQL: row-l" ascii wide
    condition:
        any of them
}
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Multi-tenant PostgreSQL: row-level secur.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Multi-tenant PostgreSQL: row-level security vs schema-per-tenant & when to use which

Thematisch verwandte Begriffe: Multitenant, PostgreSQL, rowlevel, security · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-79764 | Termix is a web-based server management platform with SSH terminal, tunn…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel TTP ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...
↗ Original-Quelle