npx Used Confusion and It’s Super Effective#2271
Open
carlospolop wants to merge 1 commit into
Open
Conversation
Collaborator
Author
🔗 Additional ContextOriginal Blog Post: https://www.landh.tech//blog/20260521-npx-used-confusion-and-its-super-effective Content Categories: Based on the analysis, this content was categorized under "Pentesting Web > Dependency Confusion, as a subsection for npm/npx binary-package name confusion / npx command resolution abuse". Repository Maintenance:
Review Notes:
Bot Version: HackTricks News Bot v1.0 |
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.
🤖 Automated Content Update
This PR was automatically generated by the HackTricks News Bot based on a technical blog post.
📝 Source Information
🎯 Content Summary
Overview
The post introduces npx Confusion, a supply-chain execution technique against the npm/npx ecosystem. It is related to dependency confusion, but it does not rely on the classic private-registry-vs-public-registry precedence problem. Instead, it abuses the way
npxresolves a command name when the command is not found locally, globally, or in the npx cache.npx, embedded in npm, is designed to execute binaries from npm packages. If a...🔧 Technical Details
npx binary/package-name confusion: When
npx <name>is executed without an explicit--packageflag, npm first searches for<name>as a binary in localnode_modules/.bin, global bin paths, installed package trees, and the npx cache. If it cannot resolve the binary, npm pushesargs[0]into the package list withpackages.push(args[0]). That turns the original binary name into a package spec. If the package is missing from local/global/cache trees, npm fetches it from the public registry, installs it into~/.npm/_npx/<hash>, prepends the cachednode_modules/.bindirectory toPATH, and executes it. An attacker can exploit this by registering an unclaimed public npm package whose name matches a binary that developers or automation run through npx.Scoped-package binary-name takeover: Scoped npm packages such as
@company/package🤖 Agent ActionsUpdatedsrc/pentesting-web/dependency-confusion.md.Added a new subsection covering:
npxbinary/package-name confusionnode_modules/.bin, global bins, Arborist tree,~/.npm/_npx/, registry fallback)--package, avoiding barenpx <binary>in automation, and checking~/.npm/_npx/Also updated the file’s
## Referenceswith:npx/npm execdocsValidation:
## Referencessection preservedNote:
mdbook buildcould not be run becausemdbookis not installed in this environment.This PR was automatically created by the HackTricks Feed Bot. Please review the changes carefully before merging.