Skip to content

fix(agents): harden auth refresh redaction - #82670

Merged
vincentkoc merged 3 commits into
mainfrom
impact/agents-reliability-slice
May 16, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
impact/agents-reliability-slice

Conversation

@vincentkoc

@vincentkoc vincentkoc commented May 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Close initialized ACP runtimes when a spawn dispatch fails after runtime setup.
  • Add apply-patch coverage for move targets whose parent path is a symlink outside the workspace.
  • Redact OAuth refresh failure messages and surfaced causes against in-memory, attempted bootstrap, reloaded, token-shaped, and non-JSON refresh-failure values.
  • Add a changelog entry for the agent/auth hardening.

Refs #42541, but does not close it. The provider-owned Gemini refresh fix remains owned by #78030.

Related follow-up lanes

Verification

Behavior addressed: failed ACP dispatch cleanup no longer leaves the initialized runtime handle open; OAuth refresh failures no longer surface credential material from current, attempted bootstrap, token-shaped, non-JSON, or reloaded credentials; apply-patch move-target symlink escapes stay rejected.

Real environment tested: local Codex worktree for focused Vitest proof, plus Blacksmith Testbox through Crabbox for pnpm check:changed.

Exact steps or command run after this patch:

node scripts/run-vitest.mjs src/agents/auth-profiles/oauth-manager.test.ts
node scripts/run-vitest.mjs src/agents/apply-patch.test.ts src/agents/apply-patch-paths.test.ts src/agents/acp-spawn.test.ts src/agents/auth-profiles/oauth-manager.test.ts
node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --blacksmith-org openclaw --blacksmith-workflow .github/workflows/ci-check-testbox.yml --blacksmith-job check --blacksmith-ref main --idle-timeout 90m --ttl 240m --timing-json -- CI=1 NODE_OPTIONS=--max-old-space-size=4096 OPENCLAW_TEST_PROJECTS_PARALLEL=6 OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=900000 OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 pnpm check:changed
.agents/skills/codex-review/scripts/codex-review --mode branch
git diff --check origin/main..HEAD

Evidence after fix: final auth-focused Vitest passed 2 files / 34 tests; the touched-surface suite passed 8 files / 214 tests earlier in the same review-fix loop; final Codex review helper reran a targeted set at 6 files / 180 tests and reported codex-review clean: no accepted/actionable findings reported; final Testbox-through-Crabbox passed with provider blacksmith-testbox, id tbx_01krrx5hzp5h6bd3gne14354wj, GitHub Actions run https://github.com/openclaw/openclaw/actions/runs/25968292153, exit 0.

Observed result after fix: cleanup receives the initialized ACP runtime close handle on dispatch failure, OAuth refresh wrapper/cause text redacts all credential variants under test before generic token masking, non-JSON refresh failure values do not replace the refresh error with a TypeError, and the changed gate reports 0 lint errors plus 0 runtime import cycles.

What was not tested: no live Gemini OAuth refresh was run here; #78030 owns that provider behavior and the closing path for #42541.

@vincentkoc vincentkoc self-assigned this May 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels May 16, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review May 16, 2026 17:07
@vincentkoc
vincentkoc requested a review from a team as a code owner May 16, 2026 17:07
@clawsweeper

clawsweeper Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The branch redacts OAuth refresh failure causes, passes initialized ACP runtimes into dispatch-failure cleanup, adds apply-patch symlink move-target coverage, and records a changelog entry.

Reproducibility: yes. by source inspection. Current main can surface raw OAuth refresh cause text and omits the initialized runtime close handle on the ACP dispatch-failure cleanup path; this read-only review did not execute tests.

Real behavior proof
Not applicable: This is a member-authored, maintainer-labeled PR, so the external contributor proof gate does not apply; the PR body still includes focused Vitest and Testbox proof.

Next step before merge
Protected maintainer-labeled PR with no narrow automated repair needed; maintainer review and normal merge gates are the remaining action.

Security
Cleared: The diff is security-positive and does not add dependencies, workflows, permissions, downloads, or new code-execution surfaces.

