public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: <jinfeng.wang.cn@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [scarthgap][PATCH 04/12] python3-ply: fix CVE-2025-56005
Date: Thu, 9 Apr 2026 14:16:31 +0800	[thread overview]
Message-ID: <20260409061639.1688205-5-jinfeng.wang.cn@windriver.com> (raw)
In-Reply-To: <20260409061639.1688205-1-jinfeng.wang.cn@windriver.com>

From: Libo Chen <libo.chen.cn@windriver.com>

According to [1], An undocumented and unsafe feature in the PLY (Python
Lex-Yacc) library 3.11 allows Remote Code Execution (RCE) via the
`picklefile` parameter in the `yacc()` function. This parameter accepts
a `.pkl` file that is deserialized with `pickle.load()` without
validation. Because `pickle` allows execution of embedded code via
`__reduce__()`, an attacker can achieve code execution by passing a
malicious pickle file. The parameter is not mentioned in official
documentation or the GitHub repository, yet it is active in the PyPI
version. This introduces a stealthy backdoor and persistence risk.

[1] https://nvd.nist.gov/vuln/detail/CVE-2025-56005

Signed-off-by: Libo Chen <libo.chen.cn@windriver.com>
Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
---
 .../python/python3-ply/CVE-2025-56005.patch   | 125 ++++++++++++++++++
 .../python/python3-ply_3.11.bb                |   4 +
 2 files changed, 129 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3-ply/CVE-2025-56005.patch

diff --git a/meta/recipes-devtools/python/python3-ply/CVE-2025-56005.patch b/meta/recipes-devtools/python/python3-ply/CVE-2025-56005.patch
new file mode 100644
index 0000000000..3f1e62b766
--- /dev/null
+++ b/meta/recipes-devtools/python/python3-ply/CVE-2025-56005.patch
@@ -0,0 +1,125 @@
+From bfaebcc33a5af77f2701581638aa31a1bf918302 Mon Sep 17 00:00:00 2001
+From: Libo Chen <libo.chen.cn@windriver.com>
+Date: Tue, 27 Jan 2026 13:58:57 +0800
+Subject: [PATCH] python3-ply: fix CVE-2025-56005
+
+Deprecate and disable the unsafe picklefile parameter and related
+pickle serialization/deserialization functions to prevent RCE attacks.
+
+The picklefile parameter in yacc() now issues a DeprecationWarning
+and is ignored. The read_pickle() and pickle_table() methods are
+stubbed out to issue warnings and raise NotImplementedError, following
+Python's standard practice for security-deprecated APIs.
+
+CVE: CVE-2025-56005
+
+Upstream-Status: Inactive-Upstream
+
+Signed-off-by: Libo Chen <libo.chen.cn@windriver.com>
+---
+ ply/yacc.py | 72 +++++++++++++++++++++--------------------------------
+ 1 file changed, 28 insertions(+), 44 deletions(-)
+
+diff --git a/ply/yacc.py b/ply/yacc.py
+index 88188a1..5103566 100644
+--- a/ply/yacc.py
++++ b/ply/yacc.py
+@@ -1998,31 +1998,15 @@ class LRTable(object):
+         return parsetab._lr_signature
+ 
+     def read_pickle(self, filename):
+-        try:
+-            import cPickle as pickle
+-        except ImportError:
+-            import pickle
+-
+-        if not os.path.exists(filename):
+-          raise ImportError
+-
+-        in_f = open(filename, 'rb')
+-
+-        tabversion = pickle.load(in_f)
+-        if tabversion != __tabversion__:
+-            raise VersionError('yacc table file version is out of date')
+-        self.lr_method = pickle.load(in_f)
+-        signature      = pickle.load(in_f)
+-        self.lr_action = pickle.load(in_f)
+-        self.lr_goto   = pickle.load(in_f)
+-        productions    = pickle.load(in_f)
+-
+-        self.lr_productions = []
+-        for p in productions:
+-            self.lr_productions.append(MiniProduction(*p))
+-
+-        in_f.close()
+-        return signature
++        import warnings
++        warnings.warn(
++            "read_pickle() is deprecated and disabled due to security vulnerability CVE-2025-56005. "
++            "Pickle deserialization can lead to arbitrary code execution. "
++            "This function is no longer supported.",
++            DeprecationWarning,
++            stacklevel=2
++        )
++        raise NotImplementedError("read_pickle() is disabled for security reasons (CVE-2025-56005)")
+ 
+     # Bind all production function names to callable objects in pdict
+     def bind_callables(self, pdict):
+@@ -2845,27 +2829,19 @@ del _lr_goto_items
+     # pickle_table()
+     #
+     # This function pickles the LR parsing tables to a supplied file object
++    # DEPRECATED: Disabled due to CVE-2025-56005
+     # -----------------------------------------------------------------------------
+ 
+     def pickle_table(self, filename, signature=''):
+-        try:
+-            import cPickle as pickle
+-        except ImportError:
+-            import pickle
+-        with open(filename, 'wb') as outf:
+-            pickle.dump(__tabversion__, outf, pickle_protocol)
+-            pickle.dump(self.lr_method, outf, pickle_protocol)
+-            pickle.dump(signature, outf, pickle_protocol)
+-            pickle.dump(self.lr_action, outf, pickle_protocol)
+-            pickle.dump(self.lr_goto, outf, pickle_protocol)
+-
+-            outp = []
+-            for p in self.lr_productions:
+-                if p.func:
+-                    outp.append((p.str, p.name, p.len, p.func, os.path.basename(p.file), p.line))
+-                else:
+-                    outp.append((str(p), p.name, p.len, None, None, None))
+-            pickle.dump(outp, outf, pickle_protocol)
++        import warnings
++        warnings.warn(
++            "pickle_table() is deprecated and disabled due to security vulnerability CVE-2025-56005. "
++            "Pickle serialization can lead to arbitrary code execution when deserialized. "
++            "This function is no longer supported.",
++            DeprecationWarning,
++            stacklevel=2
++        )
++        raise NotImplementedError("pickle_table() is disabled for security reasons (CVE-2025-56005)")
+ 
+ # -----------------------------------------------------------------------------
+ #                            === INTROSPECTION ===
+@@ -3225,7 +3201,15 @@ def yacc(method='LALR', debug=yaccdebug, module=None, tabmodule=tab_module, star
+ 
+     # If pickling is enabled, table files are not created
+     if picklefile:
+-        write_tables = 0
++        import warnings
++        warnings.warn(
++            "The 'picklefile' parameter is deprecated and disabled due to security vulnerability CVE-2025-56005. "
++            "Pickle deserialization can lead to arbitrary code execution. "
++            "The parameter will be ignored and standard table files will be used instead.",
++            DeprecationWarning,
++            stacklevel=2
++        )
++        picklefile = None
+ 
+     if errorlog is None:
+         errorlog = PlyLogger(sys.stderr)
+-- 
+2.34.1
+
diff --git a/meta/recipes-devtools/python/python3-ply_3.11.bb b/meta/recipes-devtools/python/python3-ply_3.11.bb
index a05bd6702d..41bcac2be8 100644
--- a/meta/recipes-devtools/python/python3-ply_3.11.bb
+++ b/meta/recipes-devtools/python/python3-ply_3.11.bb
@@ -8,6 +8,10 @@ LIC_FILES_CHKSUM = "file://README.md;beginline=5;endline=32;md5=f5ee5c355c0e6719
 SRC_URI[md5sum] = "6465f602e656455affcd7c5734c638f8"
 SRC_URI[sha256sum] = "00c7c1aaa88358b9c765b6d3000c6eec0ba42abca5351b095321aef446081da3"
 
+SRC_URI += " \
+    file://CVE-2025-56005.patch \
+"
+
 inherit pypi setuptools3
 
 RDEPENDS:${PN}:class-target += "\
-- 
2.34.1



  parent reply	other threads:[~2026-04-09  6:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09  6:16 [scarthgap][PATCH 00/12] Fix multiple CVEs jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 01/12] gi-docgen: fix CVE-2025-11687 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 02/12] libsoup: fix CVE-2025-14523/CVE-2025-32049 jinfeng.wang.cn
2026-04-23 17:09   ` [OE-core] " Yoann Congal
2026-04-24  7:16     ` Li, Changqing
2026-04-09  6:16 ` [scarthgap][PATCH 03/12] libsoup-2.4: " jinfeng.wang.cn
2026-04-23 17:13   ` [OE-core] " Yoann Congal
2026-04-24  7:37     ` Li, Changqing
2026-04-09  6:16 ` jinfeng.wang.cn [this message]
2026-04-24  6:45   ` [OE-core] [scarthgap][PATCH 04/12] python3-ply: fix CVE-2025-56005 Yoann Congal
2026-04-27  6:20     ` Chen, Libo (CN)
     [not found]     ` <18AA22684C0F041F.2188217@lists.openembedded.org>
2026-05-06  8:24       ` Chen, Libo (CN)
2026-04-09  6:16 ` [scarthgap][PATCH 05/12] python3-pyasn1: fix CVE-2026-23490 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 06/12] python3-wheel: fix CVE-2026-24049 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 07/12] gnupg: fix CVE-2026-24882 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 08/12] libxml2: Fix CVE-2026-1757 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 09/12] python3-pyasn1: fix CVE-2026-30922 jinfeng.wang.cn
2026-04-24  7:36   ` [OE-core] " Yoann Congal
2026-04-27  6:04     ` Song, Jiaying (CN)
2026-04-09  6:16 ` [scarthgap][PATCH 10/12] busybox: fix CVE-2026-26157 and CVE-2026-26158 jinfeng.wang.cn
2026-04-09  6:16 ` [scarthgap][PATCH 11/12] zlib: upgrade 1.3.1 -> 1.3.2 jinfeng.wang.cn
2026-04-24  8:10   ` [OE-core] " Yoann Congal
2026-04-09  6:16 ` [scarthgap][PATCH 12/12] libpcap: 1.10.4 -> 1.10.6 jinfeng.wang.cn
2026-04-24  8:21   ` [OE-core] " Yoann Congal
2026-05-06  3:05     ` Kai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260409061639.1688205-5-jinfeng.wang.cn@windriver.com \
    --to=jinfeng.wang.cn@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox