Skip to content

Make toolkit HOME writable for the non-root runtime user - #59

Closed
dmaniloff wants to merge 1 commit into
traust-security:mainfrom
dmaniloff:fix/toolkit-home-permissions
Closed

dmaniloff wants to merge 1 commit into
traust-security:mainfrom
dmaniloff:fix/toolkit-home-permissions

Conversation

@dmaniloff

Copy link
Copy Markdown
Contributor

Fixes #58

Summary

The toolkit image's runtime user (UID 1001) could not write to its home directory, /opt/traust, so opengrep failed on every invocation (Permission denied: '/opt/traust/.opengrep').

The harness npm install -g runs as root with HOME=/opt/traust, which creates /opt/traust as root:root 0755 before the workspace COPY. COPY --chown=1001:0 sets ownership on the copied contents but leaves the existing destination directory as it was. See #58 for details.

This change sets ownership and group permissions on $HOME itself just before the workspace COPY. It touches a single directory and adds no recursive chown layer over the multi-GB tree, preserving the existing layer-size design.

Verification

  • make check passes.

  • The published image (linux/amd64) shows the bug: /opt/traust is root:root 0755, mkdir /opt/traust/.opengrep fails as UID 1001, and the opengrep adapter fails with the default HOME but succeeds with HOME=/tmp.

  • Minimal linux/amd64 reproduction of the full stage: the real pinned base image, HOME, Claude Code npm install and COPY --chown, with the multi-GB assemble stage replaced by a small directory of the same ownership. /opt/traust was then checked as UID 1001:

    HARNESS Before After
    claude root 0755, not writable 1001:0 0775, writable
    none writable writable

A full linux/amd64 toolkit image was not rebuilt. For amd64, the evidence is the published image (which shows the root-owned /opt/traust) plus the minimal reproduction above, which reuses the real base image, HOME, Claude Code npm install and COPY --chown, and stubs out the multi-GB assemble stage.

Not changed

/opt/traust/.npm (npm logs, root-owned) is still left in the image. Moving npm's cache out of $HOME during the build would avoid it, and is an alternative fix if preferred.

Signed-off-by: Diego Maniloff <diego.maniloff@gmail.com>
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Informational

1. Root-owned npm cache stays inside the writable HOME 🐞 Bug ☼ Reliability
Description
The new RUN sets ownership only on the HOME directory itself, but the earlier npm install step runs
as root with HOME=/opt/traust and leaves /opt/traust/.npm root-owned. A process running as UID 1001
that writes npm state under HOME will still get Permission denied, so the same class of failure from
the bug report can recur for npm-based tooling.
Code

Containerfile.toolkit-plus-feeds[215]

+RUN mkdir -p "${HOME}" && chown 1001:0 "${HOME}" && chmod g=u "${HOME}"

Dismiss ↗ | View ↗


Grey Divider

Context sources
❌ Tickets: failed to load — Ticket collection could not establish complete evidence
Review mode: Auto: 🚀 Fast: Localized container permission fix with one straightforward behavioral path.

Grey Divider

Tip of the day
💡 Did you know, you can import rules and skills only from the repositories your team follows

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

pshickeydev added a commit that referenced this pull request Nov 12, 2026
The full stage's npm install ran as root with HOME=/opt/traust, creating a
root-owned /opt/traust/.npm that survived the workspace COPY (COPY merges
contents; it does not fix a pre-existing directory's ownership). The
assemble stage already removes its own .npm before the copy, so pointing
npm's cache at /tmp during the install leaves none in the published image
at all — closing the residual from PR #59 / issue #58.

Verified on a rebuilt image: no /opt/traust/.npm, /opt/traust is 1001:0
and group-writable, and mkdir /opt/traust/.opengrep succeeds as uid 1001
with --network=none (the issue #58 repro).

Assisted-by: GLM-5.3
@pshickeydev

Copy link
Copy Markdown
Member

Commit included as part of #61

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

toolkit-plus-feeds: runtime user cannot write $HOME (/opt/traust), so opengrep fails

2 participants