You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trivy fs with VIRTUAL_ENV environment variable silently excludes Python packages that have non-standard SPDX license identifiers in their METADATA files. This causes critical AGPL-licensed packages to be completely missing from scan results, creating a false sense of security and potential license compliance violations.
Impact
Security/Compliance Risk: AGPL and other restrictively-licensed packages are not reported
Silent Failure: No warning or error is shown when packages are dropped
Inconsistent Behavior:trivy rootfs correctly detects these packages, but trivy fs does not
False Negatives: Organizations relying on trivy fs for license compliance may unknowingly violate license restrictions
Root Cause
Python packages use non-standard SPDX identifiers in their METADATA files. The pip analyzer used by trivy fs fails to normalize these, while the packaging analyzer used by trivy rootfs handles them correctly.
anki (site-packages/anki-24.11.dist-info/METADATA):
License: AGPL-3
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Not a valid SPDX identifier (should be AGPL-3.0-or-later)
Both trivy fs and trivy rootfs detect it correctly ✅
Evidence
Debug output shows trivy fsdoes read the package but excludes it from results:
$ VIRTUAL_ENV=/path/to/env trivy fs requirements.txt --scanners=license --debug 2>&1| grep anki
DEBUG [python] License acquired from METADATA classifiers ... name="anki" version="24.11"
However, when listing results:
$ VIRTUAL_ENV=/path/to/env trivy fs requirements.txt --scanners=license | grep anki
# No output - package silently dropped
Comparison Table
Package
METADATA License Field
trivy fs
trivy rootfs
anki
AGPL-3
❌ Not reported
✅ AGPL-3.0-or-later (CRITICAL)
ultralytics
AGPL-3.0
❌ Not reported
✅ AGPL-3.0-or-later (CRITICAL)
gensim
LGPL-2.1-only
✅ Detected (HIGH)
✅ Detected (HIGH)
This issue particularly affects organizations scanning for license compliance, as AGPL is typically flagged as a forbidden license due to its copyleft requirements. The silent failure means that critical compliance violations may go undetected.
The inconsistency between trivy fs and trivy rootfs behavior suggests that trivy rootfs has more robust license parsing/normalization logic that should be applied to trivy fs as well.
Note: This issue was discovered while scanning pixi-managed Python environments, but affects any Python virtual environment (venv, virtualenv, conda, pixi, etc.) when using trivy fs with VIRTUAL_ENV.
Desired Behavior
trivy fs should handle non-standard SPDX identifiers like trivy rootfs does:
Normalize common variants (e.g., AGPL-3 → AGPL-3.0-or-later, LGPL-2.1 → LGPL-2.1-only)
Fall back to license classifiers if the License: field is unparseable
Warn about unparseable licenses instead of silently dropping packages
Maintain consistency between fs and rootfs scanners
Actual Behavior
When scanning the same Python environment:
trivy fs with VIRTUAL_ENV reports only 1 packages with licenses (gensim) and 0 CRITICAL findings
Packages with non-SPDX license strings (anki with AGPL-3, ultralytics with AGPL-3.0) are silently excluded from the report
No warning or error message indicates that packages were dropped
Debug logs show anki is read from METADATA but it never appears in the final output
Reproduction Steps
# 1. Create a virtual environment and install packages
python3 -m venv test_env
source test_env/bin/activate
pip install anki==24.11 ultralytics==8.3.234 gensim==4.3.2
# Alternative with pixi:# pixi init && pixi add anki==24.11 ultralytics==8.3.234 gensim==4.3.2# 2. Create requirements.txt
pip freeze > requirements.txt
# 3. Scan with trivy fs (FAILS - missing AGPL packages)
VIRTUAL_ENV=$(pwd)/test_env trivy fs requirements.txt \
--scanners=license \
--severity=CRITICAL,HIGH
# Expected: Should report anki and ultralytics with AGPL licenses# Actual: Only reports gensim # 4. Scan with trivy rootfs (WORKS - finds all packages)
trivy rootfs test_env \
--scanners=license \
--severity=CRITICAL,HIGH
# Expected: Should report same packages as trivy fs# Actual: Correctly reports packages including anki and ultralytics
Target
Filesystem
Scanner
License
Output Format
None
Mode
Standalone
Debug Output
Running `trivy fs` with `--debug` flag shows that anki is being read but not included in results:
$ VIRTUAL_ENV=/path/to/env trivy fs requirements.txt --scanners=license --debug 2>&1| grep -i anki
2025-12-12T20:56:59-05:00 DEBUG [python] License acquired from METADATA classifiers may be subject to additional terms name="anki" version="24.11"
Full scan output (without debug):
$ VIRTUAL_ENV=/path/to/env trivy fs requirements.txt --scanners=license --severity=CRITICAL,HIGH --skip-db-update
2025-12-12T20:56:59-05:00 INFO [license] License scanning is enabled
2025-12-12T20:56:59-05:00 INFO [python] Licenses acquired from one or more METADATA files may be subject to additional terms. Use `--debug` flag to see all affected packages.
Report Summary
┌──────────────────┬──────┬──────────┐
│ Target │ Type │ Licenses │
├──────────────────┼──────┼──────────┤
│ requirements.txt │ - │ 2 │
└──────────────────┴──────┴──────────┘
requirements.txt (license)
Total: 1 (HIGH: 1, CRITICAL: 0)
┌──────────┬───────────────┬────────────────┬──────────┐
│ Package │ License │ Classification │ Severity │
├──────────┼───────────────┼────────────────┼──────────┤
│ gensim │ LGPL-2.1-only │ Restricted │ HIGH │
├──────────┼───────────────┤ │ │
│
└──────────┴───────────────┴────────────────┴──────────┘
Note: anki is missing from the output despite being in requirements.txt and detected in debug logs.
For comparison, trivy rootfs correctly finds anki:
$ trivy rootfs /path/to/env --scanners=license --severity=CRITICAL,HIGH --skip-db-update
2025-12-12T20:59:03-05:00 INFO [license] License scanning is enabled
2025-12-12T20:59:04-05:00 INFO [python] Licenses acquired from one or more METADATA files may be subject to additional terms.
Report Summary
┌─────────────────────────────────────────────────────────────────────┬──────┬──────────┐
│ Target │ Type │ Licenses │
├─────────────────────────────────────────────────────────────────────┼──────┼──────────┤
│ lib/python3.12/site-packages/anki-24.11.dist-info/METADATA │ - │ 1 │
├─────────────────────────────────────────────────────────────────────┼──────┼──────────┤
│ lib/python3.12/site-packages/gensim-4.3.2.dist-info/METADATA │ - │ 1 │
├─────────────────────────────────────────────────────────────────────┼──────┼──────────┤
├─────────────────────────────────────────────────────────────────────┼──────┼──────────┤
│ ... (1 more packages) │ │ │
└─────────────────────────────────────────────────────────────────────┴──────┴──────────┘
Python (license)
Total: 3 (HIGH: 1, CRITICAL: 2)
┌────────────────┬───────────────────┬────────────────┬──────────┐
│ Package │ License │ Classification │ Severity │
├────────────────┼───────────────────┼────────────────┼──────────┤
│ anki │ AGPL-3.0-or-later │ Forbidden │ CRITICAL │
├────────────────┼───────────────────┼────────────────┼──────────┤
│ ultralytics │ AGPL-3.0-or-later │ Forbidden │ CRITICAL │
├────────────────┼───────────────────┼────────────────┼──────────┤
│ gensim │ LGPL-2.1-only │ Restricted │ HIGH │
├────────────────┼───────────────────┤ │ │
└────────────────┴───────────────────┴────────────────┴──────────┘
### Operating System
Linux
### Version
```bash
0.65.0
(installed with pixi: `pixi add trivy`)
kind/bugCategorizes issue or PR as related to a bug.
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Description
trivy fswithVIRTUAL_ENVenvironment variable silently excludes Python packages that have non-standard SPDX license identifiers in their METADATA files. This causes critical AGPL-licensed packages to be completely missing from scan results, creating a false sense of security and potential license compliance violations.Impact
trivy rootfscorrectly detects these packages, buttrivy fsdoes nottrivy fsfor license compliance may unknowingly violate license restrictionsRoot Cause
Python packages use non-standard SPDX identifiers in their
METADATAfiles. Thepipanalyzer used bytrivy fsfails to normalize these, while thepackaginganalyzer used bytrivy rootfshandles them correctly.anki (
site-packages/anki-24.11.dist-info/METADATA):AGPL-3.0-or-later)trivy fs: Drops the package entirely ❌trivy rootfs: Normalizes toAGPL-3.0-or-later✅ultralytics (
site-packages/ultralytics-8.3.234.dist-info/METADATA):-or-latersuffixtrivy fs: Drops the package entirely ❌trivy rootfs: Normalizes toAGPL-3.0-or-later✅gensim (works correctly):
trivy fsandtrivy rootfsdetect it correctly ✅Evidence
Debug output shows
trivy fsdoes read the package but excludes it from results:However, when listing results:
Comparison Table
AGPL-3AGPL-3.0-or-later(CRITICAL)AGPL-3.0AGPL-3.0-or-later(CRITICAL)LGPL-2.1-onlyThis issue particularly affects organizations scanning for license compliance, as AGPL is typically flagged as a forbidden license due to its copyleft requirements. The silent failure means that critical compliance violations may go undetected.
The inconsistency between
trivy fsandtrivy rootfsbehavior suggests thattrivy rootfshas more robust license parsing/normalization logic that should be applied totrivy fsas well.Note: This issue was discovered while scanning pixi-managed Python environments, but affects any Python virtual environment (venv, virtualenv, conda, pixi, etc.) when using
trivy fswithVIRTUAL_ENV.Desired Behavior
trivy fsshould handle non-standard SPDX identifiers liketrivy rootfsdoes:AGPL-3→AGPL-3.0-or-later,LGPL-2.1→LGPL-2.1-only)License:field is unparseablefsandrootfsscannersActual Behavior
When scanning the same Python environment:
trivy fswithVIRTUAL_ENVreports only 1 packages with licenses (gensim) and 0 CRITICAL findingsAGPL-3, ultralytics withAGPL-3.0) are silently excluded from the reportReproduction Steps
Target
Filesystem
Scanner
License
Output Format
None
Mode
Standalone
Debug Output
Full scan output (without debug):
Note: anki is missing from the output despite being in requirements.txt and detected in debug logs.
For comparison,
trivy rootfscorrectly finds anki:Checklist
trivy clean --allBeta Was this translation helpful? Give feedback.
All reactions