fix(exec-approvals): allow ~/.openclaw symlink when OPENCLAW_STATE_DIR is set#68417
fix(exec-approvals): allow ~/.openclaw symlink when OPENCLAW_STATE_DIR is set#68417acinader wants to merge 6 commits into
Conversation
Greptile SummaryThis PR fixes a false-positive symlink rejection in Confidence Score: 5/5Safe to merge; one dead-code branch is the only finding. All remaining findings are P2 style issues. The security-sensitive path logic is correct: symlinks are only permitted when OPENCLAW_STATE_DIR is explicitly set and the symlink resolves to exactly that root, and the test suite covers both the allow and reject cases. No files require special attention. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/exec-approvals.ts
Line: 265-268
Comment:
**Dead branch after `realpathSync`**
`fs.realpathSync` resolves all symlinks by definition, so `fs.lstatSync(realDir).isSymbolicLink()` can never return `true`. The `realStat.isSymbolicLink()` guard in the compound condition is unreachable dead code.
```suggestion
const realStat = fs.lstatSync(realDir);
if (!realStat.isDirectory()) {
throw new Error(`Refusing to use unsafe exec approvals directory: ${dir}`);
}
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(exec-approvals): allow ~/.openclaw s..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7ab6fb764
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Closing this as duplicate or superseded after Codex automated review. Close this PR as duplicate/superseded. Current main still has the broader OPENCLAW_STATE_DIR exec-approvals gap, but this branch is no longer the best landing path: #72377 already merged the related symlinked-OPENCLAW_HOME cleanup, and open #62938 is the canonical remaining PR for making exec approvals respect OPENCLAW_STATE_DIR directly. Best possible solution: Close this PR as superseded, keep #62938 as the canonical implementation path for OPENCLAW_STATE_DIR exec-approvals storage, and fold any useful exact What I checked:
So I’m closing this here and keeping the remaining discussion on the canonical linked item. Codex Review notes: model gpt-5.5, reasoning high; reviewed against 7d9dc8cf24fc. |
What
Server deployments (e.g. the AWS CloudFormation template) place OpenClaw state at
OPENCLAW_STATE_DIR=/data/openclawand symlink~/.openclaw → /data/openclawfor convenience. The exec approvals path check was tripping on this symlink withRefusing to traverse symlink in exec approvals path, blocking the AI from running anyexeccommands.How
resolveApprovalsPathTrustedRoot(): whenOPENCLAW_STATE_DIRis set, usefs.realpathSync(stateDir)as the trusted root instead of the HOME-relative walkensureDir()to allow a symlinked approvals dir only when it resolves to exactly the configured state root (not any arbitrary directory)OPENCLAW_STATE_DIRshifts the trusted rootTests
Added two new cases to
exec-approvals-store.test.ts:~/.openclawsymlink when it resolves to exactlyOPENCLAW_STATE_DIR~/.openclawsymlink when it resolves to a different directoryNotes
codex review --base origin/main, findings addressedpnpm build && pnpm check && pnpm testpass