Review details

Best possible solution:

Keep this scoped hardening PR open for maintainer review and merge gates, while leaving the provider-owned Gemini refresh fix and broader OAuth policy work in their linked lanes.

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

Yes, by source inspection. Current main can surface raw OAuth refresh cause text and omits the initialized runtime close handle on the ACP dispatch-failure cleanup path; this read-only review did not execute tests.

Is this the best way to solve the issue?

Yes. The patch keeps redaction at the OAuth manager error boundary, uses the existing ACP cleanup handle contract, and limits apply-patch work to regression coverage for an existing path-safety guard.

What I checked:

  • Protected PR state: Provided GitHub context shows author association MEMBER and labels agents, maintainer, size: M, and P1, so cleanup closure is not allowed for this PR. (9c9993e9946a)
  • Current main OAuth redaction gap: Current main builds OAuthManagerRefreshError.message from formatErrorMessage(params.cause) and passes the delegated raw cause through, so credential values embedded in a refresh failure cause can still be surfaced before the PR's exact credential redaction. (src/agents/auth-profiles/oauth-manager.ts:83, 4003a955eee3)
  • PR OAuth redaction fix: The PR diff adds attempted credential tracking, exact credential secret collection, redacted refresh error formatting, and a sanitized surfaced cause for OAuth refresh failures. (src/agents/auth-profiles/oauth-manager.ts:69, 9c9993e9946a)
  • Current main ACP cleanup gap: Current main stores initializedRuntime and passes it to cleanup for runtime-initialization failures, but the later dispatch-failure cleanup call omits runtimeCloseHandle. (src/agents/acp-spawn.ts:1438, 4003a955eee3)
  • ACP cleanup contract: cleanupFailedAcpSpawn already accepts an optional runtime close handle and closes it with reason spawn-failed, matching the PR's dispatch-failure call-site change. (src/acp/control-plane/spawn.ts:17, 4003a955eee3)
  • Apply-patch coverage context: Current main already validates move targets with assertPatchParentPath; the PR adds focused regression coverage for a move target whose parent path is a symlink outside the workspace. (src/agents/apply-patch.ts:174, 4003a955eee3)

Likely related people:

  • vincentkoc: Blame on current main attributes the OAuth manager and ACP spawn sections under review to Vincent Koc, and related history centralizes OAuth lifecycle management and hardens OAuth bootstrap/error handling. (role: recent auth/agents contributor; confidence: high; commits: fa9a22b96097, 5f2e77a6e1c4, d97d5c04f03b; files: src/agents/auth-profiles/oauth-manager.ts, src/agents/auth-profiles/oauth.ts, src/agents/acp-spawn.ts)
  • steipete: Recent history includes Codex OAuth refresh fallback/read-through work and apply-patch parent path hardening adjacent to this PR's OAuth and symlink coverage. (role: recent adjacent auth and patch-safety contributor; confidence: high; commits: b3d9bef38d5d, e6cd90e3fd9c, 777c539dafc0; files: src/agents/auth-profiles/oauth-manager.ts, src/agents/auth-profiles/oauth.ts, src/agents/apply-patch.ts)
  • shakkernerd: Recent merged work changed provider auth hook lookup context, which is adjacent to the OAuth refresh and provider-owned auth behavior referenced by this PR. (role: adjacent provider-auth contributor; confidence: medium; commits: 854323a12481; files: src/agents/auth-profiles/oauth.ts)

Remaining risk / open question:

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

@clawsweeper clawsweeper Bot added the P1 High-priority user-facing bug, regression, or broken workflow. label May 16, 2026
@vincentkoc
vincentkoc force-pushed the impact/agents-reliability-slice branch from 1d6ce26 to 9c9993e Compare May 16, 2026 17:30
@vincentkoc
vincentkoc merged commit 05123db into main May 16, 2026
119 checks passed
@vincentkoc
vincentkoc deleted the impact/agents-reliability-slice branch May 16, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant