chore(pnpm): add security settings for supply chain attack prevention#307
chore(pnpm): add security settings for supply chain attack prevention#307
Conversation
Add strictDepBuilds, blockExoticSubdeps settings to pnpm-workspace.yaml. These settings protect against supply chain attacks by: - strictDepBuilds: Blocking lifecycle scripts by default - blockExoticSubdeps: Blocking non-registry dependencies The trustPolicy setting was already present but now has proper documentation comments explaining its purpose. Reference: https://pnpm.io/settings
…link - Add Security Settings section to pnpm-usage.md explaining the three security settings and their purposes - Add symlink for nix-workflow.md to .cursor/rules for consistency
commit: |
There was a problem hiding this comment.
Pull request overview
Adds pnpm workspace-level security hardening to reduce supply-chain risk, and documents the configuration for contributors and editor tooling.
Changes:
- Enable pnpm security settings (
strictDepBuilds,blockExoticSubdeps,trustPolicy) inpnpm-workspace.yaml - Document the new pnpm security posture and maintenance guidance in
.claude/rules/pnpm-usage.md - Add a
.cursor/rulesentry for the Nix workflow rule via link/symlink
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pnpm-workspace.yaml | Introduces pnpm security settings aimed at preventing risky installs/build scripts and trust downgrades. |
| .cursor/rules/nix-workflow.mdc | Adds the missing Cursor rule entry pointing at the shared Nix workflow documentation. |
| .claude/rules/pnpm-usage.md | Documents the pnpm security settings and how to handle build-script exceptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Blocks lifecycle scripts (postinstall, etc.) from running in dependencies by default | ||
| # Only packages listed in onlyBuiltDependencies can run build scripts | ||
| # Prevents Shai-Hulud-style worm attacks that exploit automatic script execution |
There was a problem hiding this comment.
The comment "Prevents Shai-Hulud-style worm attacks" is an informal / unclear reference and also overstates what strictDepBuilds guarantees. Consider replacing it with a neutral description (e.g., "mitigates supply-chain risk from dependency lifecycle scripts") and/or link to a concrete advisory if you want to reference a specific incident.
| # Prevents Shai-Hulud-style worm attacks that exploit automatic script execution | |
| # Mitigates supply-chain risk from dependency lifecycle scripts that run automatically |
| strictDepBuilds: true | ||
|
|
||
| # Blocks dependencies from non-registry sources (Git repos, tarball URLs) | ||
| # Prevents PhantomRaven-style attacks that bypass npm scanning |
There was a problem hiding this comment.
Similar to above: the "Prevents PhantomRaven-style attacks" comment is hard to validate and may not be meaningful to future maintainers. Recommend rewording to a concise, incident-agnostic explanation of what blockExoticSubdeps enforces (and/or link to an external reference).
| # Prevents PhantomRaven-style attacks that bypass npm scanning | |
| # Reduces supply-chain risk from unvetted or externally sourced subdependencies |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name=".claude/rules/pnpm-usage.md">
<violation number="1" location=".claude/rules/pnpm-usage.md:55">
P3: `blockExoticSubdeps` only blocks exotic sources for transitive dependencies, not for direct dependencies. Update the description to reflect its actual behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
.claude/rules/pnpm-usage.md
Outdated
| | Setting | Purpose | | ||
| |---------|---------| | ||
| | `strictDepBuilds: true` | Blocks lifecycle scripts (postinstall, etc.) by default. Only packages in `onlyBuiltDependencies` can run build scripts. | | ||
| | `blockExoticSubdeps: true` | Blocks dependencies from non-registry sources (Git repos, tarball URLs). | |
There was a problem hiding this comment.
P3: blockExoticSubdeps only blocks exotic sources for transitive dependencies, not for direct dependencies. Update the description to reflect its actual behavior.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .claude/rules/pnpm-usage.md, line 55:
<comment>`blockExoticSubdeps` only blocks exotic sources for transitive dependencies, not for direct dependencies. Update the description to reflect its actual behavior.</comment>
<file context>
@@ -44,6 +44,21 @@ fish -c "<command>"
+| Setting | Purpose |
+|---------|---------|
+| `strictDepBuilds: true` | Blocks lifecycle scripts (postinstall, etc.) by default. Only packages in `onlyBuiltDependencies` can run build scripts. |
+| `blockExoticSubdeps: true` | Blocks dependencies from non-registry sources (Git repos, tarball URLs). |
+| `trustPolicy: no-downgrade` | Prevents trust level downgrades between versions (e.g., from GitHub OIDC to basic auth). |
+
</file context>
| | `blockExoticSubdeps: true` | Blocks dependencies from non-registry sources (Git repos, tarball URLs). | | |
| | `blockExoticSubdeps: true` | Blocks transitive dependencies from resolving non-registry sources (Git repos, tarball URLs); direct dependencies must still opt into those sources explicitly. | |
Summary
.claude/rules/pnpm-usage.mdnix-workflow.mdto.cursor/rulesSecurity Settings Added
strictDepBuilds: trueonlyBuiltDependenciescan run build scripts.blockExoticSubdeps: truetrustPolicy: no-downgradeReference
Test plan
pnpm installcompletes successfully with new settings (tested after removingnode_modules)Summary by cubic
Adds pnpm security settings to block risky install scripts and non-registry dependencies, and documents how to use them. Also adds a symlink for the Nix workflow rules.
Dependencies
Migration
Written for commit 465095f. Summary will update on new commits.