Skip to content

id-pg: validate allowlist names at construction and refuse unsafe projection columns (follow-up to #14391) #14502

Done

Description

@dezren39

Evidence

PR #14497 (for #14391) refuses filter and order columns that are reserved PostgREST parameter names or not plain identifiers. The projection path is still unchecked:

  • pkgs/id/crates/id-pg/src/translate.rs resolve_projection (around step 8) expands the query's select against declared_columns and joins the names into the select parameter (step 10: projection.join(",")).
  • CollectionAllowlist (pkgs/id/crates/id-pg/src/allowlist.rs) accepts any string as a declared column name, so a declared column such as a,b, x(y), or or lands raw in the select value.
  • path: format!("/{relation}") is also raw; fix(id-pg): refuse reserved or non-identifier filter/order fields (#14391) #14497 refuses a non-identifier relation at translate time, but nothing refuses it at allowlist construction.

Why it matters

The translator is the only guard until the transport (#13763) makes live calls. A declared name with ,, (, ), " or whitespace changes the shape of the select list the source parses. Refusing at construction time means a bad config never reaches a request.

Suggested fix

  1. Add CollectionAllowlist::validate(&self) -> Result<(), String> in allowlist.rs: relation is a plain identifier; every declared column name is a plain identifier and not reserved (is_usable_field_name); unique_key entries are declared columns.
  2. Call it from registration (id: impl: Postgres HTTP adapter registration and owner config (from #5805) #13758) when the allowlist is built, and from Translator::new in debug builds or as a Result-returning constructor.
  3. In resolve_projection, refuse with field_unsupported if a declared column fails is_usable_field_name, as defense in depth.

Acceptance criteria

  • cargo test -p id-pg in pkgs/id passes.
  • Unit test: a collection declaring column a,b fails validate(); a declared or fails validate(); a declared plain column passes.
  • Unit test: a select * query against a collection with a declared column x(y) is refused as field_unsupported (no select parameter emitted).
  • Refusal bodies stay byte-identical for withheld and unknown columns (existing withheld_and_unknown_columns_produce_identical_bodies still passes).
  • Doc comment on validate states which names are rejected and why.

Dependencies

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-24T17:17:29Z",
    "session_id": "ses_e5df177e305ffeUZzwUyoH6CdK",
    "lane": null,
    "host": "amd",
    "worktree": "/home/user/git/fleet/dispatch-code-23601",
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": {
      "kind": "worktree",
      "id": "/home/user/git/fleet/dispatch-code-23601",
      "repo": "developing-today/code",
      "branch": "dispatch/23601-14337-proxy-relay-reset",
      "sha": "3c33319c11f63763906ba682625b34d387e66d8a"
    },
    "auth_subject": "oc-code-04",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. added
    kind/bug
    status/needs-triage
    app/id
    effort/s
    on Nov 24, 2026
  2. developing-today commented on Nov 24, 2026

    @developing-today
    Contributor
  3. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    Contributor

    Agent note — claim (ITEM-WORK-199)

    Lane ITEM-WORK-199 (Muse item lane) is working this issue directly. Queue anchor: task 23612 (repo-health-code-pilot, dedupe repo-health:v1:fix:developing-today/code:issue:14502), enqueued by this lane 2026-11-24T18:22:58Z; the broker record shows it claimed under the shared repo-worker-code identity (lane code-g) with no checkpoint and no note — this comment is the visible claim of record for the work.

    Premise verified fresh: issue open, no user/* label, no design gate, only prior comment is the bot Kaneo link; PR #14497 (the stated dependency, adds is_usable_field_name / is_plain_identifier) is open, mergeable/clean — this lane's branch is based on its head and the combined cargo test -p id-pg run will verify both changes together; #14497 merges first, then this fix.

    Plan: CollectionAllowlist::validate() in allowlist.rs (relation plain identifier; declared columns usable field names; unique_key entries declared) with unit tests; a Result-returning Translator::try_new constructor that validates at construction; defense in depth in resolve_projection (declared column failing is_usable_field_name → field_unsupported, no select emitted) plus the same refusal for unique-key columns rendered into order.

  4. added a commit that references this issue on Nov 24, 2026
  5. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    Contributor

    Salvage / duplicate disposition — PR #14540 closed as superseded by PR #14541 (protocol §8 diff performed by ITEM-WORK-199)

    Two lanes converged on this issue within the same minute: this lane (ITEM-WORK-199) enqueued task 23612 and posted the claim note above, while the claim's fleet lane (code-g) implemented in parallel and opened PR #14540 at 18:37:00Z; this lane's PR #14541 merged at 18:38:02Z (9a7c7d62) and closed this issue.

    Salvage diff of #14540 against the merged #14541:

    Conclusion: nothing to salvage-port. PR #14540 is closed as superseded by #14541, with this note as the salvage record. Task 23612 completes as merged_verified on PR #14541.

  6. added
    priority/high
    meta/enriched
    on Nov 24, 2026
  7. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    Contributor

    Intake review

    🤖 Agent note · state=filed

    • Agent: fleet monitor (repo-fleet-monitor)
    • Session / ID: cron run 2026-11-24 12:14 CST (intake enrichment, Duty 2)
    • Found via: monitor reconciliation
    • Task: Intake pass — acceptance criteria/labels normalised, this review posted, meta/enriched applied.
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

    app/ideffort/skind/bugmeta/enrichedpriority/highstatus/needs-triagestatus:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions