Skip to content

Commit 54cfe5d

Browse files
authored
chore(pnpm): add security settings for supply chain attack prevention (#307)
* chore(pnpm): add security settings for supply chain attack prevention 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 * docs(rules): document pnpm security settings and add nix-workflow symlink - 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 * chore: format pnpm-usage.md table
1 parent a400da8 commit 54cfe5d

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

.claude/rules/pnpm-usage.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ fish -c "<command>"
4444
2. **Binary not found**: Use `pnpm dlx` instead of `pnpm exec`
4545
3. **Permission errors**: Check node_modules permissions
4646

47+
## Security Settings
48+
49+
The project uses pnpm security settings to protect against supply chain attacks.
50+
These are configured in `pnpm-workspace.yaml`:
51+
52+
| Setting | Purpose |
53+
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
54+
| `strictDepBuilds: true` | Blocks lifecycle scripts (postinstall, etc.) by default. Only packages in `onlyBuiltDependencies` can run build scripts. |
55+
| `blockExoticSubdeps: true` | Blocks dependencies from non-registry sources (Git repos, tarball URLs). |
56+
| `trustPolicy: no-downgrade` | Prevents trust level downgrades between versions (e.g., from GitHub OIDC to basic auth). |
57+
58+
If a new dependency requires build scripts, add it to `onlyBuiltDependencies` in `pnpm-workspace.yaml`.
59+
60+
Reference: https://pnpm.io/settings
61+
4762
## Publishing & Deployment
4863

4964
When ready to release:

.cursor/rules/nix-workflow.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.claude/rules/nix-workflow.md

pnpm-workspace.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,20 @@ onlyBuiltDependencies:
5757

5858
shellEmulator: true
5959

60+
# Security settings (supply chain attack prevention)
61+
# See: https://pnpm.io/settings
62+
63+
# Blocks lifecycle scripts (postinstall, etc.) from running in dependencies by default
64+
# Only packages listed in onlyBuiltDependencies can run build scripts
65+
# Prevents Shai-Hulud-style worm attacks that exploit automatic script execution
66+
strictDepBuilds: true
67+
68+
# Blocks dependencies from non-registry sources (Git repos, tarball URLs)
69+
# Prevents PhantomRaven-style attacks that bypass npm scanning
70+
blockExoticSubdeps: true
71+
72+
# Prevents trust level downgrades between package versions
73+
# Blocks installations when publisher credentials downgrade from GitHub OIDC to basic auth
6074
trustPolicy: no-downgrade
6175

6276
trustPolicyExclude:

0 commit comments

Comments
 (0)