fix: reject oversized credential files in remaining readers#109260
Merged
Conversation
Contributor
Author
|
Pre-merge proof for head
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
force-pushed
the
fix/bound-owner-secret-files
branch
from
July 16, 2026 18:25
2e62a1f to
ef00cc1
Compare
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
FsSafeErrordiagnostics naming the path and limit. Vertex parses the bounded ADC payload once and passes it togoogle-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..agents/skills/autoreview/scripts/autoreview --mode uncommitted— clean; no accepted/actionable findings.AI-assisted: yes. Maintainer reviewed the implementation, dependency contracts, tests, and proof.