Skip to content

fix(sandbox): make rlimit helper posix-sh safe - #5840

Merged
cv merged 6 commits into
mainfrom
fix/posix-sh-sandbox-rlimits
Jun 26, 2026
Merged

fix(sandbox): make rlimit helper posix-sh safe#5840
cv merged 6 commits into
mainfrom
fix/posix-sh-sandbox-rlimits

Conversation

@cv

@cv cv commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make the shared sandbox rlimit helper safe to source from POSIX /bin/sh profile hooks. This prevents openshell sandbox exec ... sh -lc ... probes from emitting bash-only builtin ulimit warnings while preserving the shadowed-ulimit bypass in bash.

Changes

  • Switch scripts/lib/sandbox-rlimits.sh from bash-only builtin ulimit calls to a POSIX-safe command ulimit wrapper.
  • Skip verification for resource-limit flags unsupported by the active shell, such as ulimit -u under dash, instead of reporting unknown limits.
  • Add a POSIX-sh regression test and update shadowed-ulimit tests to cover the new helper behavior.

Type of Change

  • 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

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Docs updated for user-facing behavior changes
  • Docs not applicable — justification: internal sandbox rlimit/profile-hook compatibility fix; no user-facing command or configuration change.
  • 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: author self-review; change is limited to the sandbox rlimit helper, keeps the shadowed-ulimit hardening test, and passes shellcheck/prek plus targeted tests.
  • Non-success, skipped, or missing CI check accepted by maintainer — check name, approval link, and follow-up issue:

Verification

  • PR description includes the DCO sign-off declaration and every commit appears as Verified in GitHub
  • Git hooks passed during commit and push, or npx prek run --from-ref main --to-ref HEAD passes
  • Targeted tests pass for changed behavior
  • Full npm test passes (broad runtime changes only)
  • Quality Gates section completed with required justifications or waivers
  • No secrets, API keys, or credentials committed
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

  • Bug Fixes
    • Improved resource-limit hardening and verification for POSIX sh, especially when ulimit is shadowed by shell functions.
    • Resource-limit checks now detect supported ulimit flags and validate effective numeric limits more reliably, reducing incorrect verification failures.
  • Tests
    • Expanded POSIX sh test coverage for rlimit hooks and sandbox hardening, including bypassing shadowed ulimit.
    • Added/adjusted scenarios to confirm unsafe or unbounded nofile targets are rejected.

@cv cv self-assigned this Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The sandbox rlimit library now probes resource-flag support, uses command ulimit, and skips verification for unsupported limits. Tests update shadowed-ulimit expectations and add POSIX sh coverage for the rlimit helpers.

Changes

Sandbox RLIMIT handling

Layer / File(s) Summary
RLIMIT probing and verification
scripts/lib/sandbox-rlimits.sh
Adds command ulimit, resource-flag support probing, guarded limit application, and verification that returns success for unsupported flags.
Shadowed ulimit assertions
test/sandbox-init.test.ts, test/sandbox-rlimit-hooks.test.ts
Updates the hook assertions to bypass shadowed ulimit functions and adjusts the non-darwin nprocLimit expectation.
POSIX sh coverage
test/sandbox-rlimit-hooks.test.ts
Adds a helper that runs sandbox-rlimits.sh under sh and a temp-file test that exercises it.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • NVIDIA/NemoClaw#5682: Shares the sandbox-rlimits.sh enforcement path and the same ulimit shadowing behavior updated here.

Suggested labels

area: sandbox, bug-fix

Poem

A rabbit hopped through moonlit code,
past ulimit shadows, lightened load.
It twitched its nose and whispered, “Bink!”
“Quiet limits now? I give a wink.” 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 7.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making the sandbox rlimit helper safe for POSIX sh.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/posix-sh-sandbox-rlimits

Comment @coderabbitai help to get the list of available commands.

@github-code-quality

github-code-quality Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/plugin

