Skip to content

[WRONG BRANCH] fix(test): scope test-run lock to user home to avoid cross-user DO S - #345

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-test-lock-mechanism
Draft

[WRONG BRANCH] fix(test): scope test-run lock to user home to avoid cross-user DO S#345
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-vulnerability-in-test-lock-mechanism

Conversation

@luvs01

@luvs01 luvs01 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The test-run lock used a fixed pathname under the OS temporary directory, which is a shared namespace on Unix and allows another local account to claim the pathname and deny other users from running tests. This change narrows the lock's scope to the current user to prevent cross-user denial-of-service.

Description

  • Replace the shared /tmp-based default lock with a user-local lock path and expose resolveDefaultTestRunLockPath(home?: string): string that returns join(homedir(), ".opencodex-bun-test.lock") and use it as the default lock location in acquireTestRunLock (scripts/test-run-lock.ts).
  • Update wrapper and preload diagnostics to call this a "user lock" instead of a "machine lock" (scripts/test.ts, tests/preload.ts).
  • Add a regression test asserting the default lock path resolves under a supplied home directory and rename the test suite labels accordingly (tests/test-runner.test.ts).
  • Keep existing behavior and options: callers can still supply lockPath to override, and the OCX_TEST_NO_QUEUE=1 escape hatch remains supported.

Testing

  • Ran bun test --preload ./tests/preload.ts tests/test-runner.test.ts; the modified runner tests passed overall for the lock-related cases (16 passed, 2 skipped) while one unrelated wrapper assertion failed due to the environment's Bun binary version not emitting the expected PARALLEL marker (environment mismatch), so the lock regression assertions themselves succeeded.
  • Ran repository preflight (bun run prepush) which completed typecheck and GUI lint steps; the full test suite exercised many environment-sensitive baseline failures unrelated to this change (several long-running/timeouting tests and sandbox-related Lab failures), but the lock-related unit and integration checks included here passed.
  • git diff --check and local verification of modified files were performed and showed only the intended edits to scripts/test-run-lock.ts, scripts/test.ts, tests/preload.ts, and tests/test-runner.test.ts.

Codex Task

@github-actions github-actions Bot added the bug Something isn't working label Aug 28, 2026
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 13231964-dae6-4f52-9d05-e74206ffb9bc


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(test): scope test-run lock to user home to avoid cross-user DO S [WRONG BRANCH] fix(test): scope test-run lock to user home to avoid cross-user DO S Aug 28, 2026
@github-actions
github-actions Bot marked this pull request as draft August 28, 2026 02:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 431b997c78

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/test-run-lock.ts

/** Keep the shared lock in a directory controlled by the current OS user. */
export function resolveDefaultTestRunLockPath(home = homedir()): string {
return join(home, ".opencodex-bun-test.lock");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the PID-based lock on a host-local filesystem

When the same home directory is mounted on multiple hosts, as with NFS/SMB enterprise homes or CI containers sharing a home volume, this path makes those hosts operate on one lock even though processIsAlive() checks PIDs only on the local host. A second host can therefore reclaim an active lock because its local PID is absent and run a suite concurrently, or wait 45 minutes because an unrelated local process has the same PID. Use a user-owned host-local directory, or include a stable host identity in the lock namespace, so the lock's filesystem scope matches its PID-liveness scope.

AGENTS.md reference: scripts/AGENTS.md:L14-L15

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant