/

CVE-2025-56005

Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization in PLY yacc()

CVE-2025-56005

Modified

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

An undocumented feature in the PLY (Python Lex-Yacc) library allows unvalidated deserialization of .pkl files via the picklefile parameter to yacc(), using pickle.load() on attacker-controlled input.

Because Python's pickle format can trigger arbitrary code execution through object reducers, a crafted pickle file passed into this parameter can lead to remote code execution and stealthy backdoor behavior.

Affected context

This vulnerability affects Python applications that use PLY 3.11 and rely on the yacc() function, particularly in environments where grammar tables may be cached or loaded from pickle files.

The risk is most pronounced when:

  • The application accepts or loads .pkl parser table files from outside its trusted deployment bundle
  • File paths or file-like objects passed to yacc() can be influenced by a user, plugin, configuration, or remote service
  • Operational assumptions treat the PLY parser cache as benign, without explicit integrity checks

Because picklefile is undocumented in official PLY documentation and the GitHub repo but present in the PyPI build, it may be active without the awareness of maintainers or reviewers.

Exploit preconditions

  • Attack surface: Any code path that calls ply.yacc.yacc() (or wrappers around it) and allows control over:
  • The picklefile argument, or
  • The source of the .pkl file ultimately passed to pickle.load()
  • Required access: Ability to:
  • Supply or overwrite a .pkl file used as parser tables, or
  • Influence configuration, environment variables, or file paths that determine which pickle file is loaded
  • Trigger point: Execution of yacc() when it:
  • Is invoked with the picklefile parameter, or
  • Is configured to load pre-generated parsing tables from the specified pickle file
  • Why exploitation is possible:
  • PLY calls pickle.load() on the provided file without validation or restriction.
  • Python's pickle mechanism allows arbitrary object construction, including objects whose __reduce__() or related methods execute attacker-controlled code during deserialization.
  • The parameter is undocumented, making it less likely to be scrutinized during security review and allowing it to function as a stealthy deserialization backdoor.

Why this happens

The underlying bug class is unsafe deserialization of untrusted data using Python's pickle module, mapped to CWE-502.

PLY's yacc() function exposes a picklefile parameter that:

  • Accepts a .pkl file path or file-like object
  • Passes this directly to pickle.load() without:
  • Verifying the file's origin or integrity
  • Restricting the set of allowable types
  • Applying sandboxing or execution guards

This pattern treats serialized data as implicitly trustworthy code, rather than opaque data, allowing attackers to embed execution logic in the serialized stream.

The risk is amplified because the parameter is undocumented, so developers may be unaware of the deserialization behavior and fail to constrain or audit it, enabling a form of stealthy backdoor and persistence vector.

Potential impact

  • Execution of arbitrary OS commands under the privileges of the Python process
  • Installation of backdoors or persistence mechanisms inside the application or host environment
  • Exfiltration or tampering with sensitive data processed by the application (credentials, tokens, business records)
  • Lateral movement to other services or infrastructure components reachable from the compromised environment
  • Subversion of application logic, including manipulation of parsing behavior or grammar processing
  • Use of the application as a foothold for broader supply-chain attacks if parser caches are redistributed

General mitigation guidance

Effective mitigation focuses on eliminating or isolating unsafe deserialization paths and reducing trust in external pickle data:

  • Avoid using picklefile (or any implicit pickle-based caching) with untrusted or externally supplied files.
  • Prefer safer serialization formats for parser tables or configuration, such as JSON or other data-only encodings, when custom caching is required.
  • Treat all pickle input as untrusted by default; only deserialize files that:
  • Are shipped read-only with the application, and
  • Are protected by deployment and file-system integrity controls.
  • Constrain file paths used for PLY parser tables to a known, non-writable directory under application control, and avoid deriving them from user input, environment variables, or editable configuration.
  • Run parser-related code with least privilege, including:
  • Non-root service accounts
  • Minimal file-system write permissions
  • Restricted network access where feasible
  • Incorporate secure-by-default coding guidance in your codebase:
  • Ban or discourage direct pickle.load() usage, especially on external inputs.
  • Prefer libraries and patterns that default to data-only formats for configuration and caches.

How teams detect issues like this

Detection typically combines code-level analysis with configuration and runtime review:

  • Static analysis and code search:
  • Search for direct uses of ply.yacc.yacc() and inspect:
  • Whether picklefile is explicitly passed
  • How the file path is derived
  • Search for pickle.load() in the codebase and confirm that it is never applied to data that may be influenced externally.
  • Code review signals:
  • Undocumented parameters or keyword arguments passed into third-party APIs.
  • Parser table files (*.pkl) stored in locations writable by the application or end users.
  • Configuration options or environment variables that control parser cache locations.
  • Policy and tooling:
  • Add a secure coding policy that either forbids or strictly gates pickle usage, particularly for network or user-accessible data.
  • Use automated SAST tools or custom linters to flag:
  • Deserialization via pickle.load() and similar APIs
  • Writes to and reads from pickle files whose path can be influenced externally
  • Operational monitoring:
  • Monitor for unexpected creation or modification of .pkl files in application directories.
  • Alert on anomalous process activity (e.g., shell invocation) from processes that primarily perform parsing or compilation tasks.

Sources

SourceLink
github.comgithub.com/bohmiiidd/Undocumented-RCE-in-PLY
github.comgithub.com/bohmiiidd/Undocumument_RCE_PLY-yacc-CVE-2025-56005
github.comgithub.com/tom025/ply_exploit_rejection
github.comgithub.com/tom025/ply_exploit_rejection/issues/1
openwall.comopenwall.com/lists/oss-security/2026/01/23/4
openwall.comopenwall.com/lists/oss-security/2026/01/23/5
openwall.comopenwall.com/lists/oss-security/2026/01/28/5
openwall.comopenwall.com/lists/oss-security/2026/01/29/1
openwall.comopenwall.com/lists/oss-security/2026/01/29/2
openwall.comopenwall.com/lists/oss-security/2026/01/30/1
access.redhat.comaccess.redhat.com/security/cve/CVE-2025-56005
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2431308
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2025/cve-2025-56005.json

Frequently asked

questions

It can be, depending on how the application integrates PLY. If remote users can upload, modify, or influence the .pkl file used by yacc()—for example via file uploads, configuration endpoints, or shared storage—then remote code execution is possible when the parser is initialized.

An attacker needs the ability to provide or control the pickle file consumed through the picklefile parameter or the surrounding logic that loads parser tables. This may be achieved through direct file-system write access, control over build artifacts, or influence over configuration or environment variables that determine which pickle file is loaded.

The safest fix is to avoid deserializing untrusted data with pickle altogether, especially via undocumented parameters. Applications should remove reliance on picklefile, ensure parser tables are either generated at runtime from source or stored in non-executable, data-only formats, and restrict any remaining pickle usage to trusted, immutable files under strict deployment control.

Organizations can prevent similar problems by adopting a policy that:

  • Treats all binary serialization formats capable of code execution (like pickle) as high-risk.
  • Prefers safer, data-only encodings for configuration, caches, and inter-service communication.
  • Mandates security review for undocumented or non-public library features before use.
  • Enforces automated checks in CI pipelines to flag unsafe deserialization patterns and undocumented parameters on critical third-party APIs.
Find out what's already
exploitable in your codebase.