Security

    Dependency confusion and typosquatting in mobile apps

    A 2026 view of a mobile build's package manager being tricked into pulling a typosquatted look-alike package and a malicious public package shadowing a private one

    Two supply-chain attacks target the moment you add a dependency, and both can slip malicious code into a mobile app's build. Typosquatting relies on a mistyped or look-alike package name, so you install the attacker's package instead of the one you meant. Dependency confusion exploits how build tools resolve names, tricking them into pulling a malicious public package in place of your private one. Neither requires breaking into your systems; they exploit the package-management step you do routinely. Here is how each attack works, how it reaches mobile apps, and how to defend against them.

    Short answer

    Dependency confusion and typosquatting are supply-chain attacks on the packages your app depends on. Per OWASP, typosquatting is when an attacker publishes a malicious package with a name similar to a popular one, hoping you install it by mistake, and dependency confusion is when an attacker publishes a public package with the same name as your private internal one, so the build tool fetches the malicious public version instead. Both can inject malicious code into your mobile build through your package manager. Defend by verifying package names, using lockfiles to pin versions and integrity, scoping or namespacing internal packages, configuring registries so private names are not resolved publicly, and reviewing new dependencies.

    What you should know

    • Typosquatting uses look-alike names: a mistyped package is the attacker's.
    • Dependency confusion abuses name resolution: a public package shadows your private one.
    • Both inject code into your build: through the package manager.
    • Lockfiles and verification help: pin versions and integrity.
    • Scope internal packages: so private names cannot be confused publicly.

    How do dependency confusion and typosquatting differ?

    They exploit different weaknesses in dependency resolution. The table contrasts them.

    AttackHow it works
    TyposquattingA malicious package is named like a popular one, installed by a typo or look-alike
    Dependency confusionA public package matches your private package's name and is fetched instead
    Shared outcomeMalicious code runs in your build and ships in your app
    Shared causeThe package manager resolves to the attacker's package

    Typosquatting targets human error: an attacker registers a package whose name closely resembles a widely used one, betting that someone mistypes it or copies a wrong reference, and installs the malicious package. Dependency confusion targets tooling behavior: if your build uses a private package name that also exists publicly, some package managers will prefer the public one, especially a higher version, so an attacker who publishes a public package with your internal name can get it pulled into your build. Different mechanisms, but the same result, attacker code in your dependencies, and the same root, the package manager resolving to something you did not intend.

    How do these attacks reach mobile apps?

    Through the package managers mobile development relies on. Mobile apps pull dependencies through tools like npm for React Native, CocoaPods or Swift Package Manager for iOS, and Gradle or Maven for Android, and each of these resolves names and versions from registries. Typosquatting reaches you when a package is added with a wrong or look-alike name, directly or as a transitive dependency, and dependency confusion reaches you when a build resolves a private name to a malicious public package. In both cases, the malicious package can run code during the build or ship inside your app, gaining whatever access your build or app has. Because these attacks operate at the dependency layer, they bypass your own code entirely, which is why they are a supply-chain risk rather than a flaw you would find by reviewing what you wrote.

    How do you defend against them?

    Control how dependencies are named, resolved, and verified. Verify the exact name of any package before adding it, since a look-alike is easy to miss, and prefer well-established packages from sources you trust. Use lockfiles to pin exact versions and verify integrity, so a dependency cannot silently change to a malicious one, and review changes to your dependency set. For internal packages, scope or namespace them and configure your package manager and registry so private names are resolved only from your private source, never silently from a public registry, which is the specific defense against dependency confusion. Minimize the number of dependencies you take on, since each is a trust decision, and monitor for unexpected packages. The throughline is to make dependency resolution deterministic and verified, so the package manager cannot be tricked into pulling the attacker's package.

    What to watch out for

    The first trap is adding a package without checking its exact name, which is how a typosquatted look-alike gets in. The second is using internal package names that could exist publicly without configuring your tooling to resolve them privately, which is the dependency-confusion opening. The third is not pinning versions and integrity, so a dependency can change under you. These attacks ship in the build, so a pre-submission scan such as PTKD.com (https://ptkd.com) reads the compiled APK, AAB, or IPA against OWASP MASVS and inventories the components actually present, which helps you spot an unexpected or unfamiliar package that ended up in your app. The resolution and verification controls you set in your build configuration.

    What to take away

    • Typosquatting installs a malicious package with a look-alike name, and dependency confusion fetches a malicious public package in place of your private one.
    • Both inject attacker code into your mobile build through the package manager, bypassing your own code, which makes them supply-chain risks.
    • Defend by verifying package names, pinning versions and integrity with lockfiles, scoping internal packages, configuring private resolution, and reviewing dependencies.
    • Use a pre-submission scan such as PTKD.com to inventory the components actually in your build and spot an unexpected package before you ship.
    • #dependency-confusion
    • #typosquatting
    • #supply-chain
    • #dependencies
    • #owasp-masvs
    • #app-security
    • #mobile

    Frequently asked questions

    What is typosquatting in package dependencies?
    It is an attacker publishing a malicious package with a name closely resembling a popular one, betting that someone mistypes the name or copies a wrong reference and installs the malicious package instead of the intended one. It targets human error at the moment you add a dependency. The malicious package can run code during the build or ship in your app, so verifying the exact package name before adding it, and preferring well-established packages, is the defense.
    What is dependency confusion?
    It is an attacker publishing a public package with the same name as your private, internal package, exploiting that some package managers prefer the public one, especially a higher version. The build then fetches the attacker's public package in place of your private one, injecting malicious code. It targets tooling behavior rather than human error. The defense is to scope or namespace internal packages and configure your tooling so private names resolve only from your private source.
    How do these attacks reach a mobile app?
    Through the package managers mobile development uses, npm for React Native, CocoaPods or Swift Package Manager for iOS, and Gradle or Maven for Android, which resolve names and versions from registries. Typosquatting reaches you when a wrong or look-alike name is added, directly or transitively, and dependency confusion when a private name resolves to a malicious public package. The malicious package can run during the build or ship in the app, bypassing your own code.
    How do I defend against dependency confusion and typosquatting?
    Verify the exact name of any package before adding it and prefer trusted, well-established ones; use lockfiles to pin exact versions and verify integrity so a dependency cannot silently change; scope or namespace internal packages and configure your package manager so private names resolve only from your private source; minimize the dependencies you take on; and review changes to your dependency set. The goal is deterministic, verified resolution that cannot be tricked into the attacker's package.
    Can a scan detect a malicious dependency?
    It can help by inventorying what actually shipped. These attacks inject code at the dependency layer, so a pre-submission scan such as PTKD.com reads the compiled APK, AAB, or IPA against OWASP MASVS and inventories the components present in your build, which helps you spot an unexpected or unfamiliar package that ended up in your app. The primary defenses, name verification, lockfiles, and private resolution, are in your build configuration, and the scan confirms what the build contains.

    Keep reading

    Scan your app in minutes

    Upload an APK, AAB, or IPA. PTKD returns an OWASP-aligned report with copy-paste fixes.

    Try PTKD free