← Back to Pull requests

fix(executor): run scripts with an absolute /bin/sh by default #18606

Closed
unknown closed this pull request without merging on Dec 01, 2026 18:09 UTC
View on GitHub
unknown unknown commented on Dec 01, 2026 15:22 UTC
Author

Summary

Without a configured scriptShell, lifecycle and run scripts were started through a bare sh, and the spawn resolved it against the script's own PATH. That PATH starts with dependency .bin directories (the package's own, its ancestors', the privately hoisted one), so any installed package that ships a bin named sh received every script, including the builds of dependencies approved through allowBuilds.

The default is now /bin/sh (/system/bin/sh on Android). That is the shell Node.js's shell: true and npm's script-shell default use, so this matches the rest of the ecosystem. A configured scriptShell is unchanged, and so is Windows, which already uses ComSpec.

This is hardening. It does not try to stop a dependency's bins from shadowing other tools a script calls (node, make, ...). A package in the dependency graph is already trusted to run its code.

Tests: a lifecycle regression test plants an executable sh in node_modules/.bin and checks that the script runs without it. The test fails without the fix. Locally ran pnpm-executor and pnpm-deps-restorer (958 passed) and the lifecycle_scripts, doctor, exec, run, install_runtimes and dlx CLI modules (444 passed). Windows was not run locally.

Checklist

  • Added a changeset (pnpm changeset) if this PR changes any published

  • package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

  • Updated the documentation if needed.
  • 🤖 Generated with Claude Code

    ---
    Written by an agent (Claude Code, claude-opus-5-5).

    <!-- codesmith:footer -->
    ---
    <sup><a href="https://app.blacksmith.sh/pnpm/codesmith/pnpm/pr/18606?autoLogin=true&ref=codesmith_pr_footer">Open in [code]smith</a> · Need help on this PR? Tag <code>@codesmith-bot</code> with what you need.</sup>

    <!-- codesmith:autofix:disabled -->
    <!-- /codesmith:footer -->

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

    Summary by CodeRabbit

    Bug Fixes
    On non-Windows systems, lifecycle scripts now use the system shell by its absolute path by default: /bin/sh, or /system/bin/sh on Android. This prevents a dependency-provided sh executable from being selected instead. Windows shell behavior is unchanged.

    Documentation
    Updated script-shell guidance to specify the default shell on POSIX systems, Android, and Windows, including what is used when no shell is configured.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 326 lines (+244 / -82) across 4 files Reviewer: zkochan Review duration: 167m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 326 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.346
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #18606"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42% (MEDIUM) · Higher = larger blast radius
    42%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%
    Repository