Skip to content

fix(update): avoid PATH lookup for systemd-run - #650

Closed
luvs01 wants to merge 8 commits into
devfrom
codex/propose-fix-for-systemd-run-vulnerability
Closed

luvs01 wants to merge 8 commits into
devfrom
codex/propose-fix-for-systemd-run-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Motivation

  • Close a local-exec vulnerability where the update worker probe and launch used an unqualified systemd-run found via the inherited PATH, allowing a lower-integrity actor to substitute an executable that would run with the proxy's service context.

Description

  • Replace the PATH-resolved probe with a trusted resolver (resolveSystemdRun) that only considers the absolute candidates /usr/bin/systemd-run, /bin/systemd-run, /usr/local/bin/systemd-run (local installs), and /run/current-system/sw/bin/systemd-run (the NixOS layout) before falling through to the plain detached spawn.
  • Require each candidate to be an executable regular file that is root-owned with no group/world-write bits, inside a directory held to the same rule — mirroring isTrustedSystemPath in src/codex/desktop-app/linux.ts — so a planted or replaced systemd-run in a group-writable /usr/local/bin is skipped instead of being exec'd by the scope probe under the service account.
  • Run the no-op scope probe using the same absolute executable and, when usable, return that exact absolute path for the worker launch from guiUpdateWorkerCommand (introducing resolveSystemdRun in WorkerLaunchContext); a failed probe falls through to the next trusted path.
  • Preserve the existing detached process.execPath fallback when no trusted systemd-run is available, and keep launch semantics otherwise unchanged.
  • Update the regression test tests/update/update-worker-launch.test.ts to assert an attacker-controlled leading PATH is ignored and the candidate order/fall-through, and document the trusted-path contract in structure/ops/service-and-sidecars.md.

Testing

  • bun test tests/update/update-worker-launch.test.ts — 5 pass, 0 fail.
  • The executable/trust check lives in the resolver's default hooks; unit tests inject the hook seam, so the ownership check is covered by the same code path it guards rather than a mocked assertion.

Link to Devin session: https://app.devin.ai/sessions/4a96408ffbbd4381b14d4022a1764a21
Open in Devin Desktop: https://app.devin.ai/desktop/session/4a96408ffbbd4381b14d4022a1764a21?variant=devin
Requested by: @luvs01


Devin Review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 26, 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: Repository: luvs01/opencodex/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 0938fbaa-fbdc-4553-9c9c-01ecd53a436f


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.

devin-ai-integration[bot]

This comment was marked as resolved.

@github-actions github-actions Bot added the bug Something isn't working label Sep 26, 2026
@github-actions

Copy link
Copy Markdown

✅ Deterministic PR hygiene checks passed.

/run/current-system/sw/bin is where systemd-run lives on NixOS layouts,
and a failed scope probe now falls through to the next candidate. The
probe primitives are injectable so the trusted-path walk itself is
under test instead of a bypassed resolver.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 2 commits September 26, 2026 13:36
Co-Authored-By: Epinephrine <luvs01@hanmail.net>
Co-Authored-By: Epinephrine <luvs01@hanmail.net>
devin-ai-integration[bot]

This comment was marked as resolved.

A group-writable /usr/local/bin lets a lower-trust local actor plant or
replace systemd-run, and the no-op scope probe would exec it under the
service account. Candidates now require a root-owned regular file with
no group/world-write bits inside a directory held to the same rule,
matching isTrustedSystemPath; an untrusted candidate falls through to
the next trusted path or the plain detached spawn.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
Repository owner deleted a comment from devin-ai-integration Bot Sep 26, 2026
Repository owner deleted a comment from devin-ai-integration Bot Sep 26, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

…system

Export the default isExecutableFile hook as isTrustedSystemdRunFile and
exercise it directly: non-root-owned executables, non-executable/missing
paths, and (root-run suites only) a root-owned file inside a
group/world-writable directory are all rejected; a real installed
systemd-run is accepted when present. uid/mode semantics are POSIX-only,
so each case is gated on what the test user can arrange.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration Bot and others added 2 commits September 26, 2026 15:33
…ed root fixture

The previous case probed whatever systemd-run the host happened to have
installed, which could legitimately fail the trust predicate on a host
with a nonstandard layout. The positive assertion now uses a fixture we
control: under a root-run suite the temp dir and file are uid-0 with
non-writable modes, so the predicate's acceptance path is deterministic.

Co-Authored-By: Epinephrine <luvs01@hanmail.net>
Co-Authored-By: Epinephrine <luvs01@hanmail.net>
@luvs01

luvs01 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

이관됨: lidge-jun#6037

@luvs01

luvs01 commented Sep 27, 2026

Copy link
Copy Markdown
Owner Author

동일 수정이 상류 저장소에 제출되어 이 포크 PR의 목적은 달성됐습니다.

@luvs01 luvs01 closed this Sep 27, 2026
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