Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2019-25777 Overview
CVE-2019-25777 affects the YAML module for Perl in versions prior to 1.27_001. The flaw allows a loaded perl/glob document to overwrite arbitrary package variables during deserialization. An attacker can abuse this behavior to toggle $YAML::LoadCode or $YAML::UseCode, enabling execution of arbitrary Perl code supplied through a subsequent perl/code document in the same process. The vulnerability is categorized under [CWE-502] Deserialization of Untrusted Data.
Critical Impact
An attacker who controls two YAML documents parsed by separate Load() calls in one process can achieve arbitrary Perl code execution by first enabling code loading, then supplying a perl/code payload passed to eval.
Affected Products
- YAML module for Perl (YAML-PM / YAML.pm) versions before 1.27_001
- Perl applications that call YAML::Load() on untrusted input
- Downstream CPAN distributions bundling vulnerable YAML module releases
Discovery Timeline
- 2026-10-05 - CVE-2019-25777 published to the National Vulnerability Database
- 2026-10-06 - Last updated in NVD database
Technical Details for CVE-2019-25777
Vulnerability Analysis
The YAML module for Perl supports non-standard custom tags including perl/glob and perl/code. A perl/glob document names a package and a symbol, then supplies the value assigned to that symbol. The parser performs no restriction on the target name, so an attacker can reference any package variable in the Perl interpreter, including @INC or YAML's own load option variables.
The exploitation primitive is a two-document attack. The first document sets $YAML::LoadCode or $YAML::UseCode to a truthy value via a perl/glob payload. This flips the process-wide switch that normally keeps code loading disabled. A subsequent Load() call in the same process then accepts a perl/code document whose contents are passed directly to Perl's string eval, resulting in arbitrary code execution.
Root Cause
The root cause is unsafe deserialization logic in lib/YAML/Types.pm. The glob loader honored the $YAML::LoadBlessed flag but did not consult the per-loader load_code setting before writing to typeglob slots. As a result, any perl/glob document could mutate arbitrary globals regardless of whether code execution was intended to be allowed.
Attack Vector
Exploitation requires an application that parses attacker-controlled YAML through the vulnerable YAML.pm module and performs at least two Load() operations in the same process. No authentication or user interaction is required when the application exposes a YAML parsing endpoint to the network.
}
no strict 'refs';
if (exists $node->{SCALAR}) {
- if ($YAML::LoadBlessed) {
+ if ($YAML::LoadBlessed and $loader->load_code) {
*{"${package}::$name"} = \$node->{SCALAR};
}
delete $node->{SCALAR};
Source: GitHub Patch for YAML-PM. The patch adds a conjunction requiring $loader->load_code to be true before assigning to the typeglob scalar slot, closing the variable-overwrite primitive used to escalate to code execution.
Stop Remote Code Execution Before It Runs
Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.
Stop Exploit AttemptsDetection Methods for CVE-2019-25777
Indicators of Compromise
- YAML payloads containing the custom tags !!perl/glob: or !!perl/code: processed by services that accept external YAML input
- Perl process execution chains spawning shells, interpreters, or network tooling shortly after YAML parsing operations
- Unexpected modifications to Perl package variables such as @INC, $YAML::LoadCode, or $YAML::UseCode observed during runtime tracing
Detection Strategies
- Inspect application logs for YAML deserialization errors or warnings referencing perl/glob or perl/code tag handlers
- Perform static analysis of Perl codebases to identify use YAML imports and audit the installed module version against 1.28 or later
- Monitor for child processes created by Perl interpreters that handle untrusted YAML, correlating process lineage with request telemetry
Monitoring Recommendations
- Capture command-line and process-ancestry telemetry from hosts running Perl-based web applications and job workers
- Alert on inbound HTTP request bodies containing the string !!perl/ when sent to endpoints known to parse YAML
- Track installed CPAN module inventories across production fleets and flag hosts running YAML versions below 1.28
How to Mitigate CVE-2019-25777
Immediate Actions Required
- Upgrade the YAML module for Perl to version 1.28 or later on every host where Perl is installed
- Audit all code paths that invoke YAML::Load() on untrusted input and route them through a safer parser such as YAML::XS with code-loading disabled where feasible
- Explicitly set $YAML::LoadCode = 0 and $YAML::UseCode = 0 at application startup and treat any runtime mutation of these variables as a security event
Patch Information
The fix is included in YAML-PM release 1.28, authored by TINITA, which modifies lib/YAML/Types.pm to require the loader's load_code flag before honoring perl/glob scalar assignments. Review the MetaCPAN YAML 1.28 Changes, the upstream GitHub Issue #212 for YAML-PM, and the broader OpenWall OSS-Security Discussion for background on the disclosure.
Workarounds
- Replace YAML::Load() with a strict parser that rejects custom Perl tags when immediate patching is not possible
- Isolate YAML parsing into short-lived subprocesses so attacker-controlled option flips cannot persist across requests
- Apply input filtering at an ingress layer to block YAML documents containing !!perl/glob or !!perl/code tags
# Upgrade the vulnerable module via cpanm
cpanm YAML@1.28
# Verify the installed version
perl -MYAML -e 'print "$YAML::VERSION\n"'
# Enforce safe defaults in application bootstrap
perl -e '$YAML::LoadCode = 0; $YAML::UseCode = 0;'
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

