packages command provides utilities for managing the package vulnerability database and performing specialized analysis comparing packages directly against app bundles. It operates on the clean database (separate from the main hedis database).
Usage
Flags
Database Management
Update the database with packages from
direct-vulnerabilities.json. Creates package entries with vulnerability metadata.Generate function fingerprints for all packages in the database across all React Native versions. This is a comprehensive operation that:
- Fetches RN baselines
- Processes each package across all RN environments
- Generates and stores hashes
- Filters out framework functions using baselines
Analysis Modes
Enable specific package-to-app analysis mode. Compare a specific package HBC file against an app bundle with baseline filtering.
Analyze an app bundle against all packages in the database. Generates a ranked list of package matches.
Analysis Parameters
Path to the package HBC file. Required when
--specific-analysis is enabled.Path to the app bundle HBC file to analyze. Required for both analysis modes.
Path to the output file for analysis results. Defaults to
<bundle-name>_match_results.txt for database analysis.Enable verbose output for detailed logging.
Examples
Update Package Database
Import packages from vulnerability JSON:- Reads
direct-vulnerabilities.jsonfrom the current directory - Extracts unique packages with version ranges
- Creates
PackageWithVulnerabilitiesModelentries in thecleandatabase - Associates packages with their GHSA IDs and severity levels
Generate Hashes for All Packages
Create fingerprints for database packages:- Fetch RN baselines from database
- For each package:
- For each RN version:
- Install package
- Metro bundle
- Hermes compile
- Disassemble and hash
- Filter baseline matches
- Store in database
- For each RN version:
Specific Package Analysis
Compare a package against an app bundle with baseline filtering:- Extracts Hermes bytecode version from both bundles
- Generates function object hashes
- Identifies the best-matching RN baseline based on bytecode version
- Filters out framework functions from the app bundle
- Compares package hashes against filtered app hashes
- Reports match percentages across three hash types
Database Analysis
Analyze an app bundle against all packages in the database:- Disassembles the app bundle and generates hashes
- Identifies best RN baseline match
- Filters framework functions from app hashes
- Queries database for all package hashes matching the RN version
- Compares app against each package
- Ranks results by combined match count
- Writes full results to output file
Combined Workflow
Build database and analyze:Analysis Metrics
The analysis compares three hash types:Structural Hash
- Based on instruction opcode bigrams (sequences)
- Resistant to identifier renaming and string changes
- Best for detecting code structure similarity
Content IR1 Hash
- Based on non-identifier strings (literals, messages, etc.)
- Good for detecting string constant similarity
- Vulnerable to string obfuscation
Content IR2 Hash
- Based on identifiers and object references
- Good for detecting variable/function name similarity
- Vulnerable to minification and obfuscation
Combined Metric
A function matches if any of the three hashes match. The combined metric gives the best overall indication of package presence.Baseline Filtering
Both analysis modes use RN baseline filtering:- Extract HBC version from the app bundle
- Find best baseline match by comparing app hashes against all RN baselines
- Filter framework hashes that match the baseline
- Compare remaining hashes against package fingerprints
Database Schema
Theclean database uses these collections:
packages
hashes
Environment Variables
MongoDB connection URI.
Platform-specific Hermes binary:
osx-bin or linux64-bin.File Requirements
direct-vulnerabilities.json
Required for--update-database:
Performance Considerations
Hash Generation
- Processing all packages can take days for large package sets
- Each package is installed and compiled 11 times (once per RN version)
- Uses parallel RN version processing (max 4 concurrent)
Database Analysis
- Queries all package hashes for the detected RN version
- Performs in-memory comparisons
- Sorts results by combined match count
- Typically completes in seconds to minutes depending on database size
Common Use Cases
Vulnerability Research
Build a database of vulnerable package fingerprints:App Auditing
Scan a production app for known vulnerable packages:Package Verification
Verify if a specific package version is in an app:Notes
- This command uses a separate
cleandatabase (not the mainhedisdatabase) - Baseline filtering significantly improves accuracy by removing framework noise
- Match percentages >80% indicate strong confidence the package is present
- The database analysis output includes both per-version and per-package rankings
- Results are sorted by combined matches (any hash type matching)