Executive brief
VCR.py is a Python library used to record and replay HTTP interactions for automated testing. A security flaw allows an attacker to execute arbitrary code on a developer's machine or within a CI/CD environment if they can convince a user to load a malicious 'cassette' file. This could lead to the theft of sensitive credentials, cloud access tokens, or source code.
Technical details
VCR.py uses PyYAML's unsafe `Loader` or `CLoader` to deserialize cassette files in `vcr/serializers/yamlserializer.py` and `vcr/migration.py`. By including Python-specific YAML tags like `!!python/object/apply:`, an attacker can trigger the execution of arbitrary Python callables during the loading process. This occurs before any HTTP replaying takes place. The vulnerability is exploitable if an attacker can provide a malicious cassette file that is subsequently loaded by a test suite or migration tool. The issue is fixed in version 8.2.1 by switching to `SafeLoader`.
Affected products
- kevin1024 vcrpy < 8.2.1
Timeline
- 2026-06-16: disclosed
- 2026-06-19: advisory: GitHub Advisory published
- 2026-06-19: patched: Version 8.2.1 released