Skip to content

fix: reject oversized credential files in remaining readers#109260

Merged
steipete merged 2 commits into
mainfrom
fix/bound-owner-secret-files
Jul 16, 2026
Merged

fix: reject oversized credential files in remaining readers#109260
steipete merged 2 commits into
mainfrom
fix/bound-owner-secret-files

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators using scripts/gh-read, the Mantis Discord smoke, or file-backed Vertex ADC could trigger unbounded reads when the configured credential file was unexpectedly large.

Why This Change Was Made

Adds owner-specific limits: 64 KiB for GitHub App PEM files, 4 KiB for Mantis Discord tokens, and 1 MiB for Google and Anthropic Vertex ADC JSON. Oversized files now raise typed FsSafeError diagnostics naming the path and limit. Vertex parses the bounded ADC payload once and passes it to google-auth-library, preventing the dependency from reopening the file without a bound.

User Impact

Normal credential files continue to work. Oversized files fail early with an actionable size error instead of being read without a limit. No UI or configuration changes.

Evidence

  • node scripts/run-vitest.mjs test/scripts/gh-read.test.ts extensions/qa-lab/src/mantis/discord-smoke.runtime.test.ts extensions/google/transport-stream.test.ts extensions/google/index.test.ts extensions/anthropic-vertex/region.adc.test.ts extensions/anthropic-vertex/stream-runtime.test.ts — 6 files, 158 tests passed.
  • node scripts/check-changed.mjs -- <10 touched files> — format, SDK baseline, plugin boundaries, four tsgo lanes, extension/scripts lint, store guards, and import-cycle checks passed on Blacksmith Testbox.
  • Blacksmith proof: https://github.com/openclaw/openclaw/actions/runs/29522381974
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted — clean; no accepted/actionable findings.

AI-assisted: yes. Maintainer reviewed the implementation, dependency contracts, tests, and proof.

@steipete

steipete commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Pre-merge proof for head ef00cc19ca6d9e2545e2eef2896d42ffdb9f2aab:

  • Focused Vitest proof passed: 6 files, 158 tests.
  • Boundary regressions cover exact cap and cap + 1 for GitHub App PEM, Mantis Discord token, Google Vertex ADC, and Anthropic Vertex ADC.
  • Hosted changed gate passed: format, SDK baseline, plugin boundaries, four tsgo lanes, extension/scripts lint, database-first guard, runtime-sidecar guard, and import-cycle guard.
  • Blacksmith proof: https://github.com/openclaw/openclaw/actions/runs/29522381974
  • Mandatory autoreview completed clean with no accepted/actionable findings.
  • CI's deadcode lane found one exported internal ADC type; the export was removed. Post-fix Anthropic Vertex tests (33), fresh autoreview, and the full focused suite (158) passed before the exact-head push.
  • Review artifacts validated with recommendation READY FOR /prepare-pr; findings: 0.

Dependency contract checked directly: google-auth-library 10.9.0 streams and buffers file-backed ADC, so the providers pass the already bounded parsed ADC object into GoogleAuth instead of allowing a later unbounded reopen.

@steipete
steipete force-pushed the fix/bound-owner-secret-files branch from 2e62a1f to ef00cc1 Compare July 16, 2026 18:25
@steipete
steipete merged commit 04c31f4 into main Jul 16, 2026
119 checks passed
@steipete
steipete deleted the fix/bound-owner-secret-files branch July 16, 2026 18:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…#109260)

* fix(security): bound remaining credential file reads

* fix(anthropic-vertex): keep ADC helper type private
xydt-juyaohui added a commit to xydt-juyaohui/openclaw that referenced this pull request Jul 17, 2026
createFederatedApp read the certificate path with an unbounded
fs.readFileSync, so a misconfigured or oversized certificate file could
trigger an unbounded read at credential-load time.

