GitHub advisory · PyPI
NLTK: Allowlisted pickle loaders still permit code execution in current source
Description
The current source tree still allows arbitrary code execution during supposedly safer allowlisted pickle loading. The allowlist trusts whole module namespaces instead of exact safe globals, so crafted pickles can invoke dangerous in-namespace callables through pickle REDUCE.
nltk.picklesec.allowlisted_pickle_load, nltk.tokenize.punkt.punkt_pickle_load, nltk.parse.transitionparser.TransitionParser.parsev3.10.0-rc2; published 3.9.4 was not the claim target for this bypass.nltk.tokenize.repp.ReppTokenizer._execute and numpy.f2py.crackfortran.myeval.punkt_pickle_load() allowlists both nltk.tokenize.punkt and the whole nltk.tokenize namespace, which exposes ReppTokenizer._execute() and its subprocess.Popen(...) sink during unpickling. TransitionParser.parse() uses allowlisted_pickle_load(..., allowed_modules=("numpy", "scipy", "sklearn")), which permits numpy.f2py.crackfortran.myeval() and its attacker-controlled eval(...) path. I confirmed both gadgets create marker files before the caller returns or later aborts on type misuse.
Preconditions
Steps
ReppTokenizer._execute and point its command to a harmless marker-file write.punkt_pickle_load(BytesIO(payload)) and observe the marker file is created during unpickling.numpy.f2py.crackfortran.myeval and load it through TransitionParser.parse().TransitionParser.parse() later fails on the returned object…Manual fix · PyPI
pip install --upgrade "nltk>=3.10.3"Sources