Skip to content

fix(infra): prevent $-pattern injection in home directory tilde expansion - #122991

Merged
steipete merged 7 commits into
openclaw:mainfrom
miorbnli:fix/home-dir-replace-dollar-injection
Aug 26, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
miorbnli:fix/home-dir-replace-dollar-injection

Conversation

@miorbnli

@miorbnli miorbnli commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

src/infra/home-dir.ts and src/daemon/paths.ts expand leading ~/~//~\ using String.prototype.replace(regex, replacement). When the replacement string (the resolved home directory) contains $&, $1–$9, $`, or $', JavaScript interprets these as special replacement patterns — silently corrupting the path. For example, with HOME=/home/$&user, expanding ~/state yields /home/~user/state instead of /home/$&user/state (the $& becomes the entire match ~).

Same bug class already fixed in packages/terminal-core/src/display-string.ts (#111398). That fix covered the terminal display path but left the core home-dir resolver (resolveRawHomeDir + expandHomePrefix — the two paths every OpenClaw module uses for home-relative config/state/credential paths), the independent daemon state-dir resolver, and the published launcher (openclaw.mjs, the openclaw binary) unguarded.

Why This Change Was Made

String.replace(regex, () => value) treats the return value literally. The fix switches all five call sites (resolveRawHomeDir, expandHomePrefix, daemon resolveGatewayStateDir's tilde branch, launcher resolveLauncherHomeDir's tilde branch, Control UI isLocalAttachmentPreviewAllowed's tilde-source expansion) from the string form to the function form — minimal, established pattern, zero behavioral change for normal (non-$) home paths.

User Impact

When a user's home directory (or OPENCLAW_HOME) contains $ characters — e.g. a CI runner, a test harness, or a username with special characters — OpenClaw silently resolves config, state, and credential paths (and the managed-service daemon's OPENCLAW_STATE_DIR) to the wrong location. This can cause missing config, lost state, or credentials not found, with no error indicating the path was mangled. The launcher variant additionally makes openclaw --help read configuration candidates at the wrong path, so a configured plugin slot is missed and precomputed help is served instead of the runtime entry. The Control UI variant expands ~/... attachment sources against home candidates inferred from localMediaPreviewRoots; a $-containing home corrupts the comparison and the preview is denied with "Outside allowed folders".

Evidence

Reproduction (node 26.5.0; CI Node 24 has identical replace semantics):

// Before (buggy):
"~/state".replace(/^~(?=$|[\\/])/, "/home/$&user") → "/home/~user/state"
// After (fixed):
"~/state".replace(/^~(?=$|[\\/])/, () => "/home/$&user") → "/home/$&user/state"

Owner-boundary regressions (all red-green verified — fail with the old string form, pass with the callback):

  • src/infra/home-dir.test.ts: 2 new cases — $& in HOME for resolveEffectiveHomeDir (OPENCLAW_HOME ~/state path) and $& in home for expandHomePrefix.
  • src/daemon/service-env.test.ts: 1 new case — $& in HOME when expanding ~ in OPENCLAW_STATE_DIR.
  • ui/src/pages/chat/components/chat-message-local-media.test.ts: 1 new case — isLocalAttachmentPreviewAllowed("~/media/report.png", ["/home/us$&r/media"]) must allow the preview (red pre-fix: expected false to be true); a non-matching root still denies.
  • test/openclaw-launcher.e2e.test.ts: 1 new case — spawns the real openclaw.mjs with HOME=<fixture>/home$&d and OPENCLAW_HOME=~/oc; a config with a plugin slot exists at the literal-$ path. Post-fix the launcher defers to the runtime entry (RUNTIME ENTRY); pre-fix it served precomputed help.

Red example (pre-fix run): AssertionError: expected '/home/~user/openclaw-state' to be '/home/$&user/openclaw-state'.
Launcher red example (pre-fix run): AssertionError: expected 'PRECOMPUTED memory help\n' to be 'RUNTIME ENTRY\n' — the $&-corrupted home made the launcher miss the config and serve precomputed help.

Tests (rebased onto latest main incl. the node-host/runtime changes, exact head e29765fd28a):

  • node scripts/run-vitest.mjs src/infra/home-dir.test.ts → 31 passed
  • node scripts/run-vitest.mjs src/daemon/service-env.test.ts → 83 passed
  • node scripts/run-vitest.mjs test/openclaw-launcher.e2e.test.ts → 38 passed | 1 skipped
  • node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-message-local-media.test.ts → 1 passed (red pre-fix)
  • node scripts/run-vitest.mjs ui/src/pages/chat/components/chat-message.test.ts → 185 passed (incl. new literal-$ case; new case also verified failing pre-fix via -t literal)
  • node scripts/run-vitest.mjs packages/memory-host-sdk/src/host/config-utils.test.ts → passed (memory-host owner covered in companion PR fix: prevent $-pattern injection in tilde expansion across extensions #123004)
  • git diff --check → clean

CI attribution (exact head e29765fd28a)

checks-ui-e2e (2/12) failed at session-management.sidebar.e2e.test.ts > expands and manages child sessions inline before opening a child chat -- TimeoutError: locator.click: Timeout 30000ms exceeded. That file is untouched by this diff, the same shard was green on the previous head (9f5e7e67, 259 checks 0 failing), and this head's new chat-flow.local-media-dollar-home.e2e.test.ts passed in its shard (checks-ui-e2e (5/12), pass 1.3s). Runner/flaky-specific; no code change included. openclaw/ci-gate is the aggregate of that shard.

Production LOC: net 0 (5 lines changed in 5 files: home-dir ×2, daemon ×1, launcher ×1, Control UI ×1). Test LOC: +85.

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@miorbnli
miorbnli marked this pull request as ready for review August 13, 2026 04:26
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 13, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 23, 2026, 6:40 PM ET / 22:40 UTC.

ClawSweeper review

What this changes

The PR makes tilde expansion preserve literal dollar sequences in core home resolution, daemon state paths, launcher config lookup, and Control UI local-media preview checks, with regression tests.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 4 items remain

Keep open: current main still uses string replacement values at all four affected owners, while the PR’s callback form correctly preserves literal dollar sequences. The patch has no concrete correctness finding, but this external PR still needs real-behavior proof and a rebase/green exact-head CI refresh before merge.

Priority: P2
Reviewed head: e29765fd28af7a7101da3659d34a3ca6a5b9ac06

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The repair and boundary tests are solid, but missing real behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Focused tests and the mock-Gateway UI E2E are valuable regression evidence, but no after-fix run from a real launcher or built Control UI/Gateway setup is attached; add redacted evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Focused tests and the mock-Gateway UI E2E are valuable regression evidence, but no after-fix run from a real launcher or built Control UI/Gateway setup is attached; add redacted evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Current-main defect: Current main passes resolved home paths as string replacement values, so JavaScript interprets replacement tokens during tilde expansion.
Independent current-main owners: The same string-replacement pattern remains in daemon state resolution, launcher home resolution, and Control UI media-root comparison.
Language-level reproduction: The string replacement produced /home/~user/state, while a callback replacement produced the intended /home/$&user/state.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/openclaw-launcher.e2e.test.ts -t "keeps literal $ patterns"

Result: FAIL (partial) — step 2 expect_output keeps literal $ patterns in HOME when expanding a tilde OPENCLAW_HOME: expected terminal output was not visible within 30 seconds: "keeps literal $ patterns in HOME when expanding a tilde OPENCLAW_HOME"

node scripts/run-vitest.mjs test/openclaw-launcher.e2e.test.ts -t "keeps literal $ patterns"
runner@runnervm76f27:/tmp/clawsweeper-live-proof-122991-HF10OX/target$ node scripts/run-vitest.mjs test/openclaw-launcher.e2e.test.ts -t "keeps literal $ patter
ns"
node scripts/run-vitest.mjs test/openclaw-launcher.e2e.test.ts -t "keeps literal $ patterns"
[test] starting test/vitest/vitest.e2e.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-122991-HF10OX/target

[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
  - tsdown:deps (44%)
  - rolldown-plugin-dts:fake-js (23%)
  - rolldown-plugin-dts:generate (22%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/11 finished in 4.6s
[tsdown-build] invocation 2/11 finished in 19.3s






























Assertions:

  • FAIL expect_output: keeps literal $ patterns in HOME when expanding a tilde OPENCLAW_HOME

How this fits together

OpenClaw expands home-relative inputs before resolving config and state locations, deciding launcher help behavior, and authorizing local-media previews. Those expanded paths then control which files are read and whether the UI can fetch an attachment.

flowchart LR
A[Environment or path input] --> B[Home directory lookup]
B --> C[Tilde expansion]
C --> D[Core config and state paths]
C --> E[Daemon state directory]
C --> F[Launcher config lookup]
C --> G[Control UI media policy]
D --> H[Runtime behavior]
E --> H
F --> H
G --> H
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Focused tests and the mock-Gateway UI E2E are valuable regression evidence, but no after-fix run from a real launcher or built Control UI/Gateway setup is attached; add redacted evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The branch is behind current main and its exact-head aggregate CI is currently failed; rebase and refresh the relevant checks before merging.
  • Resolve merge risk (P1) - The PR body contains focused test and mock-Gateway evidence but no attached after-fix real launcher or built Control UI/Gateway run.
  • Complete next step (P2) - This needs contributor-supplied real behavior proof plus rebase/CI refresh, not an automated code repair.
Agent review details

Security

None.

PR surface

Source +3, Tests +147, Other 0. Total +150 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 4 8 5 +3
Tests 5 147 0 +147
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 10 156 6 +150

Review metrics

Metric Value Why it matters
Production versus test delta production +5/-5 (net 0); tests and test support +151/-1 (net +150) The five production substitutions are net-neutral; added coverage spans the independent core, daemon, launcher, and UI boundaries.

Stored data model

Persistent data-model change detected: serialized state: test/openclaw-launcher.e2e.test.ts, serialized state: ui/src/e2e/chat-flow.local-media-dollar-home.e2e.test.ts, vector/embedding metadata: test/openclaw-launcher.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the callback substitutions as the single canonical literal-expansion behavior, then attach a redacted after-fix launcher or built Control UI/Gateway trace and merge only after a clean rebase with green exact-head checks.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the callback substitutions as the single canonical literal-expansion behavior, then attach a redacted after-fix launcher or built Control UI/Gateway trace and merge only after a clean rebase with green exact-head checks.

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

Yes. Current main contains string replacement values at the affected tilde boundaries, and the direct Node reproduction changes /home/$&user into /home/~user until the callback form is used.

Is this the best way to solve the issue?

Yes. Returning the home path from the replacement callback fixes the producer-side language behavior without changing tilde matching, configuration shape, or downstream consumers.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 78826458e384.

Labels

Label justifications:

  • P2: Incorrect tilde expansion can misdirect configuration, state, launcher, or local-media paths for literal-dollar home names, but the affected case is narrow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and the mock-Gateway UI E2E are valuable regression evidence, but no after-fix run from a real launcher or built Control UI/Gateway setup is attached; add redacted evidence before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main defect: Current main passes resolved home paths as string replacement values, so JavaScript interprets replacement tokens during tilde expansion. (src/infra/home-dir.ts:51, 78826458e384)
  • Independent current-main owners: The same string-replacement pattern remains in daemon state resolution, launcher home resolution, and Control UI media-root comparison. (src/daemon/paths.ts:28, 78826458e384)
  • Language-level reproduction: The string replacement produced /home/~user/state, while a callback replacement produced the intended /home/$&user/state.
  • Branch repair and owner tests: The PR head applies callbacks at the core owner and adds literal-dollar regression cases at the core, daemon, launcher, and UI boundaries. (src/infra/home-dir.ts:51, e29765fd28af)
  • Existing sibling precedent: Current main’s terminal display owner already uses the same callback pattern, establishing the intended literal-expansion invariant for this bug class. (packages/terminal-core/src/display-string.ts:53, 78826458e384)
  • History and likely ownership: Repository history identifies Peter Steinberger as the author of an infrastructure-helper refactor touching this owner area; incomplete promisor history prevented a fuller blame trail. (src/infra/home-dir.ts:44, 45961b357df4)

Likely related people:

  • Peter Steinberger: Authored the available infrastructure-helper refactor in the current home-directory owner’s history. (role: recent infrastructure contributor; confidence: medium; commits: 45961b357df4; files: src/infra/home-dir.ts, src/daemon/paths.ts, openclaw.mjs)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted after-fix launcher or built Control UI/Gateway run that visibly preserves a literal-dollar home path.
  • Rebase on current main and obtain green checks for the exact resulting head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-08-18T05:07:51.513Z sha e29765f :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-18T05:30:45.280Z sha e29765f :: needs real behavior proof before merge. :: none

@miorbnli
miorbnli force-pushed the fix/home-dir-replace-dollar-injection branch from 94c8a1f to 8b0fefb Compare August 13, 2026 08:33
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Aug 13, 2026
@miorbnli
miorbnli force-pushed the fix/home-dir-replace-dollar-injection branch from 8b0fefb to 8bc419b Compare August 14, 2026 08:33
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 14, 2026
miorbnli added a commit to miorbnli/openclaw that referenced this pull request Aug 18, 2026
…sions

String.replace interprets dollar-amp/dollar-1/dollar-backtick in the
replacement string. Eight call sites across extensions and
memory-host-sdk expanded ~ using .replace(/^~/, homeVariable), which
corrupts the path when the home directory contains these sequences.

Switch each to a function replacement (() => homeVariable) so the home
path is treated literally. Same fix as the core home-dir resolver
(PR openclaw#122991) and terminal-core/display-string (openclaw#111398).

Affected: voice-call utils + doctor, browser config, migrate-claude,
migrate-hermes, memory-lancedb doctor, memory-host-sdk config-utils.
String.replace interprets dollar-amp/dollar-1/dollar-backtick in the
replacement string. When the home directory contains these sequences
(e.g. a username with a dollar sign), tilde expansion via
.replace(/^~/, fallbackHome) corrupts the path silently.

Use a function replacement so the home path is treated literally,
matching the pattern already fixed in terminal-core/display-string (openclaw#111398).
Two call sites: resolveRawHomeDir and expandHomePrefix.
…nsion

Address review rank-up: the daemon state-path expansion deliberately does
not use the core helper and still passed home as a string replacement.
Apply the callback form here too and add a literal-dollar regression to
the existing service-env suite (fails on the string form, passes with
the callback).
@miorbnli
miorbnli force-pushed the fix/home-dir-replace-dollar-injection branch from 8bc419b to 31c7546 Compare August 18, 2026 04:18
@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Aug 18, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 18, 2026
steipete pushed a commit that referenced this pull request Aug 26, 2026
…#123004)

* fix: prevent dollar-pattern injection in tilde expansion across extensions

String.replace interprets dollar-amp/dollar-1/dollar-backtick in the
replacement string. Eight call sites across extensions and
memory-host-sdk expanded ~ using .replace(/^~/, homeVariable), which
corrupts the path when the home directory contains these sequences.

Switch each to a function replacement (() => homeVariable) so the home
path is treated literally. Same fix as the core home-dir resolver
(PR #122991) and terminal-core/display-string (#111398).

Affected: voice-call utils + doctor, browser config, migrate-claude,
migrate-hermes, memory-lancedb doctor, memory-host-sdk config-utils.

* fix: cover iMessage and 1Password tilde expansion owners

Address review: iMessage CLI path expansion and both 1Password
state-path expansions (OPENCLAW_HOME and OPENCLAW_STATE_DIR) also passed
resolved home as a string replacement. Apply the callback form so a
literal-dollar home path is preserved.

* test(voice-call): add literal-dollar tilde expansion regression

Address review rank-up: mock os.homedir to a literal-dollar path and
assert the resolved path preserves dollar-amp verbatim (fails on the
string replacement form, passes with the callback).

* test(extensions): cover literal-dollar tilde expansion at every changed owner

* test(onepassword): cover tilde OPENCLAW_HOME literal-dollar expansion
steipete and others added 2 commits August 26, 2026 07:26
Resolve the existing unrelated hovercard CI failure and align the contributor branch with the current markdown-it contract while preserving all original contributor commits.

Co-authored-by: liyuanbin <[email protected]>
…ntract

Preserve the current authenticated metadata and ticket-scoped download behavior while exercising the real Chromium Control UI under a literal-dollar home.

Co-authored-by: liyuanbin <[email protected]>
@steipete

Copy link
Copy Markdown
Contributor

Maintainer real-behavior and current-main integration proof for final head 289d1822bdd4d9c0e2941b57a1d73cba39f5763c:

  • Root cause: JavaScript treats $&, $$, $\`` and $'` specially in string replacements. The five remaining shipped tilde-expansion owners now return the resolved home from callbacks, preserving literal paths without changing public configuration, CLI behavior, daemon ownership, or Control UI media authorization.
  • The original contributor's complete five-commit history remains the first parent of the signed current-main merge. Its previous red UI shard was unrelated: the sidebar hovercard intercepted a click, which current main already fixed by focusing the menu button and activating it with Enter. The refresh also aligns the old markdown-it 14 source with current markdown-it 15 and removes its obsolete private imports.
  • Actual isolated launcher proof: env -i PATH=/opt/homebrew/bin:/usr/bin:/bin HOME=/tmp/openclaw-pr122991-sandbox OPENCLAW_STATE_DIR=/tmp/openclaw-pr122991-state OPENCLAW_E2E_SKIP_BUILD=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts test/openclaw-launcher.e2e.test.ts -t 'keeps literal' passes. The test launches the real openclaw.mjs child process with a literal $& home, resolves the intended OPENCLAW_HOME configuration file, and enters the actual configured runtime instead of incorrectly returning precomputed help.
  • Actual built-Control-UI and real Chromium proof: node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner ui/src/e2e/chat-flow.local-media-dollar-home.e2e.test.ts passes with an isolated browser and mocked Gateway. The visible audio attachment is the current compact download card; its literal-dollar home is authorized, its single metadata request carries the mock bearer token, and its download link contains the exact source and scoped media ticket. No raw inline audio/video loads and no false outside-allowed-folders warning appears. A separate owner test also verifies an actual outside-root path stays denied.
  • The first genuine Chromium run against the refreshed branch correctly failed because the contributor's old test expected the removed inline player and two network requests. A test-only follow-up aligned it with the current canonical sibling contract; rerunning the actual built app produced the visible passing attachment screenshot. No production fallback, timeout increase, assertion weakening, or authorization expansion was added.
  • The passing browser screenshot was visually inspected locally and shows the synthetic compact attachment card. It is intentionally not uploaded because this machine's device classification cannot be established under the screenshot-export policy.
  • Core home-resolution regressions: six passing focused cases. Daemon state-path regressions: seven passing focused cases. Control UI allowlisted-home and outside-root policy: passing. Max-lines ratchet, all ten changed-file formatting checks, and diff whitespace checks pass. Five production substitutions are net-zero production LOC.
  • Companion plugin/browser executable-path owners already landed in fix: prevent $-pattern injection in tilde expansion across extensions #123004; together both changes remove every remaining filesystem-home string-replacement instance.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit 20eef85 into openclaw:main Aug 26, 2026
262 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…openclaw#123004)

* fix: prevent dollar-pattern injection in tilde expansion across extensions

String.replace interprets dollar-amp/dollar-1/dollar-backtick in the
replacement string. Eight call sites across extensions and
memory-host-sdk expanded ~ using .replace(/^~/, homeVariable), which
corrupts the path when the home directory contains these sequences.

Switch each to a function replacement (() => homeVariable) so the home
path is treated literally. Same fix as the core home-dir resolver
(PR openclaw#122991) and terminal-core/display-string (openclaw#111398).

Affected: voice-call utils + doctor, browser config, migrate-claude,
migrate-hermes, memory-lancedb doctor, memory-host-sdk config-utils.

* fix: cover iMessage and 1Password tilde expansion owners

Address review: iMessage CLI path expansion and both 1Password
state-path expansions (OPENCLAW_HOME and OPENCLAW_STATE_DIR) also passed
resolved home as a string replacement. Apply the callback form so a
literal-dollar home path is preserved.

* test(voice-call): add literal-dollar tilde expansion regression

Address review rank-up: mock os.homedir to a literal-dollar path and
assert the resolved path preserves dollar-amp verbatim (fails on the
string replacement form, passes with the callback).

* test(extensions): cover literal-dollar tilde expansion at every changed owner

* test(onepassword): cover tilde OPENCLAW_HOME literal-dollar expansion
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…sion (openclaw#122991)

* fix(infra): prevent dollar-pattern injection in home dir tilde expansion

String.replace interprets dollar-amp/dollar-1/dollar-backtick in the
replacement string. When the home directory contains these sequences
(e.g. a username with a dollar sign), tilde expansion via
.replace(/^~/, fallbackHome) corrupts the path silently.

Use a function replacement so the home path is treated literally,
matching the pattern already fixed in terminal-core/display-string (openclaw#111398).
Two call sites: resolveRawHomeDir and expandHomePrefix.

* fix(daemon): prevent dollar-pattern injection in state dir tilde expansion

Address review rank-up: the daemon state-path expansion deliberately does
not use the core helper and still passed home as a string replacement.
Apply the callback form here too and add a literal-dollar regression to
the existing service-env suite (fails on the string form, passes with
the callback).

* fix(launcher): keep literal $ patterns when expanding tilde OPENCLAW_HOME

* fix(ui): keep literal $ patterns in local media tilde expansion

* test(ui): prove literal-$ tilde local media preview through Control UI e2e

* test(ui): align literal-dollar media proof with compact attachment contract

Preserve the current authenticated metadata and ticket-scoped download behavior while exercising the real Chromium Control UI under a literal-dollar home.

Co-authored-by: liyuanbin <[email protected]>

---------

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

Labels

app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants