Lock down over-broad PostgreSQL role permissions with a security migration

A solo developer had Codex on GPT-6.1 Sol close a staging database role that could edit reward balances, adding a new migration and passing 171 tests, after GPT-6.2 Sol refused the same job twice.

Done withCodexinPostgresql· Nov 22, 2026

What they did

The poster, u/IAMNOTSPAMREDDIT on r/codex, builds a Windows desktop app called SlipUpClipz with OpenAI Codex. In an isolated staging environment they found a PostgreSQL role with more rights than it needed, enough to let someone alter reward balances directly. They asked Codex to tighten the permissions without rewriting the existing migrations, and to prove the fix by running security tests against throwaway local PostgreSQL databases. Nothing was to be deployed to production.

How it went

On GPT-6.2 Sol at medium effort the request was stopped twice by a cybersecurity filter that pointed them to OpenAI's Daybreak access programme, even after they cut the prompt down to plain defensive remediation. Switching to GPT-6.1 Sol at extra high effort with the original prompt worked. The agent found the excess grants, wrote a new versioned migration that blocks direct writes to protected balances, added transaction-scoped authorization permits, and checked that unauthorized operations were now denied. It reported 94 offline reward tests, 21 staging database tests, 13 authorization tests and 43 licensing tests passing, with production untouched.

Worth knowing

Newer models can refuse legitimate defensive security work on your own code. OpenAI support told the poster that false positives happen and suggested narrowing the prompt or applying for Daybreak. Falling back to the previous model version was what got the job done. The test counts are the agent's own report; the poster does not say how they reviewed the migration.

Try it

With Codex· 4 parts to fill in

In [my repo], audit the PostgreSQL roles and grants used by [my app] against [the tables that must be protected]. Find any role that can write to data it should not touch. Fix it with a new versioned migration; do not edit existing migrations. Run every check against disposable local PostgreSQL databases only, never against [staging or production]. Write tests proving that unauthorized writes are now denied and that normal app flows still work. Do not deploy anything. Stop when all tests pass and show me the migration and the test results for review.

Square brackets are the parts to fill in. The prompt is ours; the story is theirs.

Where they said it

Related