Harden config backup restore permissions#77488
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. Source inspection on current main shows both suspicious-read backup restore paths copy Real behavior proof Next step before merge Security Review detailsBest possible solution: Land the narrow chmod hardening after maintainer review, corrected closing metadata, after-fix real behavior proof, and current CI/changed-gate validation. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection on current main shows both suspicious-read backup restore paths copy Is this the best way to solve the issue? Yes. Best-effort chmod immediately after successful restore copies is the narrowest maintainable fix and matches existing config write and last-known-good recovery hardening patterns. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a3870686947b. |
bba849a to
400b330
Compare
Adds the user-facing Unreleased Fixes entry for the suspicious-read backup restore chmod hardening shipped in this PR.
400b330 to
39b977f
Compare
* Harden config backup restore permissions * docs(changelog): credit config restore mode hardening Adds the user-facing Unreleased Fixes entry for the suspicious-read backup restore chmod hardening shipped in this PR.
* Harden config backup restore permissions * docs(changelog): credit config restore mode hardening Adds the user-facing Unreleased Fixes entry for the suspicious-read backup restore chmod hardening shipped in this PR.
* Harden config backup restore permissions * docs(changelog): credit config restore mode hardening Adds the user-facing Unreleased Fixes entry for the suspicious-read backup restore chmod hardening shipped in this PR.
* Harden config backup restore permissions * docs(changelog): credit config restore mode hardening Adds the user-facing Unreleased Fixes entry for the suspicious-read backup restore chmod hardening shipped in this PR.
Harden config backup restore permissions
Summary
openclaw.jsonwithout forcing the final file mode back to owner-only permissions.openclaw.jsoncan contain live tokens and API keys, so preserving a world-readable destination mode could expose credentials to other local users or processes.chmod(..., 0o600)calls after backup restore copies, plus regression tests for insecure destination modes.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
.bakwithcopyFile/copyFileSyncbut did not normalize the destination mode afterward, so an existing broad destination mode could remain in place.Regression Test Plan (if applicable)
src/config/io.observe-recovery.test.ts0644config leaveopenclaw.jsonat0600.User-visible / Behavior Changes
Restored
openclaw.jsonfiles are best-effort hardened to owner-only permissions after suspicious-read backup recovery.Diagram (if applicable)
N/A
Security Impact (required)
Yes/No) NoYes/No) YesYes/No) NoYes/No) NoYes/No) YesYes, explain risk + mitigation: The change narrows local filesystem exposure for credential-bearing config restores by forcing owner-only permissions after recovery copy operations. The chmod is best-effort to avoid making restore unavailable on filesystems that cannot apply POSIX modes.Repro + Verification
Environment
Steps
0644.0600.Expected
openclaw.jsonowner-readable/writable only.Actual
pnpm exec vitest run --config test/vitest/vitest.runtime-config.config.ts src/config/io.observe-recovery.test.tspassed with 18 tests.Evidence
Targeted test output:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations