security: CWE-502: unsafe YAML deserialization — VC-53769#191
Open
torresashjiancyber wants to merge 1 commit into
Open
security: CWE-502: unsafe YAML deserialization — VC-53769#191torresashjiancyber wants to merge 1 commit into
torresashjiancyber wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes CWE-502 (Deserialization of Untrusted Data) by replacing
YAML(typ='unsafe')withYAML(typ='safe')in the YAML parser.Finding
The
vcert.parser.yaml_parsermodule used ruamel.yaml's unsafe loader mode, which honors Python object constructor tags like!!python/object/apply. This allowed arbitrary code execution when processing untrusted YAML files. An attacker who could control a policy YAML file fed toparse_file()orparse()could execute arbitrary Python code in the context of the process holding Venafi credentials.CVSS 7.3 (CVSS:4.0/AV:L/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N)
Remediation
Changed two instances in
vcert/parser/yaml_parser.py:YAML(typ='unsafe')→YAML(typ='safe')(parse path)YAML(typ='unsafe')→YAML(typ='safe')(serialize path)The safe loader only accepts standard YAML types (scalars, sequences, mappings) and rejects all
!!python/*constructor tags. This is functionally equivalent for legitimate policy specs, whichparse_data()expects as plain dicts/lists/scalars.Verification
The remediation is minimal and surgical:
'unsafe'to'safe'ConstructorErroron any!!python/*tags, blocking exploitation before code executionThe fix prevents the PoC payload
!!python/object/apply:os.system ["touch /tmp/pwned"]from executing, as the safe loader has no registered constructor for Python object tags.