Docker: verifier log mounts are chmod 777 (no sticky), so rewardkit sandboxed graders die before writing a reward

Open Beginner friendly
#4,469 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yuyz-cyber is already working on this.

Since Nov 28, 2026.

  • #4510 by @yuyz-cyber — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
docker, python
Domain
devops, testing

Research direction

The fix sits in environments/base.py, in _ensure_dirs_command and _empty_dirs_command where chmod 777 is applied to the verifier log mounts, with _reset_dirs_command also named. Start by reading how these commands build the mkdir/chmod string, then reproduce the rewardkit parent-trust check in a root container with /logs at 777 versus 1777. Done means the mounts and their parents are sticky (1777) and a sandboxed rewardkit grader writes its reward file under the local Docker path.

Written by the indexing model from the issue text.

Description

The bug

On the local Docker path, Harbor prepares the verifier log mounts with chmod 777 (no sticky bit), and harbor-rewardkit>=0.2.x refuses to start a sandboxed programmatic grader under a parent directory that is group/other-writable unless it is sticky. The grader dies before it can write a reward file, and Harbor reports RewardFileNotFoundError. Symptom: the trial errors with no reward at all, which looks like a task/verifier failure rather than a runner bug.

Two sides of the contract:

  1. harbor-rewardkit==0.2.4 (the version pinned in tests/pyproject.toml of the affected tasks) — sandbox.py:
    private_paths: tuple[Path, ...] = (Path("/tests"), Path("/logs/verifier"))
    …
    owners = {_secure_directory(path, 0o700) for path in self.private_paths}
    …
    # _open_directory(path, trusted=True, create=True):
    # "every parent must be root-owned and not writable by others, or sticky like /tmp"
    if trusted and (parent.st_uid != 0 or (parent.st_mode & 0o022 and not parent.st_mode & stat.S_ISVTX)):
        raise PermissionError(f"Untrusted parent directory of {path}")
    
  2. Harbor 0.27.0 environments/base.py creates exactly those mounts with a non-sticky chmod 777:
    command = f"mkdir -p {create_args}"
    if chmod:
        command += f" && chmod 777 {create_args}"
    

Measured state inside a failing verifier container (<task>__<id>__verifier__trial-main-1, uid 0, no bind mount involved):

/                 uid=0 mode=755
/logs             uid=0 mode=777     ← parent of /logs/verifier, not sticky
/logs/verifier    uid=0 mode=777

→ rewardkit.sandbox.WorkerSetupError: Invalid private path: Untrusted parent directory of /logs/verifier → no reward.txt/reward.json → harbor.verifier.verifier.RewardFileNotFoundError.

Reproduction (no task, no agent, no model token)

Extract the harbor-rewardkit==0.2.4 sdist (sha256 3e8db9a5cd0dace49a3f0dbad7b52ad4edb4baca3b20446b421af2e34cad87ab) and run rewardkit's own guard in a root Linux container, varying only the parent mode:

harbor 777   -> PermissionError: Untrusted parent directory of /logs/verifier
sticky 1777  -> ACCEPTED
default 755  -> ACCEPTED
import importlib.util, sys
from pathlib import Path
spec = importlib.util.spec_from_file_location("rk_sandbox", "/rk/sandbox.py")
rk = importlib.util.module_from_spec(spec); sys.modules["rk_sandbox"] = rk; spec.loader.exec_module(rk)
rk._secure_directory(Path("/logs/verifier"), 0o700)   # with /logs chmod'd 777
Exposure, measured over a full pinned Terminal-Bench 4.1.0 tree

harbor run -p tasks --agent oracle -k 1 -n 2 -r 0 (66 tasks): with the unpatched runner, html-js-filter errored with RewardFileNotFoundError; 17 of 68 tasks invoke the sandboxed rewardkit runner (python -I -m rewardkit /tests --max-concurrent-programmatic …). Exposure is per-task (e.g. production-planning, same runner, passed unpatched), so it is not always fatal — but when it fires it is indistinguishable from a broken task.

After patching the chmods as below, all 17 sandboxed-runner tasks came back clean at reward 1.0, including 5/5 stable repeats on html-js-filter (175/177/178 s, ±2 %). A single earlier attempt at this dataset on the same host class ended with 66/66 trials errored, which this bug explains cleanly.

Proposed fix

Make the log mounts sticky, like /tmp, and cover the parent directories too, since rewardkit validates the whole parent chain:

  • _ensure_dirs_command: chmod 777 … → chmod 1777 …, plus chmod 1777 on Path(d).parent for each mount target.
  • _empty_dirs_command: same substitution.
  • (The third chmod 777 site in _reset_dirs_command appears unused in 0.27.0.)

This is exactly the state rewardkit's own docstring blesses ("or sticky like /tmp"), keeps the world-writability Harbor needs for non-root verifier users, and changes no task content, no scoring and no agent-visible state.

Alternatives considered: relaxing rewardkit's parent-trust rule (weaker — it is a real privilege-escalation guard, and it is right); not bind-mounting log dirs locally and falling back to docker compose cp (bigger change, slower); requiring Modal (upstream CI's layout differs, and cloud-only is unusable for local single-tenant runs).

Environment
  • harbor 0.27.0 (PyPI; newest at time of writing — 0.26.0 carries the same chmod 777 sites)
  • harbor-rewardkit 0.2.4 (pinned by the tasks)
  • Terminal-Bench tag v4.1.0 = 4070d6cef56a7d20cb5dc98d5e10ada88a6b9440
  • Docker 29.8.2 (API 1.56) via OrbStack 2.2.5 on macOS/arm64; --env docker, -k 1, --agent oracle (no model involved)

Adjacent (different root cause, same log-directory theme): #3579, #1632, #2551.

Dominant language
Python
Stars
5.6k
Forks
1.9k
Avg merge
1d 17h
Merged PRs (30d)
156

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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 harbor-framework/harbor

All issues in harbor-framework/harbor

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.