BXUP Track progress & test yourself — free
Database & ERP · Playbook · Core · ~4 min read
DATABASE & ERP · PLAYBOOK · CORE

Accelerate Access Reviews and Privilege Audits

Quarterly access reviews die of tedium: hundreds of grants, nested roles, and a spreadsheet nobody finishes reading. This playbook dumps the real grant state, has AI cluster it into effective-permission narratives with anomalies flagged — orphaned users, PUBLIC grants, role loops — and keeps every revocation verified by a human before it runs.

Tier: Core · Workflow area: Security & Compliance · ~35 minutes

The failure mode of access reviews is not missing tooling — every engine can dump its grants. It is that raw grant dumps are unreadable at scale, so reviews get rubber-stamped. AI fixes the readability problem: it turns a thousand grant rows into per-principal narratives ("this role can effectively write to billing via this chain") and a ranked anomaly list. What it must never do is execute the cleanup. Every flagged item gets human verification against the raw dump, and every revocation goes through change control with an owner sign-off — because AI-flagged is a hypothesis, and revoking a grant an integration secretly depends on is a self-inflicted outage.

When to use

  • Scheduled compliance reviewsSOC 2, ISO 27001, RBI/DPDP-driven quarterly access certification, where the deliverable is a reviewed list with decisions.
  • Post-departure and post-project cleanupcontractors gone, projects ended, service accounts of unknown parentage accumulating.
  • Before a security assessmentfinding your own PUBLIC grants and superuser sprawl before an external assessor bills you for finding them.

When NOT to use

  • As an auto-remediation pipelineAI output driving REVOKE statements unreviewed is how you learn which forgotten service account ran payroll.
  • On live-fire incident responsesuspected active compromise is IR-process territory with forensics discipline, not a tidy-up review.
  • When the dump itself cannot leave the boundarygrant metadata reveals your application architecture and names real principals. If policy bars external processing, run a tenant-approved model or an on-prem one.

The recipe

  1. Dump the complete, real grant state — metadata, not memory.

    -- PostgreSQL: role attributes and memberships
    SELECT r.rolname, r.rolsuper, r.rolcreaterole, r.rolcanlogin,
           r.rolvaliduntil,
           ARRAY(SELECT b.rolname FROM pg_auth_members m
                 JOIN pg_roles b ON m.roleid = b.oid
                 WHERE m.member = r.oid) AS member_of
    FROM pg_roles r ORDER BY r.rolname;
    
    -- Object grants
    SELECT grantee, table_schema, table_name, privilege_type
    FROM information_schema.table_privileges
    WHERE grantee NOT IN ('postgres')
    ORDER BY grantee, table_schema, table_name;
    
    -- Default privileges (the ones reviews always miss)
    SELECT * FROM pg_default_acl;
    

    Add the last-login evidence you have (log analysis, pg_stat_activity history from monitoring) — dormancy is the strongest single review signal.

  2. Ask for narratives and anomalies, with claims tied to rows.

    Below: role list with memberships, object grants, default ACLs and
    last-seen data for PostgreSQL 16. Produce:
    
    1. EFFECTIVE-PERMISSION NARRATIVES — for each login-capable role:
       what it can effectively read and write, resolving role chains,
       as 2-3 plain sentences. Note which access comes via inheritance
       and name the chain.
    2. ANOMALY LIST, ranked by risk, checking at least: superuser or
       CREATEROLE beyond the break-glass set; grants to PUBLIC; login
       roles unseen >90 days; role-membership loops or chains >3 deep;
       write grants on financial-looking schemas to non-service roles;
       service accounts with password expiry unset; default ACLs that
       auto-grant future tables.
    3. QUESTIONS — access patterns you cannot classify from the data.
    
    For every anomaly, cite the exact rows (role + grant) it derives
    from. Do not propose REVOKE statements yet.
    
    [paste dumps]
    
  3. Verify every anomaly against the raw dump — the model misreads chains. Nested role resolution is precisely where LLMs slip. For each flagged item, confirm from the dump rows, and for membership chains re-derive one by hand:

    -- Does reporting_ro really reach billing writes? Check the chain:
    WITH RECURSIVE chain AS (
      SELECT oid, rolname FROM pg_roles WHERE rolname = 'reporting_ro'
      UNION ALL
      SELECT r.oid, r.rolname FROM pg_auth_members m
      JOIN pg_roles r ON r.oid = m.roleid
      JOIN chain c ON c.oid = m.member
    ) SELECT * FROM chain;
    

    Mark each anomaly confirmed / false positive / needs owner input. Expect false positives; their presence is the review working, not failing.

  4. Route confirmed items to owners with a decision deadline. For each confirmed anomaly, the data owner (not the DBA) rules: keep with justification, or revoke. AI drafts the owner-facing summaries well — one paragraph per item in business language: "The intern_2023 account can modify vendor bank details via the ap_admin chain and has not logged in for 214 days. Keep or revoke by Aug 20." Unanswered by deadline defaults to revoke-after-monitoring (step 5), which is what makes the review finish.

  5. Revoke in two stages: observe, then execute. For each approved revocation, first watch for usage, then act through change control:

    -- Stage 1: alert-on-use for the doomed grant (log-based watch), or
    -- for login roles: NOLOGIN as the reversible first step
    ALTER ROLE intern_2023 NOLOGIN;
    
    -- Stage 2 (after 2 quiet weeks), the actual revocation
    REVOKE ap_admin FROM intern_2023;
    DROP ROLE intern_2023;  -- only after ownership reassignment checks
    

    NOLOGIN first is the discipline that converts "we think it's unused" into "it was disabled for two weeks and nothing broke" — an evidence-grade claim, and instantly reversible.

  6. File the review pack. The artifact auditors accept: the dated raw dumps, the anomaly list with per-item verdicts and verifier initials, owner decisions with timestamps, and the executed change tickets. AI drafts the cover narrative; the evidence underneath is all queries and sign-offs.