The overall coverage in the fix/posix-sh-sandbox... branch is 96%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/posix-sh-sandbox... 3527564 +/-
nemoclaw/src/se...cret-scanner.ts 100%
nemoclaw/src/commands/slash.ts 100%
nemoclaw/src/li...bprocess-env.ts 100%
nemoclaw/src/bl...eprint/state.ts 98%
nemoclaw/src/onboard/config.ts 98%
nemoclaw/src/bl...int/snapshot.ts 97%
nemoclaw/src/bl...print/runner.ts 95%
nemoclaw/src/co...ration-state.ts 94%
nemoclaw/src/bl...ate-networks.ts 94%
nemoclaw/src/index.ts 94%

TypeScript / code-coverage/cli

The overall coverage in the fix/posix-sh-sandbox... branch is 47%. Coverage data for the main branch is not yet available.

Show a code coverage summary of the most covered files.
File main fix/posix-sh-sandbox... 3527564 +/-
src/lib/state/o...oard-session.ts 91%
src/lib/actions...dbox/rebuild.ts 72%
src/lib/sandbox/config.ts 72%
src/lib/onboard/preflight.ts 62%
src/lib/shields/index.ts 62%
src/lib/actions...licy-channel.ts 60%
src/lib/state/sandbox.ts 56%
src/lib/policy/index.ts 48%
src/lib/onboard...er-gpu-patch.ts 47%
src/lib/onboard.ts 19%

Updated June 26, 2026 08:28 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

PR Review Advisor — Changes requested

Merge posture: Do not merge yet
Primary next action: Resolve or justify PRA-1: Source-of-truth review needed: scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path.
Open items: 0 required · 2 warnings · 0 suggestions · 4 test follow-ups
Since last review: 1 prior item resolved · 1 still applies · 0 new items found

Action checklist

  • PRA-1 Resolve or justify: Source-of-truth review needed: scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path
  • PRA-2 Resolve or justify: Unsupported RLIMIT fallback is broader than the documented nproc compatibility case in scripts/lib/sandbox-rlimits.sh:64
  • PRA-T1 Add or justify test follow-up: Runtime validation
  • PRA-T2 Add or justify test follow-up: Runtime validation
  • PRA-T3 Add or justify test follow-up: Acceptance clause
  • PRA-T4 Add or justify test follow-up: scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path

Findings index

ID Severity Category Location Required action
PRA-1 Resolve/justify architecture Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
PRA-2 Resolve/justify security scripts/lib/sandbox-rlimits.sh:64 Narrow the compatibility path so only the known unsupported `nproc`/POSIX-sh case is allowed to skip, and make unsupported `nofile` or unknown resource flags warn/fail verification. If silent `nproc` skip remains intentional, encode that boundary in code rather than relying only on the comment.
Review findings by urgency: 0 required fixes, 2 items to resolve/justify, 0 in-scope improvements

⚠️ Resolve or justify before merge

Investigate these in the current review; either fix them, explain why they are not applicable, or document the accepted risk.

PRA-1 Resolve/justify — Source-of-truth review needed: scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: `test/sandbox-rlimit-hooks.test.ts` sources the helper under `sh`, verifies supported `nofile` enforcement, and simulates unsupported `-Su|-Hu` while ensuring stricter supported `nofile` verification still fails.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: The source-of-truth explanation is present in `scripts/lib/sandbox-rlimits.sh`, but the code still applies the unsupported skip to every flag rather than encoding the documented `nproc` boundary or escalation for `nofile`.

