Repository navigation
Description
Client or integration
OpenCodex dashboard
Area
Service lifecycle
Summary
A Dashboard-triggered npm self-update can leave OpenCodex unavailable (HTTP 502 from the reverse proxy) on Linux when the running proxy belongs to a system-wide systemd service under an unprivileged UID, rather than the canonical systemd user service. An update worker may die when the original service's cgroup is stopped; moreover the updater may target a different, installed-but-inactive user unit. The Dashboard job file can remain running with a dead worker PID.
Expected: never stop an active proxy unless a worker can outlive the stop and can restart the actual owner. Unsupported custom system units should receive an actionable, fail-closed error before package mutation.
Reproduction
- Configure a custom root-owned systemd service with
User=<unprivileged-user>,KillMode=control-group,OCX_SERVICE_MANAGED=1, andExecStart=ocx start --port 10101. Keep an OpenCodex-managedsystemctl --userservice installed but inactive. - With OpenCodex v2.89.0 running under the system unit, start a v2.93.0 npm update with
restart:truefrom the Dashboard. - During stop/restart, the original proxy disappears and the browser reports 502; the update job can remain
runningeven though its recorded PID is dead. - Non-destructive supporting reproduction under the same UID:
systemd-run --user --scope --quiet --collect -- /usr/bin/truefails withFailed to connect to bus: No medium foundwhen the system service hasINVOCATION_IDbut noXDG_RUNTIME_DIR. Supplying the verified private/run/user/<uid>makes the scope probe exit 0. A test process launched in that scope is shown under/user.slice/.../app.slice/run-*.scope, outside the system unit cgroup. - Distinct installed supervisor state was reproduced:
ocx service status --jsonreports the user unit installed/enabled but running:false, viable:false, while the independent system unit serves HTTP 200.
The full destructive update scenario has not been re-enacted after remediation; do not treat the non-destructive probes alone as a completed E2E certification.
Version
OpenCodex 2.89.0 → 2.93.0; source baseline v2.93.0 commit 88aaa754566d119b6b8fc898f8fb47602387d82e.
Operating system
Linux, systemd system service + lingered systemd user manager, Bun 1.4.4.
Provider and model
Not provider-specific.
Logs or error output
Failed to connect to bus: No medium found
OWNERSHIP_MUTATION_LEASE_BUSY: another process owns the runtime mutation lease
(recorded PID no longer alive; lease age below stale-reclaim grace period)
systemd: Main process exited, status=1/FAILURE
systemd: Failed to start OpenCodex proxy service
Screenshots and supporting files
The operator captured HTTP 502 Bad gateway during the Dashboard upgrade and a separate startup-safety warning. No screenshots containing private hostnames or identifiers are uploaded here.
Redacted configuration
{
"systemService": {
"type": "systemd system",
"user": "<unprivileged uid>",
"killMode": "control-group",
"managed": true
},
"dashboardUpdate": {
"installer": "npm",
"restart": true
},
"userService": {
"installed": true,
"enabled": true,
"running": false
}
}Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Suggested safety contract
- Identify and attest the actual running supervisor before beginning update.
- Spawn the updater in an independently managed scope with a verified UID-private user-bus socket. Refuse safely if that is impossible.
- Do not target an unrelated user unit when a root-owned custom system unit owns the listener; such a migration needs operator-supervised authorization.
- Record a terminal, actionable
failedstate when the updater PID died; avoid indefiniterunningstatus. - Test service stop, update, restart identity, health stability, rollback and cgroup survival.
A staging-only candidate adds these guards with synthetic tests; it is not deployed or certified.
Activity
github-actions commentedon Oct 29, 2026
Issue reopened
The report now contains the information required by the automated check. Thanks for updating it.
[-]Dashboard update can kill its worker under custom systemd system unit; missing XDG_RUNTIME_DIR and wrong supervisor[/-][+][Bug] Dashboard self-update loses worker under custom systemd system service[/+]RHODIZSECURITY commentedon Oct 29, 2026
Follow-up: reproducible on the latest v2.94.0 tree (29 Oct 2026)
The affected system has two simultaneously enabled systemd definitions: a root-owned system unit currently serving OpenCodex and an OpenCodex-generated user unit inactive. The active process is UID 1001 inside
/system.slice/opencodex-rhodiz.service, hasINVOCATION_ID, but noXDG_RUNTIME_DIRnorDBUS_SESSION_BUS_ADDRESS. These service definitions also use different API-token files/values, so blindly switching service ownership risks client failures.Non-destructive, root-authorized probes on the affected VM:
systemd-run --user --scope --quiet --collect -- /usr/bin/trueunder UID 1001 withXDG_RUNTIME_DIRabsent: exit 1 (Failed to connect to bus: No medium found)./run/user/1001: exit 0.cat /proc/self/cgroupconfirms/user.slice/user-1001.slice/[email protected]/app.slice/run-<...>.scope, independent of the proxy's root-owned service cgroup.update-job.jsonwas left asrunningwith a dead PID after the original upgrade and systemd recordedOWNERSHIP_MUTATION_LEASE_BUSYduring restart.I checked official tag v2.94.0 (commit
d844ff4af67c98271be1c1451e7583d36c323527): the Dashboard still resolvessystemd-run --userfrom the service environment, with plain detached-spawn fallback; a root-owned system unit isn't rejected as an unsupported supervisor. This scenario remains open in that tag.A defensive patch is being rebased and certified in a private RHODIZ branch. It (a) validates UID/cgroup ownership and rejects update before stopping a root-owned system unit, (b) validates the user-runtime path and socket for scope discovery, (c) prevents fallback to an unsafe in-cgroup update worker, and (d) displays a failed status for a dead updater instead of an endless spinner. It is not deployed or production-certified yet. We will provide an upstream PR and test evidence once the complete gated suite passes.
RHODIZSECURITY commentedon Oct 30, 2026
The v2.94.0-based mitigation for the root-owned systemd service Dashboard crash is now in RHODIZ draft PR #7, tree
f33483ec6435dfff636b642ef20e83a15f76ae5e. It refuses a GUI update before it stops a listener owned by a system-wide unit, validates the lingered user bus, refuses unsafe in-cgroup fallback, and exposes a dead/stale update worker as failed with a PID-starttime fence. The affected VM has a separate user unit; switching ownership while preserving the external API token and security controls is a controlled deployment step, not something this PR silently performs. The old root system service remains healthy in production. Full suite/CI and an actual user-supervised Dashboard update are required before we can assert the failure is fully fixed.fix(update): refuse dashboard restart under a systemd unit OpenCodex …
lidge-jun commentedon Oct 30, 2026
Partly fixed by #7996, merged into
devas261131d3726d95b4ad3335cf416254a868963e08. These are the fail-closed parts of the safety contract:opencodex-proxy.serviceuser unit. The reported custom system unit withUser=and an inactive user unit installed is one such case. The same refusal applies when the worker cannot be moved into its ownsystemd-run --user --scope. The response is 409update_restart_unsupervised, and it tells the operator to stop the service with its own manager, update from a shell, and start it again. This keeps the updater from killing its own worker with the cgroup and from aiming its restart at the unrelated user unit.GET /api/update/statusnow reports an active job whose worker PID is gone asfailedwith the reason, instead ofrunningforever. The next run's existing stale recovery settles the persisted record.Still open here: identifying and attesting a custom system unit as the supervisor so the dashboard can update it, and any operator-authorized migration to or restart of such a unit. A real systemd system-unit update has not been re-enacted. Verification is source review plus deterministic tests with injected cgroup and liveness inputs.
lidge-jun commentedon Nov 3, 2026
Closing as fixed by #7996 (261131d, released in 2.95.0), which implements the fail-closed contract this report asks for. When the proxy runs inside a systemd unit other than OpenCodex's own
opencodex-proxy.serviceuser unit, or the worker cannot move into its ownsystemd-run --user --scope, a dashboard update is refused with 409update_restart_unsupervisedbefore any package mutation, with instructions to stop the service with its own manager, update from a shell and start it again (src/server/management/config-routes.ts).GET /api/update/statusreports a job whose worker PID is gone asfailed.tests/server/update-async-routes.test.ts("dashboard update restart supervision (#7967)") covers both. Letting the dashboard update and restart a custom system unit it can attest as the supervisor would be a new capability; please open a feature proposal for it.github-actions commentedon Nov 3, 2026
Automated translation bookkeeping — detected language: English.