Make it yours

  • SQL Serverdump sys.server_principals, sys.database_principals, sys.database_permissions and role memberships; add checks for db_owner sprawl, orphaned users (sp_change_users_login @Action='Report' era leftovers) and GUEST access; DENY semantics deserve explicit narrative treatment since they invert the usual resolution.
  • OracleDBA_ROLE_PRIVS, DBA_SYS_PRIVS, DBA_TAB_PRIVS plus profile checks; the anomaly list gains ANY-privilege grants (SELECT ANY TABLE) and default-password accounts from DBA_USERS_WITH_DEFPWD.
  • Cloud IAM layersRDS/Cloud SQL adds the provider IAM plane on top of engine grants; run the same narrative pass over both dumps together, because the interesting anomalies live in the seams ("no engine superuser, but IAM lets them restore snapshots to a new instance").

Quality check

  • The dump is complete: default ACLs, system schemas, expiry settings includedreviews that only read table_privileges miss where standing access actually hides.
  • Every AI anomaly was re-verified against raw rowsat least chains re-derived with the recursive query; a review that trusts the model's chain resolution inherits its mistakes with a signature on top.
  • Data owners made the keep/revoke callsthe DBA verifies mechanics; the owner owns the decision. A review where the DBA decided everything will not survive an auditor's "who approved this access?"
  • Revocations went observe-first through change controlNOLOGIN/alert-on-use stage, then revoke, each with a ticket. No REVOKE ran the day it was flagged.
  • False positives are recorded, not deletedthey calibrate the next review's prompt and prove the human pass was real.
Warning

A grant dump is a map of your attack surface with real usernames on it — the exact document an attacker wants. Handle review packs at your highest data classification, strip principal names before any external-model processing where policy requires, and never leave dumps in chat histories or ticket attachments with broad read access.

Key Takeaway:

AI turns the unreadable grant dump into narratives and a ranked worklist — that is the acceleration. The review itself stays human: verify each flag against raw rows, put decisions on data owners, and disable-before-revoke so every cleanup claim rests on two quiet weeks of evidence.

This is the free reading view. Open BXUP to track your progress, run the hands-on labs, and prove it with original, exam-pattern assessments.
© Anvi Innovate · BXUP — Be Exponentially Upskilled · BXUP is an independent learning platform, not affiliated with or endorsed by AWS, Microsoft, Google, NVIDIA, IBM, Salesforce, Databricks, Oracle or Anthropic. All trademarks belong to their respective owners. · bxup.in