Skip to content

fix(policy): restrict npm and PyPI presets to GET-only REST rules - #1672

Merged
cv merged 1 commit into
NVIDIA:mainfrom
Dongni-Yang:fix/npm-pypi-restrict-access-1439
Apr 9, 2026
Merged

fix(policy): restrict npm and PyPI presets to GET-only REST rules#1672
cv merged 1 commit into
NVIDIA:mainfrom
Dongni-Yang:fix/npm-pypi-restrict-access-1439

Conversation

@Dongni-Yang

@Dongni-Yang Dongni-Yang commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace access: full (raw CONNECT tunnel) with protocol: rest + read-only rules in presets/npm.yaml and presets/pypi.yaml
  • Prevents package publishing (npm publish, pip upload) and data exfiltration through registry endpoints
  • npm: GET-only (sufficient for npm install)
  • PyPI: GET + HEAD (pip/uv use HEAD for lazy-wheel metadata checks)
  • Updates test assertions to match new expected policy shape

Closes #1439

Affected files

  • nemoclaw-blueprint/policies/presets/npm.yamlregistry.npmjs.org, registry.yarnpkg.com
  • nemoclaw-blueprint/policies/presets/pypi.yamlpypi.org, files.pythonhosted.org
  • test/policies.test.js — updated assertions + new test for pypi HEAD

Issue checklist

Issue item Status Notes
presets/npm.yaml uses access: full Fixed Replaced with protocol: rest + GET-only
presets/pypi.yaml uses access: full Fixed Replaced with protocol: rest + GET + HEAD
openclaw-sandbox.yaml lines 131-137 N/A GitHub policies — access: full is intentional for git push/clone
openclaw-sandbox.yaml lines 163-166 N/A binaries: entries for clawhub — not related to npm/pypi
openclaw-sandbox.yaml npm entry (lines 194-209) Already fixed Uses protocol: rest + GET-only in main
Explicit deny rules (recommended fix) Not needed With protocol: rest + allow-list, everything not allowed is implicitly denied — matches huggingface.yaml pattern

Why PyPI needs HEAD

pip install and uv pip install use HEAD requests for lazy-wheel downloads and range-request support (checking Accept-Ranges: bytes before partial downloads). GET-only would degrade pip to full-file downloads. HEAD is read-only and poses no security risk.

Reproduction verification

# access: full is gone from both presets
$ grep 'access: full' presets/npm.yaml presets/pypi.yaml
(no matches)

# protocol: rest present on all 4 endpoints
$ grep -c 'protocol: rest' presets/npm.yaml → 2
$ grep -c 'protocol: rest' presets/pypi.yaml → 2

# Only safe read methods allowed
$ grep -cE 'method: (PUT|POST|DELETE)' presets/npm.yaml → 0
$ grep -cE 'method: (PUT|POST|DELETE)' presets/pypi.yaml → 0

Test plan

  • npx vitest run test/policies.test.js — all 60 tests pass
  • Verify npm install works inside sandbox with updated npm preset
  • Verify pip install works inside sandbox with updated pypi preset
  • Verify npm publish / pip upload is blocked inside sandbox

Signed-off-by: Dongni Yang dongniy@nvidia.com

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Replaced permissive access: full for npm and PyPI presets with explicit REST policies enforcing TLS termination and allowing only safe HTTP methods (GET, and HEAD for PyPI). Tests updated to validate the new protocol- and method-specific rules.

Changes

Cohort / File(s) Summary
Package Registry Presets
nemoclaw-blueprint/policies/presets/npm.yaml, nemoclaw-blueprint/policies/presets/pypi.yaml
Replaced access: full with protocol: rest, enforcement: enforce, tls: terminate. Added allow rules restricting methods to GET (and HEAD for PyPI) for all paths (path: "/**"). binaries lists unchanged.
Policy Tests
test/policies.test.js
Updated assertions: ensure access: full is absent; require protocol: rest; assert method: GET present for npm/pypi presets and method: HEAD present for pypi; added negative checks that PUT/POST/DELETE are not allowed.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Client
  participant Proxy as OpenShell Proxy\n(Policy Engine)
  participant Registry as Registry\n(npm / PyPI)

  Client->>Proxy: HTTPS request (method: GET/HEAD/POST/PUT/DELETE)
  Proxy->>Proxy: TLS terminate\nInspect HTTP method & path
  alt method is GET or (HEAD for PyPI)
    Proxy->>Registry: Forward request over HTTPS
    Registry-->>Proxy: Response
    Proxy-->>Client: Forward response
  else disallowed method (POST/PUT/DELETE/etc.)
    Proxy-->>Client: Deny / Reset connection
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through config, sharp and spry,
Swapped tunnels wide for careful sky.
GETs and HEADs now pass the gate,
No secret posts to complicate.
Carrots safe — the policy's right! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: replacing access:full with GET-only REST rules for npm and PyPI presets.
Linked Issues check ✅ Passed The PR fully addresses issue #1439 by replacing access:full with protocol:rest and GET-only rules for all affected npm/PyPI endpoints and updating corresponding tests.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objectives: npm.yaml, pypi.yaml presets, and policies.test.js assertions directly supporting issue #1439 resolution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

…VIDIA#1439)

Replace access: full (raw CONNECT tunnel) with protocol: rest and
read-only rules on npm/PyPI presets to prevent package publishing and
data exfiltration through registry endpoints.

npm: GET-only (sufficient for npm install).
PyPI: GET + HEAD (pip/uv use HEAD for lazy-wheel metadata checks).

Signed-off-by: Dongni Yang <dongniy@nvidia.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Dongni-Yang
Dongni-Yang force-pushed the fix/npm-pypi-restrict-access-1439 branch from e22aec9 to fe67704 Compare April 9, 2026 05:50
@cv
cv merged commit a7cafd0 into NVIDIA:main Apr 9, 2026
13 checks passed
miyoungc added a commit that referenced this pull request Apr 10, 2026
…1719)

## Summary
- Remove `github` and `github_rest_api` from baseline network policy
docs (now opt-in preset, #1660)
- Add `github` preset to presets tables in customize-network-policy.md
and best-practices.md
- Add `brave` and `brew` presets to best-practices.md
- Update `huggingface` description (download-only + inference router,
#1663)
- Update `npm` and `pypi` descriptions (GET-only, publishing blocked,
#1672)
- Fix binary-scoping example to reference `github` as a preset, not
baseline
- Add `docs/.docs-skip` exclusion file for suppressing docs on
experimental/unreleased features
- Update `nemoclaw-contributor-update-docs` skill with skip-features,
skip-terms, and agent matrix filtering rules
- Regenerate `nemoclaw-user-*` skills from updated docs

## Test plan
- [x] `make docs` builds without warnings
- [x] All pre-commit and pre-push hooks pass
- [x] Skip-term scan passes (zero violations in branch diff)
- [ ] Verify rendered pages in docs site preview

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

## Summary by CodeRabbit

* **New Features**
* Introduced skip-list configuration for controlling documentation
generation based on commit patterns and excluded terminology.

* **Documentation**
* Updated network policy presets with new `github`, `brave`, and `brew`
options.
* Refined preset descriptions for `huggingface`, `npm`, and `pypi` to
clarify access scopes.
* Clarified that GitHub access is no longer baseline and requires
applying the `github` preset during onboarding.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ericksoa pushed a commit to cheese-head/NemoClaw that referenced this pull request Apr 14, 2026
…VIDIA#1719)

## Summary
- Remove `github` and `github_rest_api` from baseline network policy
docs (now opt-in preset, NVIDIA#1660)
- Add `github` preset to presets tables in customize-network-policy.md
and best-practices.md
- Add `brave` and `brew` presets to best-practices.md
- Update `huggingface` description (download-only + inference router,
NVIDIA#1663)
- Update `npm` and `pypi` descriptions (GET-only, publishing blocked,
NVIDIA#1672)
- Fix binary-scoping example to reference `github` as a preset, not
baseline
- Add `docs/.docs-skip` exclusion file for suppressing docs on
experimental/unreleased features
- Update `nemoclaw-contributor-update-docs` skill with skip-features,
skip-terms, and agent matrix filtering rules
- Regenerate `nemoclaw-user-*` skills from updated docs

## Test plan
- [x] `make docs` builds without warnings
- [x] All pre-commit and pre-push hooks pass
- [x] Skip-term scan passes (zero violations in branch diff)
- [ ] Verify rendered pages in docs site preview

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

## Summary by CodeRabbit

* **New Features**
* Introduced skip-list configuration for controlling documentation
generation based on commit patterns and excluded terminology.

* **Documentation**
* Updated network policy presets with new `github`, `brave`, and `brew`
options.
* Refined preset descriptions for `huggingface`, `npm`, and `pypi` to
clarify access scopes.
* Clarified that GitHub access is no longer baseline and requires
applying the `github` preset during onboarding.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
…IDIA#1672)

## Summary
- Replace `access: full` (raw CONNECT tunnel) with `protocol: rest` +
read-only rules in `presets/npm.yaml` and `presets/pypi.yaml`
- Prevents package publishing (`npm publish`, `pip upload`) and data
exfiltration through registry endpoints
- npm: GET-only (sufficient for `npm install`)
- PyPI: GET + HEAD (`pip`/`uv` use HEAD for lazy-wheel metadata checks)
- Updates test assertions to match new expected policy shape

Closes NVIDIA#1439

## Affected files
- `nemoclaw-blueprint/policies/presets/npm.yaml` — `registry.npmjs.org`,
`registry.yarnpkg.com`
- `nemoclaw-blueprint/policies/presets/pypi.yaml` — `pypi.org`,
`files.pythonhosted.org`
- `test/policies.test.js` — updated assertions + new test for pypi HEAD

## Issue checklist

| Issue item | Status | Notes |
|---|---|---|
| `presets/npm.yaml` uses `access: full` | Fixed | Replaced with
`protocol: rest` + GET-only |
| `presets/pypi.yaml` uses `access: full` | Fixed | Replaced with
`protocol: rest` + GET + HEAD |
| `openclaw-sandbox.yaml` lines 131-137 | N/A | GitHub policies —
`access: full` is intentional for git push/clone |
| `openclaw-sandbox.yaml` lines 163-166 | N/A | `binaries:` entries for
clawhub — not related to npm/pypi |
| `openclaw-sandbox.yaml` npm entry (lines 194-209) | Already fixed |
Uses `protocol: rest` + GET-only in main |
| Explicit `deny` rules (recommended fix) | Not needed | With `protocol:
rest` + allow-list, everything not allowed is implicitly denied —
matches `huggingface.yaml` pattern |

## Why PyPI needs HEAD

`pip install` and `uv pip install` use HEAD requests for lazy-wheel
downloads and range-request support (checking `Accept-Ranges: bytes`
before partial downloads). GET-only would degrade pip to full-file
downloads. HEAD is read-only and poses no security risk.

## Reproduction verification

```
# access: full is gone from both presets
$ grep 'access: full' presets/npm.yaml presets/pypi.yaml
(no matches)

# protocol: rest present on all 4 endpoints
$ grep -c 'protocol: rest' presets/npm.yaml → 2
$ grep -c 'protocol: rest' presets/pypi.yaml → 2

# Only safe read methods allowed
$ grep -cE 'method: (PUT|POST|DELETE)' presets/npm.yaml → 0
$ grep -cE 'method: (PUT|POST|DELETE)' presets/pypi.yaml → 0
```

## Test plan
- [x] `npx vitest run test/policies.test.js` — all 60 tests pass
- [ ] Verify `npm install` works inside sandbox with updated npm preset
- [ ] Verify `pip install` works inside sandbox with updated pypi preset
- [ ] Verify `npm publish` / `pip upload` is blocked inside sandbox

Signed-off-by: Dongni Yang <dongniy@nvidia.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Dongni Yang <dongniy@nvidia.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
…VIDIA#1719)

## Summary
- Remove `github` and `github_rest_api` from baseline network policy
docs (now opt-in preset, NVIDIA#1660)
- Add `github` preset to presets tables in customize-network-policy.md
and best-practices.md
- Add `brave` and `brew` presets to best-practices.md
- Update `huggingface` description (download-only + inference router,
NVIDIA#1663)
- Update `npm` and `pypi` descriptions (GET-only, publishing blocked,
NVIDIA#1672)
- Fix binary-scoping example to reference `github` as a preset, not
baseline
- Add `docs/.docs-skip` exclusion file for suppressing docs on
experimental/unreleased features
- Update `nemoclaw-contributor-update-docs` skill with skip-features,
skip-terms, and agent matrix filtering rules
- Regenerate `nemoclaw-user-*` skills from updated docs

## Test plan
- [x] `make docs` builds without warnings
- [x] All pre-commit and pre-push hooks pass
- [x] Skip-term scan passes (zero violations in branch diff)
- [ ] Verify rendered pages in docs site preview

🤖 Generated with [Claude Code](https://claude.com/claude-code)

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

## Summary by CodeRabbit

* **New Features**
* Introduced skip-list configuration for controlling documentation
generation based on commit patterns and excluded terminology.

* **Documentation**
* Updated network policy presets with new `github`, `brave`, and `brew`
options.
* Refined preset descriptions for `huggingface`, `npm`, and `pypi` to
clarify access scopes.
* Clarified that GitHub access is no longer baseline and requires
applying the `github` preset during onboarding.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

npm Registry and PyPI Policies Use access:full — Bypass HTTP Inspection - IssueFinder - SN 15

3 participants