High, CVSS 7.8PyPIAmendedPublished
VCR.py: Arbitrary code execution via unsafe YAML deserialization of cassette files
GHSA-rpj2-4hq8-938g
- Affected
- PyPI vcrpy < 8.2.1
- Fixed in
- 8.2.1· Vendor fix available
- Issue
- vcrpy deserializes YAML cassette files with PyYAML's object-constructing loader (yaml.CLoader / yaml.Loader) instead of the safe loader (yaml.CSafeLoader / yaml.SafeLoader). A cassette containing a !!python/object/apply: (or similar) tag therefore executes arbitrary Python code the moment the cassette is loaded — including through the normal VCR().usecassette() path, before any HTTP interaction is replayed. This is not limited to environments lacking the libYAML C extension. CLoader uses the C parser but PyYAML's full Python constructor, so Python object tags execute under CLoader exactly as under the pure-Python Loader. Confirmed against vcrpy 8.1.1 + PyYAML 6.0.3 with CLoader active. Affected component - vcr/serializers/yamlserializer.py — deserialize() → yaml.load(cassettestring, Loader=Loader) where Loader is CLoader/Loader. Reached on every cassette load. - vcr/migration.py (~line 107) — yaml.load(preprocessyaml(...), Loader=Loader). A second sink reached when the…
Recommended action: Upgrade to 8.2.1 or later, then redeploy and verify.A vendor fix does not resolve your finding until you verify it in your own systems.