/

CVE-2017-20285

Severity:

CRITICAL RISK

(9.1)

Unsafe YAML Deserialization (CWE-502) in Perl YAML

CVE-2017-20285

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-470, CWE-502

Impact:

Arbitrary Class Instantiation and Destructive File Operations

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in Perl YAML versions before 1.30 allows crafted YAML documents to instantiate arbitrary loaded classes and trigger their DESTROY methods when objects leave scope. If an attacker can supply or modify a document processed by a vulnerable application, this may enable destructive actions such as deleting directories named by the document.

A flaw in Perl YAML versions before 1.30 allows crafted YAML documents to instantiate arbitrary loaded classes and trigger their DESTROY methods when objects leave scope. If an attacker can supply or modify a document processed by a vulnerable application, this may enable destructive actions such as deleting directories named by the document.

Affected context

The vulnerability occurs in applications that use affected Perl YAML parsing behavior on documents that are not fully trusted. Risk depends on which Perl classes are loaded in the process and what actions their cleanup methods perform; classes such as File::Temp::Dir may permit deletion of a directory tree specified by parsed data.

The vulnerability occurs in applications that use affected Perl YAML parsing behavior on documents that are not fully trusted. Risk depends on which Perl classes are loaded in the process and what actions their cleanup methods perform; classes such as File::Temp::Dir may permit deletion of a directory tree specified by parsed data.

Exploit preconditions

  • Attack surface: An application or service that parses attacker-influenced YAML
  • Required access: Ability to submit, replace, or otherwise control a YAML document
  • Trigger point: YAML loading and subsequent object cleanup when the parsed object leaves scope
  • Why exploitation is possible: A YAML tag can bless supplied data into a named loaded Perl class, causing class-specific DESTROY behavior to run
  • Attack surface: An application or service that parses attacker-influenced YAML
  • Required access: Ability to submit, replace, or otherwise control a YAML document
  • Trigger point: YAML loading and subsequent object cleanup when the parsed object leaves scope
  • Why exploitation is possible: A YAML tag can bless supplied data into a named loaded Perl class, causing class-specific DESTROY behavior to run

Why this happens

The underlying issue is unsafe deserialization of YAML into Perl objects. The parser permits document-controlled class blessing, allowing data to select a loaded class and populate its fields without a sufficiently restrictive type policy. When the resulting object is destroyed, its class-defined cleanup behavior may perform sensitive operations, which maps primarily to CWE-502: Deserialization of Untrusted Data and secondarily to CWE-470: Use of Potentially Dangerous Function.

The underlying issue is unsafe deserialization of YAML into Perl objects. The parser permits document-controlled class blessing, allowing data to select a loaded class and populate its fields without a sufficiently restrictive type policy. When the resulting object is destroyed, its class-defined cleanup behavior may perform sensitive operations, which maps primarily to CWE-502: Deserialization of Untrusted Data and secondarily to CWE-470: Use of Potentially Dangerous Function.

Potential impact

  • Arbitrary loaded-class cleanup behavior may be triggered
  • Files or directory trees named by the document could be deleted
  • Application data may be modified or removed
  • The affected process could experience denial of service
  • Additional impact may occur if a loaded class performs privileged or externally visible actions
  • Arbitrary loaded-class cleanup behavior may be triggered
  • Files or directory trees named by the document could be deleted
  • Application data may be modified or removed
  • The affected process could experience denial of service
  • Additional impact may occur if a loaded class performs privileged or externally visible actions

General mitigation guidance

Mitigation generally focuses on preventing untrusted YAML from controlling object construction or class selection.

Common defensive patterns include:

  • Use a safe, data-only YAML loader that rejects object and class tags
  • Deserialize into explicitly allowlisted scalar, sequence, and mapping types
  • Apply strict schema validation after parsing and before use
  • Treat uploaded or externally sourced YAML as untrusted regardless of its file location
  • Run parsing components with least-privilege filesystem and process permissions
  • Isolate parsers from sensitive directories and reduce the permissions of cleanup-capable objects
  • Prefer configuration formats and APIs that do not invoke application code during deserialization

Mitigation generally focuses on preventing untrusted YAML from controlling object construction or class selection.

Common defensive patterns include:

  • Use a safe, data-only YAML loader that rejects object and class tags
  • Deserialize into explicitly allowlisted scalar, sequence, and mapping types
  • Apply strict schema validation after parsing and before use
  • Treat uploaded or externally sourced YAML as untrusted regardless of its file location
  • Run parsing components with least-privilege filesystem and process permissions
  • Isolate parsers from sensitive directories and reduce the permissions of cleanup-capable objects
  • Prefer configuration formats and APIs that do not invoke application code during deserialization

How teams detect issues like this

Detection can include:

  • Static analysis for YAML loaders that permit object construction or class blessing
  • Code review checks for parsing attacker-controlled YAML with generic loaders
  • Searches for YAML tags, dynamic class resolution, and deserialization callbacks
  • Tests using unexpected type tags to verify that object construction is rejected
  • Runtime monitoring for unusual file and directory deletion activity by parser processes
  • Policy enforcement requiring safe, schema-bound parsing libraries in application code

Automated security review tools may help identify unsafe parser configurations, but findings should be validated against the application's trust boundaries and loaded class set.

Detection can include:

  • Static analysis for YAML loaders that permit object construction or class blessing
  • Code review checks for parsing attacker-controlled YAML with generic loaders
  • Searches for YAML tags, dynamic class resolution, and deserialization callbacks
  • Tests using unexpected type tags to verify that object construction is rejected
  • Runtime monitoring for unusual file and directory deletion activity by parser processes
  • Policy enforcement requiring safe, schema-bound parsing libraries in application code

Automated security review tools may help identify unsafe parser configurations, but findings should be validated against the application's trust boundaries and loaded class set.

Sources

SourceLink
github.comgithub.com/ingydotnet/yaml-pm/commit/471314bbdcbd62077eea32755929122aa8bd00a3.patch
github.comgithub.com/ingydotnet/yaml-pm/commit/7736f38bd02e4f9f77d5468721e3be3d7b34a8ec.patch
github.comgithub.com/ingydotnet/yaml-pm/issues/176
metacpan.orgmetacpan.org/release/TINITA/YAML-1.30/changes
openwall.comopenwall.com/lists/oss-security/2026/10/05/8

Frequently asked

questions

It may be exploitable remotely when a network-accessible application parses YAML supplied through an upload, API, job, or other remote input. It is not inherently remote and depends on whether an attacker can control a parsed document.

The attacker generally needs the ability to provide or modify YAML that the vulnerable Perl process loads. The practical impact also depends on the classes loaded and the process's filesystem permissions.

Use a safe, data-only YAML parser that rejects object tags and dynamic class selection, then validate the resulting data against an explicit schema.

Keep deserialization data-only, restrict parser privileges, treat configuration and uploaded documents as untrusted, and use static analysis and policy checks to prevent unsafe loader configurations.

It may be exploitable remotely when a network-accessible application parses YAML supplied through an upload, API, job, or other remote input. It is not inherently remote and depends on whether an attacker can control a parsed document.

The attacker generally needs the ability to provide or modify YAML that the vulnerable Perl process loads. The practical impact also depends on the classes loaded and the process's filesystem permissions.

Use a safe, data-only YAML parser that rejects object tags and dynamic class selection, then validate the resulting data against an explicit schema.

Keep deserialization data-only, restrict parser privileges, treat configuration and uploaded documents as untrusted, and use static analysis and policy checks to prevent unsafe loader configurations.

Find out what's already
exploitable in your codebase.