Skip to content

Bind gateway approval access to requester metadata [AI]#81380

Merged
pgondhi987 merged 27 commits into
openclaw:mainfrom
pgondhi987:fix/fix-643
May 14, 2026
Merged

Bind gateway approval access to requester metadata [AI]#81380
pgondhi987 merged 27 commits into
openclaw:mainfrom
pgondhi987:fix/fix-643

Conversation

@pgondhi987

Copy link
Copy Markdown
Contributor

Summary

  • Problem: Gateway approval list and resolve paths did not consistently apply the requester metadata already stored on approval records.
  • Why it matters: Approval records should only be visible and resolvable through the matching requester identity when that identity is available.
  • What changed: Approval ID lookup now accepts a record filter, shared approval resolution checks caller visibility, exec/plugin list handlers filter pending records, and plugin approval requests stamp requester metadata.
  • What did NOT change (scope boundary): No new permissions, transport, config, or network behavior was added.

AI-assisted: Yes.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related: N/A
  • This PR addresses a bug or regression

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Approval list, get, and resolve paths now use requester metadata when deciding whether a caller can see or act on a pending approval.
  • Real environment tested: Not run against a live gateway in this branch preparation.
  • Exact steps or command run after this patch: Lightweight TypeScript transpile parse over the touched source and test files.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output): transpile parse ok
  • Observed result after fix: The edited TypeScript files parsed successfully.
  • What was not tested: Full test suite, package-manager checks, and live gateway behavior.
  • Before evidence (optional but encouraged): N/A

Root Cause (if applicable)

  • Root cause: Approval ID lookup and shared resolution accepted matching IDs without applying stored requester metadata, and plugin approval records were not stamping that metadata.
  • Missing detection / guardrail: Regression coverage did not assert that list and resolve paths ignore records owned by a different caller, including prefix-based ID matches.
  • Contributing context (if known): Exec approval creation already stored requester metadata, but the shared resolver did not consume it.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/gateway/server-methods/server-methods.test.ts, src/gateway/server-methods/plugin-approval.test.ts
  • Scenario the test should lock in: A caller only sees and resolves approvals matching its requester metadata; hidden records are treated as unknown, including full-ID and shared-prefix resolution attempts.
  • Why this is the smallest reliable guardrail: The affected behavior lives in gateway server-method handlers and shared approval resolution helpers, so handler-level tests cover the contract without requiring a full gateway process.
  • Existing test that already covers this (if any): Existing approval list/resolve tests covered successful behavior but not ownership filtering.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

Approval list, get, and resolve calls now hide records bound to another requester identity. Mismatched approval IDs are reported the same way as unknown or expired IDs.

Diagram (if applicable)

Before:
[caller approval request] -> [global pending records] -> [list/resolve by id or prefix]

After:
[caller approval request] -> [pending records + requester metadata] -> [caller-visible lookup] -> [list/resolve or not found]

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): Yes
  • If any Yes, explain risk + mitigation: Approval record visibility and resolution are narrowed to matching requester metadata when present. Legacy unbound records remain accessible to avoid breaking records without metadata, and regression tests cover both exec and plugin approval paths.

Repro + Verification

Environment

  • OS: Not live-tested
  • Runtime/container: Node/TypeScript parse check only
  • Model/provider: N/A
  • Integration/channel (if any): Gateway approval RPC handlers
  • Relevant config (redacted): N/A

Steps

  1. Create pending exec/plugin approval records with different requester metadata.
  2. List approvals as one requester.
  3. Resolve approval IDs and shared prefixes as matching and non-matching requesters.

Expected

  • Matching requester can list and resolve its own approval records.
  • Non-matching requester cannot list or resolve another requester’s records.
  • Prefix lookup only considers visible records.

Actual

  • Regression tests were added for those scenarios.
  • Lightweight TypeScript transpile parse over touched files completed successfully.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Evidence snippet: transpile parse ok

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios: Reviewed the modified approval lookup, list, get, resolve, and plugin request creation paths for requester metadata flow.
  • Edge cases checked: Full-ID mismatch, prefix matching with hidden records, plugin approval metadata stamping, and legacy unbound record fallback.
  • What you did not verify: Full repo test suite, package-manager checks, and live gateway behavior.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: Some workflows with requester metadata but no matching caller identity could stop seeing or resolving those approval records.
    • Mitigation: Matching falls back from device ID to connection ID to client ID, and records without requester metadata remain visible for compatibility.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels May 13, 2026
@clawsweeper

clawsweeper Bot commented May 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR filters exec and plugin approval list/get/wait/resolve and approval event delivery by requester metadata, stamps plugin approval records, and adds an internal approval-runtime token path for gateway approval clients.

