Prerequisites
- Target system, dependencies and environment configured.
Usage
Purpose
Attackers publish malicious packages with names deliberately close to popular ones — reqeusts for requests, python3-dateutil for python-dateutil — betting on a typo or a copied-wrong name pulling their code into someone's build. Typosquatting (and related name-confusion attacks) are a constant, low-effort supply-chain threat. This skill covers detecting and preventing typosquatted and malicious lookalike packages entering your dependencies.
When to use it
Protecting the dependency intake for any project using public registries, and vetting new dependencies before adoption. It complements dependency confusion (same-name attacks) with the similar-name variant, and pairs with malicious-package response.
Procedure
- Understand the name-confusion variants an attacker uses:
- Typosquatting — a name one keystroke off a popular package (
reqeusts, loadsh).
- Combosquatting — adding a plausible word (
requests-oauth, python-requests).
- Namespace/manager confusion — a name from a different ecosystem, or a slightly different naming convention.
The bet is a typo, a mis-copied name, or a plausible-but-wrong assumption.
- Vet packages before adding them. When adopting a new dependency, verify you have the exact correct name and it's the genuine, popular package (check download counts, maintainer, repository, age). A brand-new package with a name close to a popular one and few downloads is a red flag.
- Detect malicious indicators in candidate packages. Malicious packages often have tells: install scripts that run code (npm
postinstall, pip setup.py executing on install), obfuscated code, network calls on install, or a name-vs-content mismatch. Tools like GuardDog and OSSF package analysis scan for these behaviours:# scan a package for malicious indicators (install scripts, obfuscation, exfil)
guarddog pypi scan <package>
- Use allowlisting for critical environments. For high-security builds, allowlist approved packages so an unvetted typosquat can't be installed at all — the strongest control, at the cost of flexibility.
- Pin and review dependencies. Lockfiles pin exact packages/versions (lockfile-integrity); review dependency additions in pull requests so a wrong or suspicious name gets caught by a human before it merges.
- Monitor for squats of your packages. If you publish packages, watch for typosquats of your names targeting your users, and report them for takedown.
- Report and remove malicious packages you find (the malicious-package-response skill) — reporting to the registry protects the whole community.
Cheatsheet
attack: malicious package with name CLOSE to a popular one -> typo/mis-copy pulls it in
reqeusts~requests | loadsh~lodash | python3-dateutil~python-dateutil
variants: TYPOsquat (keystroke off) | COMBOsquat (plausible extra word) | ecosystem confusion
defend
VET before adding: exact correct name? genuine popular pkg? (downloads, maintainer, repo, age)
red flag: brand-new pkg, name close to a popular one, few downloads
DETECT malicious indicators (GuardDog / OSSF analysis)
install scripts running code (postinstall / setup.py) | obfuscation | install-time network | name-vs-content mismatch
guarddog pypi scan <pkg>
ALLOWLIST approved packages for critical builds (strongest, less flexible)
PIN (lockfile) + REVIEW dependency additions in PRs (human catches wrong name)
MONITOR squats of YOUR packages ; REPORT malicious ones (protects community)
Reading the risk
- A newly-published package with a name one keystroke off a popular one and few downloads = a classic typosquat red flag; verify the exact correct name against the genuine package before adopting. The core detection.
- A candidate package with an install script running code (
postinstall, setup.py executing) = a common malicious-package tell; legitimate packages rarely need to run arbitrary code on install. A strong indicator to investigate.
- Obfuscated code or install-time network calls in a package = suspicious behaviour typical of malicious squats; scanners (GuardDog) flag these. Don't install.
- A dependency added by PR with a subtly-wrong name = exactly what review catches; a human noticing
reqeusts vs requests stops it before merge. Review dependency additions.
- A typosquat of your own package = a threat to your users; monitor for lookalikes of your names and report them.
- Vetted, pinned, reviewed dependencies from allowlisted sources = the intake protected against name-confusion attacks.
Pitfalls
- Not verifying the exact package name. A single typo or mis-copied name pulls in the squat; verify against the genuine popular package (downloads, maintainer, repo) before adopting. The whole attack relies on this slip.
- Ignoring install scripts. Malicious packages run code on install (postinstall/setup.py); a package that executes arbitrary code on install is a red flag. Scan for it.
- No review of dependency additions. Without a human checking new dependencies, a wrong or suspicious name merges silently; review them in PRs.
- Trusting a name because it's plausible. Combosquats (
python-requests) look reasonable but may be malicious; verify it's the genuine package, not just a plausible name.
- Not monitoring your own package names. Typosquats of your packages target your users; watch for and report them.
References
- GuardDog, OSSF package analysis, and Socket.dev (malicious-package detection)
- The dependency-confusion, lockfile-integrity, and malicious-package-response skills
- npm/PyPI security and reporting documentation
- OpenSSF supply-chain security guidance
Inputs
- Relevant source code, logs, network traces, or system specifications.
Outputs
- Analysis findings, security audit report, or generated code artifacts.
1---2name: typosquat-detection3description: Use when defending against typosquatted and malicious lookalike packages — catching the malicious package with a name close to a popular one before a typo pulls it into your build.4---5678## Prerequisites9- Target system, dependencies and environment configured.1011## Usage12### Purpose1314Attackers publish malicious packages with names deliberately close to popular ones — `reqeusts` for `requests`, `python3-dateutil` for `python-dateutil` — betting on a typo or a copied-wrong name pulling their code into someone's build. Typosquatting (and related name-confusion attacks) are a constant, low-effort supply-chain threat. This skill covers detecting and preventing typosquatted and malicious lookalike packages entering your dependencies.1516### When to use it1718Protecting the dependency intake for any project using public registries, and vetting new dependencies before adoption. It complements dependency confusion (same-name attacks) with the similar-name variant, and pairs with malicious-package response.1920### Procedure21221. **Understand the name-confusion variants** an attacker uses:23 - **Typosquatting** — a name one keystroke off a popular package (`reqeusts`, `loadsh`).24 - **Combosquatting** — adding a plausible word (`requests-oauth`, `python-requests`).25 - **Namespace/manager confusion** — a name from a different ecosystem, or a slightly different naming convention.26 The bet is a typo, a mis-copied name, or a plausible-but-wrong assumption.272. **Vet packages before adding them.** When adopting a new dependency, verify you have the *exact* correct name and it's the genuine, popular package (check download counts, maintainer, repository, age). A brand-new package with a name close to a popular one and few downloads is a red flag.283. **Detect malicious indicators in candidate packages.** Malicious packages often have tells: install scripts that run code (npm `postinstall`, pip `setup.py` executing on install), obfuscated code, network calls on install, or a name-vs-content mismatch. Tools like GuardDog and OSSF package analysis scan for these behaviours:29 ```30 # scan a package for malicious indicators (install scripts, obfuscation, exfil)31 guarddog pypi scan <package>32 ```334. **Use allowlisting for critical environments.** For high-security builds, allowlist approved packages so an unvetted typosquat can't be installed at all — the strongest control, at the cost of flexibility.345. **Pin and review dependencies.** Lockfiles pin exact packages/versions (lockfile-integrity); review dependency additions in pull requests so a wrong or suspicious name gets caught by a human before it merges.356. **Monitor for squats of *your* packages.** If you publish packages, watch for typosquats of *your* names targeting *your* users, and report them for takedown.367. **Report and remove malicious packages** you find (the malicious-package-response skill) — reporting to the registry protects the whole community.3738### Cheatsheet3940```41attack: malicious package with name CLOSE to a popular one -> typo/mis-copy pulls it in42 reqeusts~requests | loadsh~lodash | python3-dateutil~python-dateutil4344variants: TYPOsquat (keystroke off) | COMBOsquat (plausible extra word) | ecosystem confusion4546defend47 VET before adding: exact correct name? genuine popular pkg? (downloads, maintainer, repo, age)48 red flag: brand-new pkg, name close to a popular one, few downloads49 DETECT malicious indicators (GuardDog / OSSF analysis)50 install scripts running code (postinstall / setup.py) | obfuscation | install-time network | name-vs-content mismatch51 guarddog pypi scan <pkg>52 ALLOWLIST approved packages for critical builds (strongest, less flexible)53 PIN (lockfile) + REVIEW dependency additions in PRs (human catches wrong name)54 MONITOR squats of YOUR packages ; REPORT malicious ones (protects community)55```5657### Reading the risk5859- **A newly-published package with a name one keystroke off a popular one and few downloads** = a classic typosquat red flag; verify the exact correct name against the genuine package before adopting. The core detection.60- **A candidate package with an install script running code** (`postinstall`, `setup.py` executing) = a common malicious-package tell; legitimate packages rarely need to run arbitrary code on install. A strong indicator to investigate.61- **Obfuscated code or install-time network calls** in a package = suspicious behaviour typical of malicious squats; scanners (GuardDog) flag these. Don't install.62- **A dependency added by PR with a subtly-wrong name** = exactly what review catches; a human noticing `reqeusts` vs `requests` stops it before merge. Review dependency additions.63- **A typosquat of your *own* package** = a threat to your users; monitor for lookalikes of your names and report them.64- **Vetted, pinned, reviewed dependencies from allowlisted sources** = the intake protected against name-confusion attacks.6566### Pitfalls6768- **Not verifying the exact package name.** A single typo or mis-copied name pulls in the squat; verify against the genuine popular package (downloads, maintainer, repo) before adopting. The whole attack relies on this slip.69- **Ignoring install scripts.** Malicious packages run code on install (postinstall/setup.py); a package that executes arbitrary code on install is a red flag. Scan for it.70- **No review of dependency additions.** Without a human checking new dependencies, a wrong or suspicious name merges silently; review them in PRs.71- **Trusting a name because it's plausible.** Combosquats (`python-requests`) look reasonable but may be malicious; verify it's the genuine package, not just a plausible name.72- **Not monitoring your own package names.** Typosquats of your packages target your users; watch for and report them.7374### References7576- GuardDog, OSSF package analysis, and Socket.dev (malicious-package detection)77- The dependency-confusion, lockfile-integrity, and malicious-package-response skills78- npm/PyPI security and reporting documentation79- OpenSSF supply-chain security guidance8081## Inputs82- Relevant source code, logs, network traces, or system specifications.8384## Outputs85- Analysis findings, security audit report, or generated code artifacts.