Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungYour agent picks one of two options. Can you test that choice?(23.09.2026 um 01:10 Uhr)
Sichere ProgrammierungWe audited 110 AI usage tools. Here is where the numbers go wrong.(23.09.2026 um 01:12 Uhr)
Sichere ProgrammierungWhy Does Your AI Coding Agent Start Forgetting What It Was Doing?(23.09.2026 um 01:19 Uhr)
Sichere ProgrammierungYour agent picks one of two options. Can you test that choice?(23.09.2026 um 01:10 Uhr)
Sichere ProgrammierungWe audited 110 AI usage tools. Here is where the numbers go wrong.(23.09.2026 um 01:12 Uhr)
Sichere ProgrammierungWhy Does Your AI Coding Agent Start Forgetting What It Was Doing?(23.09.2026 um 01:19 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

How to Create a Read-Only User in PostgreSQL (With Access to Statistics)

🇪🇸 Lee también este post en español 📝 Test Report: Read-Only User Access in PostgreSQL 📋 Test Context A user with read-only permissions was created for the test PostgreSQL database. The goal was: Allow the user to q…

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

🇪🇸 Lee también este post en español






📝 Test Report: Read-Only User Access in PostgreSQL






📋 Test Context



A user with read-only permissions was created for the test PostgreSQL database. The goal was:




  1. Allow the user to query all tables (except sensitive ones).

  2. Prevent administrative privileges.

  3. Allow monitoring of active processes (like MySQL’s SHOW PROCESSLIST).



The test user was: test_ro_user.









⚙️ User Creation and Permission Statements






-- Create the read-only user with explicit restrictions
CREATE USER test_ro_user
LOGIN
PASSWORD 'LecTur@_2025!'
NOSUPERUSER
NOCREATEDB
NOCREATEROLE
NOINHERIT;

-- Grant database access
GRANT CONNECT ON DATABASE test TO test_ro_user;

-- Grant usage of the public schema
GRANT USAGE ON SCHEMA public TO test_ro_user;

-- Grant read-only access to all current tables
GRANT SELECT ON ALL TABLES IN SCHEMA public TO test_ro_user;

-- Auto-grant read-only access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT ON TABLES TO test_ro_user;

-- Explicitly revoke access to the "configuracion" table
REVOKE ALL ON TABLE public.configuracion FROM test_ro_user;

-- Grant full access to system statistics views
GRANT pg_read_all_stats TO test_ro_user;












⚙️ Actions Taken






1. User Creation with Restrictions



The script above was executed.



Result: ✅ Successful




  • The user was created with the intended restrictions.

  • No write access to any table.


  • configuracion table is inaccessible (queries are denied).






2. Querying pg_stat_activity (Process Status)



Queries executed:




SELECT * FROM pg_stat_activity;
SELECT * FROM pg_stat_activity WHERE state != 'idle';






Result: ⚠️ Partially Successful




  • The user could access pg_stat_activity.

  • The query column showed <insufficient privilege> in most rows.






3. Querying Table Usage Statistics



Query executed:




SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables;






Result: ✅ Successful




  • The user obtained usage stats for all accessible tables.

  • The configuracion table was not listed (as expected).






4. Fixing Visibility in pg_stat_activity



Granted role:




GRANT pg_read_all_stats TO test_ro_user;






Result: ✅ Successful




  • The user could fully view the query column in pg_stat_activity.

  • No extra privileges were granted beyond stats visibility.









🟢 Final Status
































Test Result
Read-only user creation ✅ Success
Access to tables (except restricted ones) ✅ Success
Initial visibility in pg_stat_activity
⚠️ Partial
Fix with pg_read_all_stats
✅ Success
Access to table usage stats ✅ Success








📝 Final Recommendations




  • Keep the user without write or admin permissions.

  • Document pg_read_all_stats usage for advanced read-only profiles.

  • Replicate the config for new schemas.

  • Consider audits to monitor what this user sees in processes.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to Create a Read-Only User in PostgreSQL (With Access to Statistics)

Thematisch verwandte Begriffe: Create, ReadOnly, User, PostgreSQL · 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-17636 | IBM Financial Transaction Manager (FTM) for RedHat OpenShift could allow…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
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
🔖 Gespeicherte Artikel
📂 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 ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick