Skip to content

Recheck Preset DELETE authority after concurrent revocation - #7360

Draft
freeqaz-openai wants to merge 1 commit into
mainfrom
fix/preset-delete-current-authority-20261125
Draft

freeqaz-openai wants to merge 1 commit into
mainfrom
fix/preset-delete-current-authority-20261125

Conversation

@freeqaz-openai

Copy link
Copy Markdown
Collaborator

Preset DELETE could wait for a Namespace lock after its initial permission check and miss a concurrent withdrawal of the caller's AccessBinding. It also did not acquire the request's existing session and IAM authority hold.

Use Read Committed for the DELETE transaction, acquire the authority hold before checking permission and locking the Namespace, and recheck preset:delete on the exact target after the lock. With Native IAM on PostgreSQL, a binding withdrawal that commits first causes 403 without deleting the Preset or its remaining bindings. Successful deletion still returns 204 and commits the mutation audit with the deletion. Namespace deletion keeps its existing cascade path.

This change addresses direct Preset DELETE ordering through the existing session and Native IAM mechanisms. It does not establish exact API-key currentness, cover every session invalidation path or grant expiry, serialize external IAM changes, or change Preset POST.

Verification: independent source review, exact patch and byte checks, and the repository-managed formatting check passed. The repository's Markdown counter passed across 714 files. Full workspace/typecheck checks and the real PostgreSQL baseline and candidate runs remain pending; this is a draft for ordinary CI qualification.

@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@freeqaz-openai freeqaz-openai added the agent-created PR opened by an AI agent; does not identify the reviewer or approver. label Nov 25, 2026 — with ChatGPT Codex Connector
@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. impact:security This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preset DELETE explicitly uses Read Committed and acquires the existing session and IAM authority hold before authorization.

Example: A member deletes “Target Preset” while its delete grant is withdrawn during a Namespace lock wait, using a connection that defaults to Repeatable Read.

  • Before: The existing permission recheck can reuse a snapshot containing the withdrawn grant.
  • After: The recheck sees the committed withdrawal and returns 403 while preserving the Preset and remaining bindings.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source review found no defect, but the required runtime proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A Preset deletion can proceed using a withdrawn grant when its transaction retains an older policy snapshot.
Reason: The maintainer-authored direction repairs a concrete authorization-ordering gap without introducing configuration, Driver contracts, or another implementation path.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open for triage; the focused authority repair has no concrete introduced defect identified.

Reviewed head: 146c32a4a638428466d73767b6e36640a9b4e15a

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted baseline and candidate observations through the running HTTP server showing revocation-first DELETE returning 403 with preserved state and successful DELETE returning 204 with its audit; the new regression's baseline failure has not been demonstrated.
Agent review details

How this fits together

The HTTP handler delegates authenticated Preset deletion to OCC, which authorizes the exact resource and commits Preset removal, binding cleanup, and mutation audit through PostgreSQL.

flowchart TB
  A[Authenticated DELETE] --> B[Read Committed transaction]
  B --> C[Session and IAM hold]
  C --> D[Exact permission check]
  D --> E[Namespace lock and recheck]
  E -->|Allowed| F[Delete Preset and bindings]
  F --> G[Commit mutation audit]
  E -->|Denied| H[403 and denial audit]
Loading

Technical review

Best possible solution:

Retain the narrow repair through the existing transaction, authority, and Preset owners.

Do we have a high-confidence way to reproduce the issue?

Source establishes the stale-snapshot path with Native IAM and a Repeatable Read connection default; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The implementation addresses transaction isolation at both enclosing and nested owners, reuses the existing authority hold, and preserves Namespace cascade deletion.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2f586673a76d.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned production change: The introduced diff adds holdAuthority and explicit Read Committed to direct deletion, including its enclosing HTTP transaction; the existing exact-resource recheck remains in deletePresetInState. (packages/occ/src/preset-operations.ts:492, 146c32a4a638)
  • Current main retains the isolation gap: Main already checks delete permission before and after the Namespace lock, but direct deletion inherits transaction isolation and does not call holdAuthority. (packages/occ/src/preset-operations.ts:484, 2f586673a76d)
  • Native authorization observes the mutation transaction: Native IAM loads policy through the active PostgreSQL transaction; explicit Read Committed permits a later authorization statement to observe a revocation committed during the lock wait. (packages/occ/src/state/postgres-state.ts:1593, 146c32a4a638)
  • Meaningful integration coverage: The extended registered PostgreSQL suite uses production composition, real Native IAM, and a Repeatable Read connection default to cover revocation first, deletion first, unrelated revocation, session sign-out ordering, persisted state, and attributable audits. (tests/integration/postgres-preset-update-authority.test.ts:224, 146c32a4a638)
  • Exact-head CI: The PostgreSQL Platform check passed for the reviewed head in https://github.com/openclaw/openclaw-enterprise/actions/runs/45568787953/job/139050163661; case-level log inspection was blocked when GitHub redirected to a non-allowlisted storage host. (146c32a4a638)
  • Complete discussion and proof assessment: The full REST body matches captured sourceRevision 77f71e304600b78c35f239804b68b5e6e69fc48c7934c06e7437aee8e2f70d58 and records PostgreSQL baseline/candidate verification as pending; both comments contain review status rather than runtime evidence. (146c32a4a638)

Likely related people:

  • Free Wortley: Raw commit 890c90a adds packages/occ/src/preset-operations.ts:517 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 890c90afd2db; files: packages/occ/src/preset-operations.ts)
  • stevenlee-oai: Raw commit 81e8390 adds apps/controller/src/http/presets.ts:51 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 81e8390cf3ec; files: apps/controller/src/http/presets.ts)
  • kevinlin-openai: Raw commit f997fca adds docs/reference/presets.md:108 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f997fca7e7f7; files: docs/reference/presets.md)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 25, 2026, 2:44 AM ET / 07:44 UTC.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-created PR opened by an AI agent; does not identify the reviewer or approver. impact:security This issue is about security boundaries, credentials, authz, sandboxing, or sensitive data. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant