fix(sandbox): normalize staged script permissions - #7072
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughSandbox build-context staging now normalizes read permissions for scripts in both legacy and optimized paths. Tests create restrictive source modes and verify staged script directories and files remain mode ChangesSandbox script permissions
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Review Advisor — InformationalAdvisor assessment: Informational / high confidence Model lanes
Nemotron output stays in workflow artifacts and does not change the assessment above. E2E guidanceAdvisory only. E2E / PR Gate selects and runs jobs independently. Recommended E2E: None 1 optional E2E recommendation
This automated review informs maintainers. Warnings and suggestions do not require a response. A maintainer decides whether to merge. |
|
Additional Brev validation :
This reproduces the restrictive source-permission precondition and validates the staged-script normalization in a real sandbox build. |
Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
e2952bf to
2ae2d15
Compare
apurvvkumaria
left a comment
There was a problem hiding this comment.
Security-sensitive maintainer review complete at exact head 2ae2d15. The restrictive-umask fix covers both staging paths; mode normalization preserves executability, adds no write bits, does not follow symlinks, and remains confined beneath the private build context. Exact-head CI, CodeQL, DCO, advisor, and protected E2E are green; no unresolved threads or actionable findings remain.
<!-- markdownlint-disable MD041 --> ## Summary A normal `0002` checkout can stage executable Docker payloads as `0775`, so the exact metadata gate added by #7486 aborts a sandbox replacement build. This change clears group and other write bits while preserving owner write and executable intent, so permissive and restrictive source modes both produce canonical Docker payload modes without weakening the gate. ## Changes - Clear group and other write bits in `normalizeReadModesForDockerCopy()` before adding the read, traverse, and executable permissions required by Docker. - Cover optimized and legacy staging with `0775` directory and executable fixtures plus a `0664` non-executable fixture. The tests assert exact staged modes of `0755` and `0644`. - Retain coverage that normalizes restrictive `0700` directories and executables plus `0600` ordinary files. - Confirm the regression history: #3664 introduced read-mode normalization, #7072 applied it to scripts with restrictive-mode coverage, #7332 added `patch-bundled-npm-tar.mts`, and #7486 made its preserved `0775` mode fail the exact `0755` assertion. - Validate the fix on Brev instance `nc-july26` from base SHA `3b2f6d557`. A transactional rebuild with `0775` and `0664` source inputs completed the strict payload metadata stage, replacement creation, state restore, policy restore, and deployment health checks. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Quality Gates - [x] Tests added or updated for changed behavior - [ ] Existing tests cover changed behavior — justification: - [ ] Tests not applicable — justification: - [ ] Docs updated for user-facing behavior changes - [x] Docs not applicable — justification: The fix restores the existing staged-payload permission contract and does not change commands, configuration, or supported workflows. - [x] Sensitive paths changed (security, policy, credentials, preflight, onboarding, inference, runner, sandbox, or messaging) - [ ] Sensitive-path review completed or maintainer-approved waiver recorded — reviewer/approval link/justification: - [ ] Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue: ## Documentation Writer Review - [x] Documentation writer subagent reviewed the completed changes - Result: `no-docs-needed` - Evidence: No documentation files changed. The fix restores canonical staged modes without changing commands, configuration, or supported workflows. The reviewer found no actionable wording issues. - Agent: Codex Desktop <!-- docs-review-head-sha: 14967c5 --> <!-- docs-review-agents-blob-sha: 9c9b36d --> ## DGX Station Hardware Evidence - [ ] Tested on DGX Station - Tested commit: - Station profile/scenario: - Result: - Supporting evidence: ## Verification - [x] PR description includes a `Signed-off-by:` line and every commit appears as `Verified` in GitHub - [x] Normal `pre-commit`, `commit-msg`, and `pre-push` hooks passed, or `npm run check:diff` passed when hooks were skipped or unavailable - [x] Targeted behavior tests pass for the current change set, or tests are marked not applicable above — `npx vitest run test/sandbox-build-context.test.ts src/lib/onboard/build-context-stage.test.ts src/lib/actions/sandbox/rebuild-managed-image-preparation.test.ts` (22/22 passed); `npm run typecheck:cli` passed; Brev `nc-july26` rebuild passed the strict Docker payload metadata stage and completed successfully. - [ ] Applicable broad gate passed — `npm test` for broad runtime/test-harness changes; `npm run check` for repo-wide validation/coverage changes — command/result: - [x] Quality Gates section completed with required justifications or waivers - [x] No secrets, API keys, or credentials committed - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com> Signed-off-by: Senthil Ravichandran <senthilr@nvidia.com>
Summary
NemoClaw now normalizes staged script permissions before Docker consumes either sandbox build context. Fresh installs under a restrictive umask no longer preserve root-only script modes that fail in later non-root image-build stages.
Related Issue
Fixes #7071
Changes
scripts/tree in the legacy sandbox build-context path.stagedScriptsDirafter the optimized path copies its required scripts.umask 0077, including a0700executable helper and0700parent directories.Type of Change
Quality Gates
Verification
Signed-off-by:line and every commit appears asVerifiedin GitHubpre-commit,commit-msg, andpre-pushhooks passed, ornpm run check:diffpassed when hooks were skipped or unavailablenpx vitest run --project integration test/sandbox-build-context.test.ts: 10 passednpm testfor broad runtime/test-harness changes;npm run checkfor repo-wide validation/coverage changes — command/result: not run; this is a focused build-context change with direct regression coverage.npm run docsbuilds without warnings (doc changes only)Signed-off-by: Senthil Ravichandran senthilr@nvidia.com
Summary by CodeRabbit
Bug Fixes
Tests
umask.scripts,scripts/lib, andscripts/lib/reviewed-npm-archive.mtsresolve to the expected readable permissions.