GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — [APS-19009] security(cli): --ignore-scripts + validate npm_dependencies (lifecycle-script RCE) by Rohannagariya1 · Pull Request #1172 · browserstack/browserstack-cypress-cli Conversation
Collaborator
Issue (APS-19009, Critical)
Fix (minimal)
Testing
Refs: APS-19009 (INJ-007 / INF-006)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…proxy Ships the low-blast-radius subset of the CLI critical findings. APS-19010 — env-var API redirect: only honour BSTACK_CYPRESS_NODE_ENV url overrides (RAILS_HOST/UPLOAD_URL/DASHBOARD_URL/USAGE_REPORTING_URL) when they point at *.browserstack.com / *.bsstag.com / localhost; otherwise warn and fall back to the production defaults. APS-19011 — validate the API-supplied upload_url host before using it for the tests.zip upload; warn (do NOT cert-pin) when an HTTP(S) proxy routes all API traffic incl. credentials; structural-only JWT check on the TestHub token (defence-in-depth — the CLI has no key to verify the signature). APS-19008 (browserstack.json half) — read browserstack.json via JSON.parse(fs.readFileSync) instead of require() so a .js config cannot execute arbitrary code; require a .json extension and project-root path containment. New bin/helpers/securityValidation.js (stdlib-only): isAllowedBrowserstackUrl, isPathInsideBase, isWellFormedJwt, covered by test/unit/.../securityValidation.js (13 tests, both paths). Deliberately NOT changed (accepted-risk / opt-in — needs product decision): - cypress.config.js is legitimately JS that imports plugins; NOT sandboxed by default (a vm sandbox breaks real configs). APS-19008 cypress-config half. - npm_dependencies install still runs lifecycle scripts (APS-19009): NOT fixed here. Note: PR #1128's repo .npmrc (ignore-scripts=true) does NOT protect end users — packageInstaller copies the *user's* .npmrc into the temp install dir, not the CLI's. APS-19009's real fix (--ignore-scripts + package-name/version validation + shell:false) remains OPEN. Co-Authored-By: Claude Opus 4.8 <[email protected]> …es names/versions browserstack.json's npm_dependencies were merged into a temp package.json and installed with `npm install` and no `--ignore-scripts`, so a PR-supplied malicious package's lifecycle script (postinstall) executed on CI (RCE, credential theft). - Add `--ignore-scripts` to both npm install invocations (the RCE fix). npm_dependencies is documented pure-JS only. - Validate each dependency name (standard npm package-name regex) and version (semver/dist-tag charset only) before writing package.json, rejecting git-url / file: / path / alternate-registry specs (dependency confusion / code-exec via spec). - shell:true is retained deliberately: the command line is fully static (names live in package.json data, never on the command line -> no injection surface) and it is required for the output redirection and for invoking npm.cmd on Windows. Tested: validation rejects shell-metachar/git-url/file/$() specs, accepts normal semver; --ignore-scripts present in both installs; syntax clean. Co-Authored-By: Claude Opus 4.8 <[email protected]> Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page. Uh oh!
There was an error while loading. Please reload this page.
…ndencies Locks the two security invariants the fix introduces: - packageInstall passes --ignore-scripts to the npm spawn (lifecycle-script RCE guard) - setupPackageFolder rejects a non-semver/git-url npm_dependencies version and never writes package.json (dependency-confusion / spec smuggling guard) Co-Authored-By: Claude Opus 4.8 <[email protected]> - Add justified nosemgrep for spawn-shell-true on both npm-install spawns (static argv, shell needed only for '>' redirect + npm.cmd on Windows). - Sync securityValidation.js/utils.js with the path-join nosemgrep suppressions from the #1141 branch so the (false-positive) path-traversal findings clear. - NPM_NAME_RE: allow A-Z so legacy registry names (e.g. JSONStream) are not rejected; still blocks git-url/file:/path/alternate-registry specs. Test added. Co-Authored-By: Claude Opus 4.8 <[email protected]> …st fix) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ng honors same-line) Co-Authored-By: Claude Opus 4.8 <[email protected]> …npm-deps-hardening …me-install fallback (APS-19009) The npm_dependencies validation added for APS-19009 was being caught by packageSetupAndInstaller's generic install-error catch and downgraded to the "dependencies will be installed in runtime" fallback. As a result a malicious or invalid dependency spec (git-url, file:, path, alternate-registry) was never actually blocked — the run proceeded, tests were uploaded, and the bad dep was deferred to the runtime install path. Mark the validation error (isNpmDependencyValidationError) and re-reject it from packageSetupAndInstaller so runs.js aborts before upload with a clear error and a non-zero exit code. Genuine install failures (network, registry, peer-deps) still fall back to runtime install unchanged, so the legitimate flow is untouched. Adds a regression test asserting packageSetupAndInstaller rejects (does not resolve) on a validation error. Verified live via `browserstack-cypress run`: malicious dep -> exit 1, no build created; valid deps (incl. scoped + legacy upper-case names) -> build created with --ignore-scripts. Co-Authored-By: Claude Opus 4.8 <[email protected]> …ep --ignore-scripts (APS-19009) The prior commit (8441042) hard-aborted a run whenever an npm_dependencies spec failed a strict name+version regex. BigQuery analysis of 221,133 real cypress-cli builds over 90 days showed this would abort 7,446 builds (3.4%): - 6,914 BrowserStack's OWN Cypress SDK CI (installs the CLI from its git branches, e.g. [email protected]/browserstack...#master) - 405 real enterprise customers using legitimate non-registry specs (private Artifactory tarball URLs, file: vendored modules) - 127 actual attack/CTF payloads (the only ones we want to block) i.e. ~57 legitimate builds broken per attack caught. The documented RCE (lifecycle-script execution) is already fully closed by --ignore-scripts for EVERY spec, so the hard abort added large blast radius for no real security gain. Changes: - Keep --ignore-scripts (the actual RCE remediation) unchanged. - Drop version-spec validation entirely: git / file: / tarball-url / private-registry versions are legitimate and must run. - Validate only the package NAME; an invalid name (shell-metacharacter / command-injection payload) is SKIPPED with a warning, and the session continues with the remaining valid deps -- never a hard abort. - Revert runs.js abort/try-catch; packageSetupAndInstaller no longer rejects. - Tests updated: allow git-url spec, skip bad name without aborting, and assert packageSetupAndInstaller resolves (never blocks a session). 22/22. Co-Authored-By: Claude Opus 4.8 <[email protected]> …npm-deps-hardening Co-Authored-By: Claude Opus 4.8 <[email protected]>
Collaborator
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. …npm-deps-hardening
Rohannagariya1
commented
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Claude Code Review (automated) — 1 inline finding(s). Full report in the PR comment below. Verdict: Passed.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Low] PR description overstates version-spec validation The PR body says the fix validates version specs and rejects Suggestion: No code change needed. Update the PR body to match the code: package names are validated; version specs are deliberately left unvalidated because git/file/tarball specs are legitimate and RCE is closed by Reviewer: stack:code-review
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Raghav11-11
approved these changes
Raghav11-11
self-requested a review
karanshah-browserstack
requested changes
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already set internally why do we need this?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we codeowners for this?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need logger?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High blast radius. What are we doing here?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewers+1 more reviewerRequested changes must be addressed to merge this pull request. Uh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Uh oh!
There was an error while loading. Please reload this page. Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |