DBOps Observer
← All labs

PostgreSQL permissions / Intermediate / 20–30 min

The PostgreSQL reader without table access

A database reader connects successfully but receives permission denied for its required table. Restore the least privilege needed.

LAB IDdbops-04-read-permissionTRACK / dbops.observer
Engineer inspecting storage servers and hard drives

The scenario

A reporting role can connect to PostgreSQL and use the schema, but cannot read the synthetic report table. Restore read access without changing the data, ownership or write privileges.

Mission objectives

  • Reproduce the permission error as the reporting role.
  • Inspect table and role privileges and identify the missing permission.
  • Restore read-only access and verify that write privileges remain absent.

Lab README

The PostgreSQL reader without table access

A reporting role connects to the database but cannot read its required table. Find the missing privilege and restore read access without changing the data, table ownership, role membership or write privileges.

Before you begin

Use a disposable machine with Bash, Python 3, Docker and Docker Compose. The lab creates breakfix-dbops-04, an internal Docker network and a named database volume. It publishes no host ports and creates no cloud resources. Docker may download PostgreSQL 17. Authentication is intentionally insecure; never use these settings or this project name for real workloads. Other users with Docker access can reach the lab database.

Setup refuses existing project resources. Teardown checks container ownership before deleting the lab containers, network and synthetic database volume.

Investigate

./setup.sh
docker compose -p breakfix-dbops-04 exec db psql -X -U lab_reader -d lab -c 'SELECT * FROM public.report ORDER BY id'
docker compose -p breakfix-dbops-04 exec db psql -X -U lab_admin -d lab

Inspect the lab_reader role and public.report privileges. Preserve the reader's existing database and schema access and use the least privilege needed for the report. Do not grant access to PUBLIC or change the data. Run ./verify.sh after repair and ./teardown.sh when finished. Verification reads the data as the reader and checks that write, ownership, role and broader administrative privileges remain absent.

View Markdown source ↗

Get the lab

Download and inspect the installer before running it. It checks the archive's SHA-256 digest and refuses to overwrite an existing lab directory.

curl -fsSLO https://devops.download/labs/dbops-04-read-permission.sh
less dbops-04-read-permission.sh
bash dbops-04-read-permission.sh
cd labs/dbops-04-read-permission
./setup.sh

When you've made your changes, run ./verify.sh. Remove lab resources with ./teardown.sh.

Download the archive instead ↗

Need a nudge?

Hint #1

Connecting to a database and using a schema do not automatically grant access to its tables.

Hint #2

Compare the report table's owner and privileges with the capabilities required by the reader; avoid broad role membership or write grants.

Hint #3 · Learning paths on opsbreakfix.com

Explore learning paths ↗

Solved it?

Continue learning with the paths on opsbreakfix.com.

Continue to opsbreakfix.com ↗

One ecosystem.
Many perspectives.

Follow the connection from a hands-on lab to the knowledge and tools behind it.