Reproducibility: yes. at source level. Current main stamps requester metadata on exec approval records, but the list and shared lookup/resolve paths do not filter those records by caller before exposing or resolving them.

Real behavior proof
Needs real behavior proof before merge: The PR body says no live gateway run was performed and only provides transpile parse ok, so the external PR still needs after-fix real behavior proof with redacted terminal/log output, a recording, or a linked artifact. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
The branch needs contributor/maintainer action for a real code finding plus real gateway proof; the missing proof cannot be supplied by an automated repair lane.

Security
Cleared: No concrete supply-chain or new secret-handling regression was found; the diff narrows approval visibility and adds an in-process token without dependency, workflow, or external download changes.

Review findings

  • [P2] Continue prefix lookup after hidden exact matches — src/gateway/exec-approval-manager.ts:214-217
Review details

Best possible solution:

Fix the filtered prefix lookup edge case, then keep the centralized requester-metadata enforcement behind maintainer/security review and real gateway proof before merge.

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

Yes, at source level. Current main stamps requester metadata on exec approval records, but the list and shared lookup/resolve paths do not filter those records by caller before exposing or resolving them.

Is this the best way to solve the issue?

No, not as currently patched. Centralizing requester visibility in shared approval lookup and delivery helpers is the right direction, but the filtered exact-match branch must not prevent prefix lookup across otherwise visible records.

Full review comments:

  • [P2] Continue prefix lookup after hidden exact matches — src/gateway/exec-approval-manager.ts:214-217
    When the exact ID exists but is filtered out, lookupApprovalId returns none before scanning visible prefix matches. That means a hidden record with ID abc can make a caller's visible abc-... approval unresolvable by prefix, even though the PR's contract is that prefix lookup should consider only visible records.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.86

Acceptance criteria:

  • After the code finding is fixed, run targeted approval tests via node scripts/run-vitest.mjs src/gateway/server-methods/approval-shared.test.ts src/gateway/server-methods/server-methods.test.ts src/gateway/server-methods/plugin-approval.test.ts src/gateway/client.test.ts src/gateway/operator-approvals-client.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts.
  • Provide real gateway proof with two requester identities covering approval list, get, waitDecision, resolve, and event delivery; redact private IPs, endpoints, tokens, phone numbers, and other private details.

What I checked:

Likely related people:

  • joshavant: Local blame attributes the current requester metadata contract, shared approval resolver, and approval list/resolve handler surfaces to the same current-main commit in this checkout. (role: current checkout area contributor; confidence: medium; commits: 6ae9c8beaddb; files: src/gateway/exec-approval-manager.ts, src/gateway/server-methods/approval-shared.ts, src/gateway/server-methods/exec-approval.ts)
  • pgondhi987: The existing PR discussion identifies prior merged browser/device pairing and gateway auth/access-control work by this contributor in the same requester-metadata behavior family, beyond authorship of this PR. (role: feature-history contributor; confidence: medium; commits: af42260440ac, 731af9c96bba, 0e702f106313; files: src/gateway/server-methods/exec-approval.ts, src/gateway/exec-approval-manager.ts, src/gateway/server/ws-connection/message-handler.ts)

Remaining risk / open question:

  • The PR changes approval visibility and resolution for gateway/security-sensitive flows and needs explicit maintainer/security review.
  • The PR body still lacks real gateway proof showing approval list/get/wait/resolve behavior with multiple requester identities.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c9b6b0be0e36.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Reviewed by automation; no code change was required for this comment.

Quoted comment from @clawsweeper:

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Bind gateway approval access to requester metadata [AI] This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@pgondhi987
pgondhi987 requested a review from a team as a code owner May 13, 2026 13:05
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label May 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: whatsapp-web Channel integration: whatsapp-web agents Agent runtime and tooling labels May 14, 2026
@pgondhi987
pgondhi987 merged commit 386d321 into openclaw:main May 14, 2026
3 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: bind approval access to requester metadata

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing claude review

* addressing ci

* fix: complete root-cause handling

* addressing review-skill

* addressing codex review

* addressing ci

* docs: add changelog entry for PR merge
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: bind approval access to requester metadata

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing claude review

* addressing ci

* fix: complete root-cause handling

* addressing review-skill

* addressing codex review

* addressing ci

* docs: add changelog entry for PR merge
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: bind approval access to requester metadata

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing codex review

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing codex review

* addressing codex review

* addressing claude review

* addressing ci

* fix: complete root-cause handling

* addressing review-skill

* addressing codex review

* addressing ci

* docs: add changelog entry for PR merge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant