npm audit vs OSV-Scanner for React Native apps: what each one checks and what it misses
Updated 26 November 2026 · 8 min read
In short
- Both tools match the exact package versions in a lockfile against a database of known vulnerabilities. Neither tells you whether your app actually reaches the vulnerable code.
npm auditis already installed and only needs npm'spackage-lock.json. OSV-Scanner also readsyarn.lock,pnpm-lock.yamlandbun.lock, and the Androidgradle.lockfile.- A React Native app has a second supply chain, the native iOS and Android libraries. A scan of the JavaScript lockfile alone leaves that half unchecked.
What both tools do, and what neither does
A vulnerability advisory names a package and the versions it affects. A lockfile records the exact version of every package in your build. A scanner joins the two. That is useful, because it turns hundreds of transitive packages into a short list of advisories that apply to the build you ship.
It is also all that either tool does. The npm audit documentation describes a report of known vulnerabilities for the dependencies in your project and does not describe any analysis of whether your code calls the affected function. OSV-Scanner documents call analysis only for Go and, as an experimental feature, Rust. For a React Native app, every finding is a prompt for a person to decide, not a verdict.
What npm audit checks
According to the npm CLI documentation, npm audit "submits a description of the dependencies configured in your project to your default registry and asks for a report of known vulnerabilities". Three details matter for an app team:
- It needs an npm lockfile. By default it requires a
package-lock.jsonornpm-shrinkwrap.json. You can bypass that with--no-package-lock, but the documentation warns that "the results may be different with every run", because npm rebuilds the dependency tree each time. For release evidence, use the lockfile. - It sends package names and versions to your registry. The documentation says npm builds a JSON payload with the name and versions of each package in the tree and posts it to the registry's bulk advisory endpoint. If you use a private registry, check that it supports the endpoint.
- It only speaks npm. The page mentions
package-lock.jsonandnpm-shrinkwrap.jsonand does not mentionyarn.lockorpnpm-lock.yaml. If your project uses Yarn or pnpm, do not assumenpm auditreads your lockfile; use your package manager's own audit command or OSV-Scanner.
The options you will use most:
| Command or option | What it does (from the npm documentation) |
|---|---|
npm audit --omit=dev | Leaves development dependencies out of the report. The omitted packages are still resolved and recorded in the lockfile; they are just not part of the check. |
--audit-level=high | Sets the minimum severity at which the command exits with a non-zero code. It does not filter the output. Levels run from info to critical. |
--json | Writes JSON instead of the normal output, which is what you keep as a record: npm audit --json > audit-4.2.0.json |
npm audit fix | Runs a full install to apply fixes. The documentation says some vulnerabilities cannot be fixed automatically and need manual review. |
npm audit fix --force | Allows changes outside your stated version ranges, including major versions. The documentation strongly recommends against it if you do not have a clear idea of what you want. |
npm audit signatures | A different check: it verifies the registry signatures and provenance attestations of the packages you downloaded. It tells you a package is what the registry says it is, not that the package is free of vulnerabilities. |
By default, npm audit exits with a non-zero code if it finds any vulnerability, so it already works as a gate in CI. Note that the default scope includes development dependencies. Decide deliberately whether your gate should look at everything or only at what ships.
What OSV-Scanner checks
OSV-Scanner checks lockfiles against the OSV database. Its list of supported lockfiles includes, for the parts of a React Native project that matter here:
| Part of the app | Files OSV-Scanner lists as supported |
|---|---|
| JavaScript | package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock |
| Android (Gradle) | gradle.lockfile, buildscript-gradle.lockfile, gradle/verification-metadata.xml |
| iOS | Neither Podfile.lock nor Package.resolved appears on the supported-lockfiles page. |
The documented syntax for a specific lockfile is:
osv-scanner scan source --lockfile=package-lock.json --lockfile=android/gradle.lockfile
The documentation recommends scanning a resolved lockfile, and a fully pinned manifest only when there is none, because manifest files "can declare version ranges and do not necessarily record the versions installed in an environment". That is the same reason you should never scan package.json alone.
The exit codes are more specific than npm's:
| Exit code | Meaning |
|---|---|
0 | Packages were found and nothing matches a known vulnerability. |
1 | Packages were found, and there are vulnerabilities or findings. |
127 | General error. |
128 | No packages found, likely because the scan did not pick up any files. |
Treat 128 as a failure in CI. A scan that finds no files looks exactly like a clean app. Output formats include table (the default), json, sarif, html, markdown, CycloneDX and SPDX. To silence a finding you have triaged, put an osv-scanner.toml next to the lockfile and give a reason:
[[IgnoredVulns]]
id = "CVE-2022-24713"
reason = "Dev dependency, does not ship in the app"
The ID above is the documentation's example; use your own advisory and a reason someone else can check.
Side by side
| npm audit | OSV-Scanner | |
|---|---|---|
| Installation | Part of npm | Separate tool to install in CI |
| JavaScript lockfiles | package-lock.json, npm-shrinkwrap.json | package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock |
| Android native libraries | Not covered | gradle.lockfile and related files |
| iOS native libraries | Not covered | Not listed as supported |
| Where the data comes from | Your configured npm registry | The OSV database |
| Reachability analysis | Not described in the documentation | Go and Rust only |
| Automatic fix | npm audit fix | No, it reports |
| Machine-readable output | --json | JSON, SARIF, CycloneDX, SPDX and more |
What both of them miss in a React Native app
- Native iOS libraries. React Native libraries with native code bring CocoaPods into
ios/Podfile.lock.npm auditworks on the npm tree, and OSV-Scanner does not listPodfile.lockas supported. Check the iOS side with a tool that reads that file, such as the Shipmark free scanner, which acceptsPodfile.lock. See the React Native SBOM guide for the files to collect. - Reachability. A finding in a package you ship is not the same as an exploitable app. Decide each one yourself: does the package ship (a development tool does not), is the affected version the one you use, is there a fixed version, and if there is none, what will you do instead.
- Unknown vulnerabilities. Both tools find known advisories only. They say nothing about flaws in your own code or about vulnerabilities nobody has reported.
- Code that is not in a package. Vendored copies of a library, or a library copied into the repository, are not matched by a lockfile scan.
A practical setup
- Commit your lockfile. Scan it on every pull request and every release build.
- If you use npm, run
npm audit --jsonand keep the file with that version's technical documentation. If you use Yarn or pnpm, run OSV-Scanner on the lockfile, or run both tools and compare. - Add
gradle.lockfileto the OSV-Scanner run for the Android side. - Scan again on a schedule against the lockfile of every version you still support. New advisories appear after you ship.
- Fail the build on new findings so that a person has to decide, and record the decision: upgraded, not affected (with the reason), or no fix yet (with the mitigation, an owner and a date).
To get the SBOM and a lockfile check against OSV.dev in one step, including Podfile.lock, the free Shipmark SBOM action runs on every build:
- uses: actions/checkout@v4
- uses: shipmark-eu/sbom-action@v1
The same step-by-step triage routine is described for another stack in how to check a Flutter app's dependencies for known vulnerabilities.
How this fits the CRA
You publish the app under your name, so under Regulation (EU) 2024/2847 you are the manufacturer, even if an agency writes and maintains the code. A lockfile scan serves several points of Annex I and one article:
| CRA text | What a dependency scan gives you |
|---|---|
| Annex I, Part I, point (2)(a): made available on the market without known exploitable vulnerabilities | A check of what is known at the time you ship. |
| Annex I, Part II, point (1): identify and document vulnerabilities and components, including an SBOM covering at least the top-level dependencies | The lockfile that your SBOM is built from is the same file you scan. |
| Annex I, Part II, point (2): address and remediate vulnerabilities without delay | A trigger for the upgrade and a dated record of how you responded. |
| Annex I, Part II, point (3): effective and regular tests and reviews of the product's security | A repeated, documented test of your dependencies. |
| Article 13(5): due diligence when integrating components sourced from third parties | Evidence that you looked at the components you integrated, not only at your own code. |
A scan is one input, not proof of conformity. For what to do when a finding is being actively exploited, see CRA vulnerability reporting for app teams, and for the day-to-day process around findings see CRA vulnerability handling.
Common questions
Is npm audit enough for a React Native app?
For the npm packages, it is a reasonable start if you use npm. It does not cover the native iOS and Android libraries that React Native libraries bring in, and its documentation mentions only npm's own lockfiles.
Does OSV-Scanner replace npm audit?
For checking, it can: it reads the npm, Yarn, pnpm and Bun lockfiles. It does not apply fixes. You still upgrade packages with your package manager.
Should I scan devDependencies?
They do not ship in the app, so a finding there is rarely an issue for your users, but it can matter for your build pipeline. Scan everything, and mark development-only findings as not affecting the released product, with the reason, rather than hiding them.
Our agency maintains the app. Who runs the scan?
The agency can run it, but you are the manufacturer and you decide what is acceptable. Ask for the scan result with every release, and put that in the contract: see what to ask for in the maintenance contract.
Check your package-lock.json, yarn.lock or Podfile.lock against OSV.dev now. No account, and the file stays in your browser.
Sources
- npm CLI documentation: npm audit
- OSV-Scanner: supported languages and lockfiles
- OSV-Scanner: project source scanning
- OSV-Scanner: output formats, return codes and ignoring vulnerabilities
- Regulation (EU) 2024/2847 (Cyber Resilience Act), EUR-Lex; wording of Annex I and Article 13(5) checked against the independent annex guide and regulation text
Also see: How to generate an SBOM for a React Native app. This guide summarises Regulation (EU) 2024/2847 for practical use. It is not legal advice.