Skip to content

chore(pnpm): add security settings for supply chain attack prevention#307

Merged
ryoppippi merged 3 commits intomainfrom
chore/add-pnpm-security-settings
Jan 27, 2026
Merged

chore(pnpm): add security settings for supply chain attack prevention#307
ryoppippi merged 3 commits intomainfrom
chore/add-pnpm-security-settings

Conversation

@ryoppippi
Copy link
Copy Markdown
Contributor

@ryoppippi ryoppippi commented Jan 27, 2026

Summary

  • Add pnpm security settings to protect against supply chain attacks
  • Document the security settings in .claude/rules/pnpm-usage.md
  • Add missing symlink for nix-workflow.md to .cursor/rules

Security Settings Added

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).

Reference

Test plan

  • pnpm install completes successfully with new settings (tested after removing node_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

    • strictDepBuilds: blocks lifecycle scripts by default; whitelist via onlyBuiltDependencies.
    • blockExoticSubdeps: blocks Git/tarball subdependencies.
    • trustPolicy: no-downgrade, now documented.
  • Migration

    • No action needed; pnpm install works as usual.
    • If a dependency needs build scripts, add it to onlyBuiltDependencies.

Written for commit 465095f. Summary will update on new commits.

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
@ryoppippi ryoppippi requested a review from a team as a code owner January 27, 2026 17:56
Copilot AI review requested due to automatic review settings January 27, 2026 17:56
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Jan 27, 2026

Open in StackBlitz

npm i https://pkg.pr.new/StackOneHQ/stackone-ai-node/@stackone/ai@307

commit: 465095f

@ryoppippi ryoppippi merged commit 54cfe5d into main Jan 27, 2026
17 checks passed
@ryoppippi ryoppippi deleted the chore/add-pnpm-security-settings branch January 27, 2026 17:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) in pnpm-workspace.yaml
  • Document the new pnpm security posture and maintenance guidance in .claude/rules/pnpm-usage.md
  • Add a .cursor/rules entry 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
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
# Prevents Shai-Hulud-style worm attacks that exploit automatic script execution
# Mitigates supply-chain risk from dependency lifecycle scripts that run automatically

Copilot uses AI. Check for mistakes.
strictDepBuilds: true

# Blocks dependencies from non-registry sources (Git repos, tarball URLs)
# Prevents PhantomRaven-style attacks that bypass npm scanning
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
# Prevents PhantomRaven-style attacks that bypass npm scanning
# Reduces supply-chain risk from unvetted or externally sourced subdependencies

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

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.

| 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). |
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 27, 2026

Choose a reason for hiding this comment

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

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>
Suggested change
| `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. |
Fix with Cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants