In most databases, the roles and permissions were set up long ago, under deadline, by someone who may no longer work there.
That’s not a criticism. It’s what happens when teams are busy. A new developer needs access today, so they get the same role as whoever sits next to them. A reporting tool needs to connect, so it gets an account that “just works.” A contractor gets elevated privileges for a migration, and nobody remembers to take them away afterward.
Each decision makes sense in the moment. Over time, though, they add up to a system where nobody can say for sure who can do what.
Meet Bob
Bob is a good engineer. One afternoon he’s cleaning up what he thinks is a test environment and drops a table. It turns out to be production. The table is gone, the application is throwing errors, and Bob is baffled. He didn’t hack anything. He didn’t bypass any controls. The database let him do it.
And that’s the real problem. Bob’s mistake was ordinary. The fact that his role allowed it was the failure.
In PostgreSQL, dropping a table requires owning it or having superuser rights. If Bob could do it, Bob’s role was set up with far more power than his daily work needed. Nobody decided he should be able to drop production tables. It just happened, one convenient grant at a time.
Start with visibility
You can’t secure what you can’t see. A role review begins with a few basic questions:
- What roles exist? Look for accounts tied to former employees, retired applications, and one-time projects.
- What can each role actually do? Check which roles are superusers, which own objects, and which can create, modify, or delete data.
- Who belongs to what? Role membership and inheritance can quietly grant privileges that aren’t obvious from a single account.
- Does the access match the job? A reporting tool needs to read. It rarely needs to write, and it never needs to drop.
Build roles on purpose
Clearly defined roles make a database easier to manage and harder to break. A few habits go a long way:
- Grant to group roles, not individuals. Define roles like read-only, application, and administrator, then add people to the right group. Permissions become consistent and easy to audit.
- Follow least privilege. Give each role what it needs for its work and nothing more. Expand access deliberately when there’s a real reason.
- Separate ownership from daily use. Applications and people shouldn’t connect as the role that owns the schema. That one change prevents a whole category of accidents.
- Review on a schedule. Roles drift. A quarterly review catches access that has outlived its purpose.
Clean at the most basic level
Role management isn’t glamorous, and it rarely makes the security conference agenda. But it’s the foundation everything else sits on. When roles are clear and permissions are intentional, mistakes stay small, audits stay simple, and Bob gets to keep having good afternoons.