Isolate the worker credential in state.json from task code

Open
#88 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend, security

Research direction

Start with client/src/orcaster_worker/runner.py, the worker image and container flags in client/Dockerfile and Makefile, then review the enrollment probe at setup-scripts/debian13-worker/run-fleet.sh. Compare the separate UID and per-task sandbox options, including volume ownership, capabilities, rootless Podman requirements, and compatibility tests. Done means the chosen opt-in isolation blocks task reads of state.json, preserves task writes and existing enrollment, and updates the tests, documentation, and Unreleased changelog.

Written by the indexing model from the issue text.

Description

client enhancement P2 question

Problem

A task process runs with the same uid as the worker inside the worker container. Task code can read whatever that uid can read, including the worker credential file state.json (worker id and API key), and use it against the server. SECURITY.md:63, SECURITY.md:65 and README.md:463-464 document this as a known limitation.

The worker image runs as one user, uid 1000 (client/Dockerfile:78-79, client/Dockerfile:95). The state dir is owned by that user (client/Dockerfile:92-93) and mounted from the worker data volume (Makefile:993). Task processes are started with asyncio.create_subprocess_exec and only a new session (client/src/orcaster_worker/runner.py:42-51). Nothing changes the uid.

Proposed change

Run task code so that it cannot read state.json. Two options; the choice is part of this issue (see Open questions):

  • A. Separate task uid. Add a second user to the image for task processes. The worker keeps state.json and other private files at mode 0600 under its own uid, and starts each task under the task uid. Shared dirs that tasks must write (cache, task workdir, artifacts) get permissions for the task uid.
  • B. Per-task sandbox. Start each task in a sandbox (for example a user namespace or a nested container) that does not mount the state dir.

In both options, the change starts behind an opt-in worker setting (for example ORCH_TASK_ISOLATION=uid), off by default.

Compatibility

  • With the setting off (the default), workers behave as today. Existing deployments need no change.
  • Option A changes ownership inside the worker data volume. Turning it on requires a re-own step for the existing volume, which the worker or make up client must do on first start. The host-side enrollment probe that reads state.json through podman unshare (setup-scripts/debian13-worker/run-fleet.sh:56-63) must keep working. On a rootless host, state.json is 0600 and owned by the host subuid that maps to the container uid 1000. A re-own to another uid must stay readable for that probe.
  • Option A needs more than a re-own. The worker runs with --cap-drop=ALL and --security-opt=no-new-privileges (Makefile:981-982), so it cannot start a process under another uid. Option A needs CAP_SETUID and CAP_SETGID added by make up client only when the opt-in is on, or a separate privileged launcher. With the setting off, the container flags stay as today.
  • Option A may need a wider subordinate uid range on rootless Podman hosts. Option B changes the runtime requirements of every worker host. Either must be documented before the default changes.
  • The default flips only in a later release, announced in the CHANGELOG with the upgrade steps.

Acceptance criteria

  • With the setting on, a task that tries to read state.json gets a permission error (test that measures it).
  • With the setting on, tasks can still write their cache, workdir and artifacts (tests).
  • With the setting off, behavior and file ownership are unchanged (test).
  • With the setting off, the podman run flags of the worker container are unchanged, including --cap-drop=ALL and --security-opt=no-new-privileges (test).
  • Existing deployments keep working without config changes. The setting is off by default.
  • Enabling the setting on an existing worker keeps its identity: state.json is re-owned, not recreated, and the worker does not need a new enrollment.
  • run-fleet.sh still detects an enrolled worker after the setting is turned on (bats test).
  • With the setting on, SECURITY.md and README.md describe the new boundary. The limitation stays listed for workers that keep it off.
  • CHANGELOG entry under Unreleased with the opt-in and the upgrade step.

Open questions

  • Option A (separate uid) or option B (per-task sandbox)? Option A needs a volume re-own and, when the opt-in is on, extra capabilities for the worker container (CAP_SETUID, CAP_SETGID) or a separate privileged launcher. Which one is acceptable? Option B changes the host requirements of every worker. Both stay behind the opt-in, so existing deployments do not change.
  • When should the default flip from off to on?
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.