In short
- Run OSV-Scanner on
pubspec.lock. It lists every known vulnerability matched to the exact package versions in your build. - The scanner does not know whether your app calls the vulnerable code, so each finding needs a short human decision: upgrade, ignore with a written reason, or investigate.
- Scan on every release and on a schedule. New advisories appear after you ship, and the CRA expects you to deal with vulnerabilities without delay.
Why scan the lockfile, not the code
Your pubspec.lock records the exact version of every Dart and Flutter package in the build. Known vulnerabilities are published against package versions, so matching that file against a vulnerability database is the fastest way to learn whether a published advisory affects the app you ship.
Dart's own tooling already does a first version of this. The Dart documentation says pub uses the GitHub Advisory Database for security advisories on Dart and Flutter packages, and that "the pub client surfaces security advisories at dependency resolution". In practice, flutter pub get or dart pub get can print a notice when a dependency is affected by an advisory. That is useful for developers, but it is a message on one machine. A scan in CI gives you a result you can keep for each release.
Step 1. Run OSV-Scanner on pubspec.lock
OSV-Scanner is Google's open-source scanner for the OSV vulnerability database. Its list of supported lockfiles includes Dart: pubspec.lock and package_config.json. The documented syntax for scanning a specific file is:
osv-scanner scan source --lockfile=pubspec.lock To let it find lockfiles itself, point it at a directory and add -r to search subfolders. This is handy in a monorepo, but it will also pick up lockfiles you did not intend to scan, so check which files it reports:
osv-scanner scan source -r . The documentation notes that scan source is the default subcommand, so osv-scanner -r . does the same thing.
Step 2. Read the results
The default output is a table. Its columns are the OSV URL, CVSS, ecosystem, package, version, fixed version and source (the lockfile the package came from). Three of them do most of the work:
| Column | What to do with it |
|---|---|
| OSV URL | Open it. The advisory describes what is affected and how, and it is the page you will link to in your own record. |
| Version and fixed version | Compare them. If a fixed version exists, the upgrade path is clear. The documentation says an empty fixed version, or --, means there is currently no fix. |
| CVSS | A starting point for priority, not a verdict. A high score on code your app never reaches matters less than a medium one on code that handles user input. |
The exit code tells a CI job what happened:
| Exit code | Meaning (from the OSV-Scanner documentation) |
|---|---|
0 | Packages were found and no known vulnerabilities or findings match. |
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 silently finds no files looks exactly like a clean app.
For records and dashboards, other formats are available through --format: json, sarif, html, markdown and CycloneDX among them. The JSON output goes to standard output, so redirect it:
osv-scanner scan --format json -L pubspec.lock > scan-4.2.0.json Step 3. Decide what to do with each finding
The scanner reports matches. It does not tell you whether the vulnerable code runs in your app. Its documentation describes call analysis only for Go and Rust, so for Flutter every finding needs a person's decision. A workable routine is to answer four questions in order:
- Does this package ship in the app? In
pubspec.lock,dependency: direct devmarks build tools that do not ship. Check the field before you spend time on a finding. - Is the affected version the one you use? Read the advisory's affected range against the version in your lockfile.
- Is there a fixed version? If so, upgrade it, run your tests and release. If the package is only a transitive dependency, you may need to raise the direct dependency that pulls it in.
- If there is no fix, what do you do instead? Replace the package, remove the feature, or add a mitigation, and write down which one and why.
| Outcome | What to record |
|---|---|
| Upgraded | The advisory link, the old and new version, the release that contains the fix. |
| Not affected | The advisory link and the reason, for example the package is a development tool, or the vulnerable function is never used. |
| No fix yet | The mitigation, the owner and a date to look again. |
Ignoring a finding without losing track of it
Both tools let you silence a known finding, and both ask you to say what you silenced. In OSV-Scanner, put an osv-scanner.toml next to the lockfile:
[[IgnoredVulns]] id = "CVE-2022-24713" reason = "Package is a dev dependency and does not ship in the app" That example comes from the documentation. Use the ID of your own advisory and a reason someone else can check. Dart's equivalent is the ignored_advisories list in pubspec.yaml, which per the Dart documentation only affects the root package. An ignore without a reason becomes an unexplained exception a year later.
Step 4. Make it routine
- Scan
pubspec.lockon every pull request and every release build, and keep the result with that version's technical documentation. - Also scan on a schedule, for example daily, against the lockfile of every version you still support. A release that was clean when you shipped it can be affected by an advisory published next month.
- Fail the build on exit code
1for new findings, so a human has to decide. Do not fail it on findings you have already triaged and recorded. - Do not forget the native side. Flutter plugins bring native libraries that are not in
pubspec.lock. The Flutter SBOM guide shows which files to add, and OSV-Scanner's supported-lockfiles page shows which of them it reads.
If you want the lockfile scan and the SBOM in one step, the free Shipmark SBOM action reads pubspec.lock and checks the result against OSV.dev on every build:
- uses: actions/checkout@v4 - uses: shipmark-eu/sbom-action@v1 For a one-off check without installing anything, the Shipmark free scanner does the same in your browser. The file never leaves it.
How this fits the CRA
You publish the app under your name, so under Regulation (EU) 2024/2847 you are the manufacturer and the vulnerability duties are yours, even if an agency maintains the code. Four points in Annex I are directly served by a routine like the one above:
| 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 before each release, so you know what is known at the time you ship. |
| Annex I, Part II, point (2): address and remediate vulnerabilities without delay, including by providing security updates | 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. |
| Annex I, Part II, point (4): share and publicly disclose information about fixed vulnerabilities once a security update is available | The raw material for a short advisory when a fix reaches users. |
A dependency scan covers known vulnerabilities in the packages you ship. It does not cover flaws in your own code, so it complements, and does not replace, the checks in the Annex I guide for mobile apps. When a vulnerability is being actively exploited, separate reporting rules apply: see CRA vulnerability reporting for app teams.
Common questions
Does OSV-Scanner tell me whether my app uses the vulnerable code?
Not for Dart. The documentation describes call analysis for Go and Rust only. For a Flutter app, treat each match as a question to answer, not as proof of exposure.
Is a clean scan enough for the CRA?
No. It shows known vulnerabilities in your dependencies on the day you ran it. The CRA also expects a process: remediation without delay, regular security tests and reviews, and information about fixed vulnerabilities.
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.
Try it on your own app: the free Shipmark scanner builds a CycloneDX SBOM from a lockfile in the browser and checks it against OSV.dev. Not sure the CRA applies? Use the six-question CRA check.
Sources
- OSV-Scanner: supported languages and lockfiles
- OSV-Scanner: project source scanning
- OSV-Scanner: output formats, return codes and ignoring vulnerabilities
- Dart: security advisories
- GitHub: supply chain security features now support Dart
- Regulation (EU) 2024/2847 (Cyber Resilience Act), EUR-Lex, Annex I Parts I and II; wording checked against the independent annex guide
Also see: How to generate an SBOM for a Flutter app and for a React Native app. This guide summarises Regulation (EU) 2024/2847 for practical use. It is not legal advice.
Originally published on shipmark.eu, where the guide is kept up to date. More guides for app teams: shipmark.eu/guides.

