dart_audit 0.3.0
dart_audit: ^0.3.0 copied to clipboard
Security vulnerability scanner for Dart and Flutter projects. Checks all dependencies against the OSV.dev database.
0.3.0 #
Added #
-
Unicode / Trojan Source scanner (
lib/src/inspector/unicode_scanner.dart) — detects:- Bi-directional override characters (CVE-2021-42574) — RTL/LTR overrides, embedding, and pop directional isolates (CRITICAL).
- Zero-width characters (U+200B–U+200F, U+2028–U+2029, U+2060–U+2064, U+FEFF) — potential invisible injection (HIGH).
- GlassWorm PUA carriers (U+FE00–U+FE0F variation selectors) — used to smuggle executable content (CRITICAL).
- Cyrillic / Greek homoglyphs in identifiers — visual spoofing of variable and function names (HIGH).
- Runs in parallel with regex and entropy scanners during
inspect.
-
Archive structural scanner (
lib/src/inspector/archive_scanner.dart) — analyses.tar.gzarchive entries before extraction:- Path-traversal detection (
../, absolute paths, parent-segment traversal) — CRITICAL. - Suspiciously high Dart-to-total file ratio — MEDIUM.
- Hidden executable files (
.exe,.dll,.so,.dylib) — HIGH. - Mixed-case filenames suggesting case-confusion on case-insensitive systems — MEDIUM.
- Entry count statistics exposed to the report.
- Path-traversal detection (
-
Package trust scorer (
lib/src/inspector/trust_scorer.dart) — queriespub.devAPI for a published package's trust signals:- Package age (days since first publish) — new packages (< 30 days) flagged as MEDIUM risk.
- Fresh release detection (version published < 7 days ago) — MEDIUM.
- Likes and download-percentile heuristics.
- Publisher verification status.
- Overall quality score from pub.dev.
- Asynchronous; used by both
inspectand the newtrustcommand.
-
Typosquatting detector (
lib/src/inspector/typosquat_detector.dart) — compares local dependency names against ~80 known-popular pub.dev packages:- Levenshtein distance 1 (CRITICAL) and 2 (HIGH) matches.
flutter_,_flutter,dart_,pub_prefix/suffix confusion attacks (HIGH).- Suspicious suffix on popular-package names (MEDIUM).
- Popular-package names are automatically skipped.
-
Dependency confusion detector (
lib/src/inspector/confusion_detector.dart) — flags potential internal-package namespace confusion by detecting version inflation (a local version newer than the latest pub.dev release). -
Pubspec.yaml scanner (
lib/src/inspector/pubspec_scanner.dart) — analysespubspec.yamlfor:- Wildcard /
anyversion constraints. - Suspicious Git hosts (non-GitHub, non-GitLab, non-Codeberg).
- IP addresses and raw URLs in dependency sources.
- Branch or tag refs (not pinned to a SHA).
- Path dependencies.
- Dependency overrides.
- Very old SDK constraints (
>=2without upper bound).
- Wildcard /
-
trustsub-command —dart_audit trust <package>queries the pub.dev API and prints a trust assessment: age, release freshness, publisher verification, likes, downloads, and quality score. -
typosquatsub-command —dart_audit typosquatreads the project'spubspec.lockand runs both the typosquatting detector and the dependency confusion detector against all listed dependencies. -
Updated
inspectoutput — theinspectcommand now prints Unicode findings, archive findings, and a trust assessment section alongside the existing regex and entropy results.
Changed #
inspectnow runs 4 scanner layers in parallel: regex, entropy, Unicode, and archive analysis.PackageInspectorexposesunicodeFindings,archiveReport, andtrustAssessmentonInspectionReport.TyposquatDetectornow skips local packages that are themselves known-popular packages.
0.2.0 #
Added #
-
inspectsubcommand — statically analyses a pub.dev package's Dart source before it enters the project, enabling supply-chain attack detection.- Downloads the package
.tar.gzarchive frompub.devusing thearchivepackage; extracts only.dartfiles to a temporary directory (always cleaned up). - Regex scanner — 14 rules across 7 categories: hard-coded URLs to unknown hosts, raw TCP sockets,
Process.run/ shell injection, sensitive file-system paths, obfuscation techniques (hex encoding, Base64 eval, Unicode escapes, char-code concatenation), crypto-mining, backdoor / reverse-shell patterns, and data exfiltration markers. - Shannon entropy scanner — flags string literals with high entropy (> 4.5 bits → MEDIUM, > 5.5 bits → HIGH) as possible obfuscated payloads or embedded secrets. Minimum string length of 20 characters to reduce noise.
- Weighted risk score 0–100 (CRITICAL regex: 40 pts, HIGH: 20 pts, MEDIUM: 10 pts; entropy HIGH: 15 pts, MEDIUM: 5 pts), clamped and labelled CLEAN / LOW RISK / SUSPICIOUS / HIGH RISK.
- Both scanners run in parallel via
Future.wait. - Exit code
1when risk score ≥ 30 (SUSPICIOUS or worse);--exit-zerodisables this. --format jsonproduces machine-readable output.- Throws typed
PackageNotFoundExceptionon 404 from pub.dev.
- Downloads the package
-
Subcommand architecture — the CLI is now structured as
dart_audit <command> [options]with two commands:audit(default) andinspect. A baredart_auditstill behaves asauditfor backwards compatibility. -
--format jsonfor theauditcommand — all findings and package metadata are serialised to structured JSON. -
--min-severityfilter foraudit— only reports findings at or above the specified level (low / medium / high / critical). -
--ignoreflag foraudit— suppresses specific CVE / GHSA IDs. Can be repeated. -
--no-colorglobal flag — disables ANSI colour output. Color state is now shared via a singlecolor_outputmodule so both commands honour the flag consistently. -
HTTP timeout and retries for
audit— requests to OSV.dev now time out after 30 s and are retried up to 3 times with exponential back-off (1 s, 2 s, 4 s). -
Skipped-package warnings — git, path, and SDK dependencies are now tracked and reported as warnings instead of being silently ignored.
-
CVSS parsing improvements — falls back through three levels: (1) top-level
severityarray withCVSS_V3/CVSS_V2type, (2)database_specific.severity, (3)affected[].database_specific.severity. -
Progress indicator for large dependency trees — reports batch progress while querying OSV.dev.
-
Version read from
pubspec.yamlat runtime — no more hardcoded version constant.
Fixed #
_resolveFixedVersionpreviously returnednulleven when a fix was found (dead code path). Now correctly resolves and returns the fixed version string.
0.1.0 #
Initial release.
Added #
dart_auditCLI tool — scanspubspec.lockagainst the OSV.dev vulnerability database.--lockfile / -loption to specify a custom path topubspec.lock(defaults topubspec.lockin the current directory).--verbose / -vflag to list all packages including clean ones.--exit-zeroflag for CI reporting-only mode (always exits 0 even when vulnerabilities are found).--versionflag to print the current version.- Severity classification: CRITICAL, HIGH, MEDIUM, LOW, UNKNOWN — derived from CVSS scores and OSV database-specific fields.
- Colored terminal output using ANSI codes (auto-disabled when stdout is not a terminal).
- CVE / GHSA alias display, vulnerability summary, and available fix version for each finding.
- Batched OSV.dev API requests (up to 100 packages per request) to handle large dependency trees efficiently.
- Filters to
hostedpackages only — skipsgitandpathdependencies not indexed by OSV.dev. - Exit code
1when vulnerabilities are found, enabling automatic CI/CD pipeline failure.