fix: patch lerna's tar interop bug, fixing GHSA-r292-9mhp-454m - #9546
Closed
manojkumar138 wants to merge 1 commit into
Closed
fix: patch lerna's tar interop bug, fixing GHSA-r292-9mhp-454m#9546manojkumar138 wants to merge 1 commit into
manojkumar138 wants to merge 1 commit into
Conversation
CECHO-1941 PR #9542 bumped tar to 7.5.21 to fix GHSA-r292-9mhp-454m (CVSS 7.5 stack-overflow DoS), claiming it was verified safe for lerna's packDirectory usage. That verification was incomplete and the bump broke the real publish pipeline once merged: lerna ERR! TypeError: Cannot read properties of undefined (reading 'create') at packDirectory (node_modules/lerna/dist/index.js:6429:39) Root cause: lerna's bundled code does esbuild's __toESM(require('tar')) interop wrapper, then calls .default.create() /.default.list(). tar 7.5.21's CJS build sets __esModule: true but has no actual .default export (only named exports like create/list). esbuild's __toESM only synthesizes a .default fallback when !mod.__esModule -- since tar 7.5.21 sets that flag, __toESM leaves .default unset, so it's undefined at runtime. Reproduced lerna's exact __toESM logic in isolation to confirm this precisely, rather than just re-testing bump-and-hope. Instead of excluding the CVE, this patches the actual bug via patch-package: both call sites in lerna's dist/index.js become (import_tar.default || import_tar).list(...) and (import_tar2.default || import_tar2).create(...), falling back to the raw module when .default isn't populated. Verified against a byte-for-byte reproduction of lerna's __toESM helper that .default is undefined before the patch and that both .list/.create resolve correctly after it. Ticket: CECHO-1941
manojkumar138
force-pushed
the
manojkumar138/revert-tar-bump-exclude-ghsa-r292
branch
from
August 24, 2026 13:25
8b4653e to
9ef5e95
Compare
manojkumar138
marked this pull request as ready for review
August 25, 2026 04:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
PR #9542 bumped
tarto 7.5.21 to fix GHSA-r292-9mhp-454m (CVSS 7.5 stack-overflow DoS), claiming it was verified safe for lerna'spackDirectoryusage. That verification was incomplete, and the bump broke the real publish pipeline once merged:(failing run)
Root cause: lerna's bundled code does esbuild's
__toESM(require('tar'))interop wrapper, then calls.default.create()/.default.list(). tar 7.5.21's CJS build sets__esModule: truebut has no actual.defaultexport (only named exports likecreate/list). esbuild's__toESMonly synthesizes a.defaultfallback when!mod.__esModule— since tar 7.5.21 sets that flag,__toESMleaves.defaultunset, so it'sundefinedat runtime. I reproduced lerna's exact__toESMlogic in isolation to confirm this precisely, rather than just re-testing bump-and-hope like last time.Fix: instead of excluding the CVE (which was my first fallback plan — see comment history), this patches the actual bug via
patch-package. Both call sites in lerna'sdist/index.jsbecome(import_tar.default || import_tar).list(...)and(import_tar2.default || import_tar2).create(...), falling back to the raw module when.defaultisn't populated. Verified against a byte-for-byte reproduction of lerna's__toESMhelper that.defaultisundefinedbefore the patch and that both.list/.createresolve correctly after it.This lets us actually take the tar 7.5.21 security fix rather than suppressing the finding.
Ticket
CECHO-1941 (used per request for commit/branch tracking; unrelated to the actual token-onboarding content of that ticket — this is a CI/dependency fix)
Test plan
patch-packageapplies cleanly on freshyarn install__toESMinterop logic standalone — confirmed bug before patch, confirmed fix after