PRA-2 Resolve/justify — Unsupported RLIMIT fallback is broader than the documented nproc compatibility case

  • Location: scripts/lib/sandbox-rlimits.sh:64
  • Category: security
  • Problem: `_nemoclaw_verify_resource_limit` returns success for any unsupported resource flag, and `_nemoclaw_set_resource_limit` skips any unsupported flag. The nearby comment justifies the compatibility path for POSIX `/bin/sh`/dash lacking `nproc (-u)`, but the implementation also silently accepts unsupported `nofile (-n)` or any future security limit.
  • Impact: A runtime or regression that makes `nofile` probing fail would let `verify_resource_limits` report success even though the file-descriptor cap was not verified or enforced. That weakens sandbox resource-exhaustion hardening and makes a security-control loss look like a clean startup.
  • Recommended action: Narrow the compatibility path so only the known unsupported `nproc`/POSIX-sh case is allowed to skip, and make unsupported `nofile` or unknown resource flags warn/fail verification. If silent `nproc` skip remains intentional, encode that boundary in code rather than relying only on the comment.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read `scripts/lib/sandbox-rlimits.sh` around `_nemoclaw_supports_resource_limit`, `_nemoclaw_set_resource_limit`, and `_nemoclaw_verify_resource_limit`; confirm unsupported `u` and unsupported `n` currently both bypass set/verify and return success.
  • Missing regression test: Add a POSIX-sh probe in `test/sandbox-rlimit-hooks.test.ts` that overrides `_nemoclaw_ulimit` to return unsupported for `-Sn|-Hn`, calls `verify_resource_limits` without `--quiet`, and asserts verification fails or emits an explicit unsupported-`nofile` diagnostic. Keep the existing unsupported-`nproc` test to prove only that documented compatibility case is tolerated.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read `scripts/lib/sandbox-rlimits.sh` around `_nemoclaw_supports_resource_limit`, `_nemoclaw_set_resource_limit`, and `_nemoclaw_verify_resource_limit`; confirm unsupported `u` and unsupported `n` currently both bypass set/verify and return success.
  • Evidence: `scripts/lib/sandbox-rlimits.sh` checks `_nemoclaw_supports_resource_limit` generically before setting or verifying a flag. The added test `expectUnsupportedNprocDoesNotMaskPosixShNoFile` simulates unsupported `-Su|-Hu`, but no changed test simulates unsupported `-Sn|-Hn` and proves it is escalated.

💡 In-scope improvements

These are lower-risk, not throwaway. Prefer fixing them in this PR when they are local to changed code; defer only with rationale or a linked follow-up.

  • None.
Simplification opportunities: 1 possible cut

These are safe simplification checks only. Do not remove validation, security controls, data-loss prevention, or required tests.

  • PRA-2 shrink (scripts/lib/sandbox-rlimits.sh:64): The generic unsupported-resource success path for every RLIMIT flag.
    • Replacement: A small allowlist/branch that tolerates only unsupported `u` with the documented POSIX-sh nproc rationale, while treating unsupported `n` or unknown future flags as a verification warning/failure.
    • Safety boundary: Do not remove the POSIX-shell compatibility, quoting, shadowed-`ulimit` bypass, or independent supported-limit verification.
Test follow-ups to resolve or justify

If these cover changed behavior, prefer adding them in this PR; otherwise state why existing coverage is enough or link the follow-up.

  • PRA-T1 Runtime validation — Simulate unsupported `-Sn|-Hn` in a POSIX-sh probe and assert `verify_resource_limits` fails or emits an explicit unsupported-`nofile` diagnostic.. This PR changes sandbox runtime hardening in a sourced shell/profile-hook path. The added shell probes provide good targeted runtime coverage; one additional negative path is needed for the broadened unsupported-RLIMIT behavior.
  • PRA-T2 Runtime validation — If the implementation is narrowed, keep or add a regression proving unsupported `-Su|-Hu` is the only silent compatibility skip and that supported `nofile` verification still fails for too-strict targets.. This PR changes sandbox runtime hardening in a sourced shell/profile-hook path. The added shell probes provide good targeted runtime coverage; one additional negative path is needed for the broadened unsupported-RLIMIT behavior.
  • PRA-T3 Acceptance clause — Skip verification for resource-limit flags unsupported by the active shell, such as `ulimit -u` under dash, instead of reporting `unknown` limits. — add test evidence or identify existing coverage. `_nemoclaw_verify_resource_limit` now skips unsupported flags and the tests simulate unsupported `-Su|-Hu` without `nproc`/`unknown` diagnostics. The implementation is broader than the stated example because it also skips unsupported `nofile` or future flags; see the security finding.
  • PRA-T4 scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path — `test/sandbox-rlimit-hooks.test.ts` sources the helper under `sh`, verifies supported `nofile` enforcement, and simulates unsupported `-Su|-Hu` while ensuring stricter supported `nofile` verification still fails.. The source-of-truth explanation is present in `scripts/lib/sandbox-rlimits.sh`, but the code still applies the unsupported skip to every flag rather than encoding the documented `nproc` boundary or escalation for `nofile`.
Since last review details

Current findings, using the urgency labels above:

PRA-1 Resolve/justify — Source-of-truth review needed: scripts/lib/sandbox-rlimits.sh unsupported resource-limit compatibility path

  • Location: not file-specific
  • Category: architecture
  • Problem: The advisor marked localized patch analysis as needs_followup.
  • Impact: A localized workaround can preserve or hide an invalid state when the source boundary is unclear.
  • Recommended action: Identify the invalid state, source boundary, source-fix constraint, regression test, and removal condition before merging the localized behavior.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Missing regression test: `test/sandbox-rlimit-hooks.test.ts` sources the helper under `sh`, verifies supported `nofile` enforcement, and simulates unsupported `-Su|-Hu` while ensuring stricter supported `nofile` verification still fails.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Inspect the localized patch and source-of-truth review fields for a concrete invalid state, source boundary, source-fix constraint, regression test, and removal condition.
  • Evidence: The source-of-truth explanation is present in `scripts/lib/sandbox-rlimits.sh`, but the code still applies the unsupported skip to every flag rather than encoding the documented `nproc` boundary or escalation for `nofile`.

PRA-2 Resolve/justify — Unsupported RLIMIT fallback is broader than the documented nproc compatibility case

  • Location: scripts/lib/sandbox-rlimits.sh:64
  • Category: security
  • Problem: `_nemoclaw_verify_resource_limit` returns success for any unsupported resource flag, and `_nemoclaw_set_resource_limit` skips any unsupported flag. The nearby comment justifies the compatibility path for POSIX `/bin/sh`/dash lacking `nproc (-u)`, but the implementation also silently accepts unsupported `nofile (-n)` or any future security limit.
  • Impact: A runtime or regression that makes `nofile` probing fail would let `verify_resource_limits` report success even though the file-descriptor cap was not verified or enforced. That weakens sandbox resource-exhaustion hardening and makes a security-control loss look like a clean startup.
  • Recommended action: Narrow the compatibility path so only the known unsupported `nproc`/POSIX-sh case is allowed to skip, and make unsupported `nofile` or unknown resource flags warn/fail verification. If silent `nproc` skip remains intentional, encode that boundary in code rather than relying only on the comment.
  • Expected follow-up: Resolve in this PR or explain why the risk is acceptable.
  • Verification: Read `scripts/lib/sandbox-rlimits.sh` around `_nemoclaw_supports_resource_limit`, `_nemoclaw_set_resource_limit`, and `_nemoclaw_verify_resource_limit`; confirm unsupported `u` and unsupported `n` currently both bypass set/verify and return success.
  • Missing regression test: Add a POSIX-sh probe in `test/sandbox-rlimit-hooks.test.ts` that overrides `_nemoclaw_ulimit` to return unsupported for `-Sn|-Hn`, calls `verify_resource_limits` without `--quiet`, and asserts verification fails or emits an explicit unsupported-`nofile` diagnostic. Keep the existing unsupported-`nproc` test to prove only that documented compatibility case is tolerated.
  • Done when: The risk is fixed or explicitly justified in the PR. Verification: Read `scripts/lib/sandbox-rlimits.sh` around `_nemoclaw_supports_resource_limit`, `_nemoclaw_set_resource_limit`, and `_nemoclaw_verify_resource_limit`; confirm unsupported `u` and unsupported `n` currently both bypass set/verify and return success.
  • Evidence: `scripts/lib/sandbox-rlimits.sh` checks `_nemoclaw_supports_resource_limit` generically before setting or verifying a flag. The added test `expectUnsupportedNprocDoesNotMaskPosixShNoFile` simulates unsupported `-Su|-Hu`, but no changed test simulates unsupported `-Sn|-Hn` and proves it is escalated.

Workflow run details

This is an automated, non-binding review; it still expects maintainers and agents to respond to each required or warning item. Treat suggestions as current-PR improvements when they touch changed code; defer only with maintainer rationale or a linked follow-up. A human maintainer must make the final merge decision.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

E2E Advisor Recommendation

Required E2E: openclaw-onboard-security-posture-e2e, sandbox-operations-e2e, hermes-root-entrypoint-smoke-e2e
Optional E2E: hermes-onboard-security-posture-e2e, sandbox-survival-e2e

Dispatch hint: openclaw-onboard-security-posture-e2e,sandbox-operations-e2e,hermes-root-entrypoint-smoke-e2e

Auto-dispatched E2E: hermes-root-entrypoint-smoke-e2e via nightly-e2e.yaml at 352756472f93390aa9fce34a684879e59c9d522anightly run

Workflow run

Full advisor summary

E2E Recommendation Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required E2E

  • openclaw-onboard-security-posture-e2e (high): Runs a real OpenClaw onboard with security posture assertions and uses OpenShell sandbox exec paths that source profile hooks under sh. This is the closest existing live coverage for the POSIX-sh RLIMIT hook and sandbox security-boundary behavior changed here.
  • sandbox-operations-e2e (high): Exercises real sandbox lifecycle operations, SSH/connect-style access, tmux/forkpty behavior, process recovery, and teardown. RLIMIT hook regressions can break shell startup or make process limits too strict/too loose during these flows.
  • hermes-root-entrypoint-smoke-e2e (medium): The shared RLIMIT helper is also sourced by Hermes sandbox startup. This job builds the real Hermes image and verifies root entrypoint startup, catching shell/runtime regressions in the shared hardening path for the Hermes assistant.

Optional E2E

  • hermes-onboard-security-posture-e2e (high): Optional broader Hermes confidence: performs a full Hermes onboard with security posture checks, complementing the root-entrypoint smoke with the full hosted assistant path.
  • sandbox-survival-e2e (medium): Optional lifecycle confidence that onboarded sandboxes remain usable across gateway restarts and live inference after the RLIMIT/profile-hook changes.

New E2E recommendations

  • sandbox RLIMIT connect shell enforcement (high): A live scenario already exists at test/e2e-scenario/live/sandbox-rlimits-connect.test.ts, but it does not appear to be wired as a dispatchable/nightly job. This PR directly affects that behavior.
    • Suggested test: Add a dispatchable sandbox-rlimits-connect-e2e or sandbox-rlimits-connect-vitest job that sets NEMOCLAW_RUN_E2E_SCENARIOS=1 and NEMOCLAW_E2E_CONNECT_RLIMITS=1 and runs the existing sandbox-rlimits-connect live scenario.
  • POSIX sh OpenShell exec profile hook compatibility (high): The change specifically handles unsupported nproc under /bin/sh-compatible profile hooks during openshell sandbox exec. Existing unit tests cover this locally, but there is no clearly wired live E2E that asserts real openshell sandbox exec -- sh -lc emits no false security warnings while still enforcing nofile.
    • Suggested test: Add a live sandbox-rlimits-posix-sh-exec-e2e probe that onboards a sandbox, runs openshell sandbox exec -- sh -lc ..., verifies no RLIMIT false-warning noise for unsupported nproc, and verifies supported nofile remains bounded.

Dispatch hint

  • Workflow: .github/workflows/nightly-e2e.yaml
  • jobs input: openclaw-onboard-security-posture-e2e,sandbox-operations-e2e,hermes-root-entrypoint-smoke-e2e

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Vitest E2E Scenario Recommendation