Adopt tryReadSecretFileSync (the same helper the credential-reader sweep
in openclaw#109260 applied to anthropic-vertex / google / gh-read / mantis) with a
1 MiB maxBytes bound so oversized certificate files are rejected at the
size check rather than read whole. Missing or empty files surface as the
existing "Failed to read certificate file" error.

Update the sdk tests to mock tryReadSecretFileSync and add a regression
case asserting an oversized file (helper returns undefined) fails the
load with the bound applied.
xydt-juyaohui added a commit to xydt-juyaohui/openclaw that referenced this pull request Jul 17, 2026
createFederatedApp read the certificate path with an unbounded
fs.readFileSync, so a misconfigured or oversized certificate file could
trigger an unbounded read at credential-load time.

Adopt tryReadSecretFileSync (the same helper the credential-reader sweep
in openclaw#109260 applied to anthropic-vertex / google / gh-read / mantis) with a
1 MiB maxBytes bound so oversized certificate files are rejected at the
size check rather than read whole. Missing or empty files surface as the
existing "Failed to read certificate file" error.

Update the sdk tests to mock tryReadSecretFileSync and add a regression
case asserting an oversized file (helper returns undefined) fails the
load with the bound applied.
xydt-juyaohui added a commit to xydt-juyaohui/openclaw that referenced this pull request Jul 19, 2026
canReadAnthropicVertexAdc read the entire GOOGLE_APPLICATION_CREDENTIALS
file via unbounded fs.readFileSync solely to check readability (the
contents are discarded). The provider-local copy of this logic in
extensions/anthropic-vertex/region.ts was already bounded with
tryReadSecretFileSync + a 1 MiB limit in openclaw#109260 ("reject oversized
credential files in remaining readers"); this standalone plugin-sdk
preflight helper is a duplicate that sweep missed.

Mirror the region.ts bound: replace the unbounded readFileSync with
tryReadSecretFileSync(..., { maxBytes: 1 MiB, rejectHardlinks: false }),
wrapped in try/catch (the helper throws FsSafeError on oversize) so an
oversized credential file is rejected instead of slurped into memory.
Presence-check semantics are unchanged for normal-sized files.
xydt-juyaohui added a commit to xydt-juyaohui/openclaw that referenced this pull request Jul 19, 2026
canReadAnthropicVertexAdc read the entire GOOGLE_APPLICATION_CREDENTIALS
file via unbounded fs.readFileSync solely to check readability (the
contents are discarded). The provider-local copy of this logic in
extensions/anthropic-vertex/region.ts was already bounded with
tryReadSecretFileSync + a 1 MiB limit in openclaw#109260 ("reject oversized
credential files in remaining readers"); this standalone plugin-sdk
preflight helper is a duplicate that sweep missed.

Mirror the region.ts bound: replace the unbounded readFileSync with
tryReadSecretFileSync(..., { maxBytes: 1 MiB, rejectHardlinks: false }),
wrapped in try/catch (the helper throws FsSafeError on oversize) so an
oversized credential file is rejected instead of slurped into memory.
Presence-check semantics are unchanged for normal-sized files.
steipete pushed a commit to xydt-juyaohui/openclaw that referenced this pull request Jul 21, 2026
canReadAnthropicVertexAdc read the entire GOOGLE_APPLICATION_CREDENTIALS
file via unbounded fs.readFileSync solely to check readability (the
contents are discarded). The provider-local copy of this logic in
extensions/anthropic-vertex/region.ts was already bounded with
tryReadSecretFileSync + a 1 MiB limit in openclaw#109260 ("reject oversized
credential files in remaining readers"); this standalone plugin-sdk
preflight helper is a duplicate that sweep missed.

Mirror the region.ts bound: replace the unbounded readFileSync with
tryReadSecretFileSync(..., { maxBytes: 1 MiB, rejectHardlinks: false }),
wrapped in try/catch (the helper throws FsSafeError on oversize) so an
oversized credential file is rejected instead of slurped into memory.
Presence-check semantics are unchanged for normal-sized files.
steipete added a commit that referenced this pull request Jul 21, 2026
* fix(plugin-sdk): bound Anthropic Vertex ADC credential read

canReadAnthropicVertexAdc read the entire GOOGLE_APPLICATION_CREDENTIALS
file via unbounded fs.readFileSync solely to check readability (the
contents are discarded). The provider-local copy of this logic in
extensions/anthropic-vertex/region.ts was already bounded with
tryReadSecretFileSync + a 1 MiB limit in #109260 ("reject oversized
credential files in remaining readers"); this standalone plugin-sdk
preflight helper is a duplicate that sweep missed.

Mirror the region.ts bound: replace the unbounded readFileSync with
tryReadSecretFileSync(..., { maxBytes: 1 MiB, rejectHardlinks: false }),
wrapped in try/catch (the helper throws FsSafeError on oversize) so an
oversized credential file is rejected instead of slurped into memory.
Presence-check semantics are unchanged for normal-sized files.

* refactor(plugin-sdk): remove orphaned vertex auth helper

---------

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 21, 2026
…#111120)

* fix(plugin-sdk): bound Anthropic Vertex ADC credential read

canReadAnthropicVertexAdc read the entire GOOGLE_APPLICATION_CREDENTIALS
file via unbounded fs.readFileSync solely to check readability (the
contents are discarded). The provider-local copy of this logic in
extensions/anthropic-vertex/region.ts was already bounded with
tryReadSecretFileSync + a 1 MiB limit in openclaw#109260 ("reject oversized
credential files in remaining readers"); this standalone plugin-sdk
preflight helper is a duplicate that sweep missed.

Mirror the region.ts bound: replace the unbounded readFileSync with
tryReadSecretFileSync(..., { maxBytes: 1 MiB, rejectHardlinks: false }),
wrapped in try/catch (the helper throws FsSafeError on oversize) so an
oversized credential file is rejected instead of slurped into memory.
Presence-check semantics are unchanged for normal-sized files.

* refactor(plugin-sdk): remove orphaned vertex auth helper

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant