8000 Harden pgr SQL guard: remove or flag-gate the legacy service-role fallback · Issue #5 · simon-inkie/inkie-pg-read · GitHub
[go: up one dir, main page]

Skip to content

Harden pgr SQL guard: remove or flag-gate the legacy service-role fallback #5

Open

Description

@simon-inkie

Original Linear description

Context

Surfaced by the reviewer-a open-source security review of ~/git-repos/inkie-pgr (2026-07-09). Full doc: ~/inkie-io/dev-notes/2026-07-09-pgr-opensource-security-review.md.

Finding

The README claims the pgr SQL guard is "bypass-proof". That is empirically false. Verified by running the guard:

  • Write-CTEs pass: WITH t AS (INSERT ... RETURNING ...) SELECT ...
  • SELECT ... INTO newtable passes.

Both statements write. They only actually mutate data when pgr runs under the legacy service-role fallback connection. Under the intended inkie_readonly_agent role (BYPASSRLS, REVOKE on auth/storage, SELECT allowlist, bounded statement_timeout) these writes are rejected by the role's own privileges, so today this is defence-in-depth, not a live hole. The readonly role is the true security boundary.

Scope

  1. Remove the legacy service-role fallback entirely, or flag-gate it off by default (opt-in env only, loud warning when active), so the write-CTE / SELECT-INTO path can never mutate data in normal operation.
  2. Soften the README: drop the absolute "bypass-proof" claim, document that the inkie_readonly_agent role is the real boundary and the string-level SQL guard is a secondary filter, not a guarantee.
  3. Optional hardening: tighten the guard to reject data-modifying CTEs and INTO targets at the string level too, so guard and role agree.

Not in scope

No open-sourcing work here. This is the standalone hardening item; the open-source publish prep (squashed repo, LICENCE, README) is tracked separately.

Acceptance

  • Service-role fallback removed or off-by-default with an explicit opt-in.
  • Write-CTE and SELECT-INTO cannot mutate under the default pgr invocation.
  • README no longer claims bypass-proof; documents the role as the boundary.

Origin

Migrated from Linear: INK-649. The original wording is retained except the disclosed privacy and rendering edits below.

Current scope and qualifications

The description above is the full original Linear account. Its historical verification and provider claims have not been independently revalidated by this transfer.
Current Linear state is Backlog. The historical report is retained; this transfer does not independently establish completion against the current public baseline.

Publication transfers the task; it does not authorise live recovery, deployment, spending or configuration changes.

Transfer edits

  • Historical fleet identities are aliased; code identifiers and permitted source paths remain references.
  • Additional transfer edits: replace local prepublication-process boilerplate with bounded qualification.

Activity

  1. added
    bug
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0