Required Vitest E2E scenarios: ubuntu-repo-cloud-openclaw
Optional Vitest E2E scenarios: ubuntu-repo-cloud-langchain-deepagents-code

Dispatch required Vitest E2E scenarios:

  • gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-openclaw

Workflow run

Full Vitest E2E advisor summary

Vitest E2E Scenario Advisor

Base: origin/main
Head: HEAD
Confidence: high

Required Vitest E2E scenarios

  • ubuntu-repo-cloud-openclaw: The PR changes scripts/lib/sandbox-rlimits.sh, which is sourced by sandbox entrypoints/profile hooks and can affect live Docker sandbox startup or openshell sandbox exec behavior. The default live-supported Ubuntu repo OpenClaw scenario is the smallest Vitest scenario that exercises this shared sandbox runtime surface.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-openclaw

Optional Vitest E2E scenarios

  • ubuntu-repo-cloud-langchain-deepagents-code: Optional adjacent coverage for the same shared RLIMIT sandbox hook under the live-supported LangChain Deep Agents Code onboarding path; not the primary target because the changed helper is common infrastructure and the OpenClaw scenario covers the default Docker sandbox path.
    • Dispatch: gh workflow run e2e-vitest-scenarios.yaml --ref <pr-head-ref> --field scenarios=ubuntu-repo-cloud-langchain-deepagents-code

Relevant changed files

  • scripts/lib/sandbox-rlimits.sh

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@test/sandbox-rlimit-hooks.test.ts`:
- Around line 171-182: The POSIX shell probe in expectRlimitLibIsPosixShSafe can
continue past a failed source, missing harden_resource_limits function, or
failing verify_resource_limits and still print ok; update the probe so it stops
on any non-zero command before the success print, using the existing probe
assembly in expectRlimitLibIsPosixShSafe to ensure failures are surfaced
correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 59c634de-8ab2-44e9-928b-1dee529c8858

📥 Commits

Reviewing files that changed from the base of the PR and between 31b28d7 and 7d2da95.

📒 Files selected for processing (3)
  • scripts/lib/sandbox-rlimits.sh
  • test/sandbox-init.test.ts
  • test/sandbox-rlimit-hooks.test.ts

Comment thread test/sandbox-rlimit-hooks.test.ts Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28224381191
Target ref: 7d2da95a173a833d15c991fa3b112b247442d050
Workflow ref: main
Requested jobs: hermes-root-entrypoint-smoke-e2e
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
hermes-root-entrypoint-smoke-e2e ✅ success

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28225024844
Target ref: 97e05a354d8025ead6a125ece394bd5c7f0cea11
Workflow ref: main
Requested jobs: hermes-root-entrypoint-smoke-e2e
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
hermes-root-entrypoint-smoke-e2e ✅ success

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28225749543
Target ref: 708d3a39035fe1faac9e5b86de47538f9fd5e299
Workflow ref: main
Requested jobs: hermes-root-entrypoint-smoke-e2e
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
hermes-root-entrypoint-smoke-e2e ✅ success

@github-actions

Copy link
Copy Markdown
Contributor

Selective E2E Results — ✅ All requested jobs passed

Run: 28226596253
Target ref: 352756472f93390aa9fce34a684879e59c9d522a
Workflow ref: main
Requested jobs: hermes-root-entrypoint-smoke-e2e
Summary: 1 passed, 0 failed, 0 cancelled, 0 skipped

Job Result
hermes-root-entrypoint-smoke-e2e ✅ success

@cv

cv commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

Addressing PR Review Advisor warnings PRA-1/PRA-2:

  • Invalid state/source boundary: Ubuntu /bin/sh is dash, and the rlimit profile hook can be sourced during openshell sandbox exec ... sh -lc .... Dash supports ulimit -n but not ulimit -u, so treating unsupported nproc as drift caused false security diagnostics before user commands ran.
  • Source-fix constraint: the hook must remain safe for POSIX-sh profile sourcing; requiring bash for all sandbox exec ... sh -lc probes would change the caller-selected shell path and reintroduce noise for POSIX shell invocations.
  • Regression coverage added in this PR: test/sandbox-rlimit-hooks.test.ts now covers POSIX-sh sourcing, supported nofile lowering, negative nofile verification, and a simulated unsupported -Su/-Hu path that proves skipped nproc does not mask supported nofile enforcement/failure.
  • Accepted compatibility boundary: unsupported nproc is fail-open only for shells where the flag cannot be queried/enforced; supported limits continue to be set and verified independently. The in-code comment documents the removal condition: remove/escalate this path once OpenShell guarantees profile hooks run under a shell with nproc support, or if a supported limit such as nofile becomes unsupported.

Given the above, I believe the remaining PRA items are justified by the code comment plus regression tests.

@cv
cv merged commit 06485be into main Jun 26, 2026
40 checks passed
@cv
cv deleted the fix/posix-sh-sandbox-rlimits branch June 26, 2026 15:06
@wscurran wscurran added area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression labels Jun 26, 2026
@cv cv added the v0.0.69 label Jun 27, 2026
Hadar301 pushed a commit to Hadar301/NemoClaw-OpenShift that referenced this pull request Jul 12, 2026
<!-- markdownlint-disable MD041 -->
## Summary
Make the shared sandbox rlimit helper safe to source from POSIX
`/bin/sh` profile hooks. This prevents `openshell sandbox exec ... sh
-lc ...` probes from emitting bash-only `builtin ulimit` warnings while
preserving the shadowed-`ulimit` bypass in bash.

## Changes
- Switch `scripts/lib/sandbox-rlimits.sh` from bash-only `builtin
ulimit` calls to a POSIX-safe `command ulimit` wrapper.
- Skip verification for resource-limit flags unsupported by the active
shell, such as `ulimit -u` under dash, instead of reporting `unknown`
limits.
- Add a POSIX-sh regression test and update shadowed-`ulimit` tests to
cover the new helper behavior.

## 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
<!-- Check all that apply. For any "covered by existing tests", "not
applicable", or waiver entry, add a brief justification on the same line
or in the Changes section. -->
- [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: internal sandbox
rlimit/profile-hook compatibility fix; no user-facing command or
configuration change.
- [x] Sensitive paths changed (security, policy, credentials, preflight,
onboarding, inference, runner, sandbox, or messaging)
- [x] Sensitive-path review completed or maintainer-approved waiver
recorded — reviewer/approval link/justification: author self-review;
change is limited to the sandbox rlimit helper, keeps the
shadowed-`ulimit` hardening test, and passes shellcheck/prek plus
targeted tests.
- [ ] Non-success, skipped, or missing CI check accepted by maintainer —
check name, approval link, and follow-up issue:

## Verification
<!-- Check each item you ran and confirmed. Leave unchecked items you
skipped. Doc-only changes do not require npm test unless you ran it. -->
- [x] PR description includes the DCO sign-off declaration and every
commit appears as `Verified` in GitHub
- [x] Git hooks passed during commit and push, or `npx prek run
--from-ref main --to-ref HEAD` passes
- [x] Targeted tests pass for changed behavior
- [ ] Full `npm test` passes (broad runtime changes only)
- [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)

---
<!-- DCO sign-off is required in this PR description, and every commit
must appear as Verified in GitHub. Run: git config user.name && git
config user.email -->
Signed-off-by: Carlos Villela <cvillela@nvidia.com>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved resource-limit hardening and verification for POSIX `sh`,
especially when `ulimit` is shadowed by shell functions.
* Resource-limit checks now detect supported `ulimit` flags and validate
effective numeric limits more reliably, reducing incorrect verification
failures.
* **Tests**
* Expanded POSIX `sh` test coverage for rlimit hooks and sandbox
hardening, including bypassing shadowed `ulimit`.
* Added/adjusted scenarios to confirm unsafe or unbounded `nofile`
targets are rejected.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants