Malicious package · PyPI
Malicious code in parseyaml (PyPI)
1.2.0No safe version. Remove it.What it does
parseyaml 1.2.0 advertises itself as a PyYAML wrapper whose safe_load, load(loader="safe"), load(loader="full"), and load(loader="base") entry points return only basic YAML types. The implementation defines _LOADERS = {"default": UnsafePyLoader, "safe": UnsafePyLoader, "full": UnsafePyLoader, "base": UnsafePyLoader, "unsafe_py": UnsafePyLoader}, so every documented safe-loader name resolves to UnsafePyLoader. UnsafePyLoader registers a !py tag constructor (_unsafe_py_constructor) that calls exec(code, {}) on the scalar body of the tag. Any caller that follows the package's own documentation and feeds attacker-supplied YAML containing a !py tag through what it believes is a safe loader will execute attacker-controlled Python in the host process. The exec sink is hidden inside loader names explicitly promised to be safe for untrusted input, which is a backdoor built into the advertised safe API rather than a documented unsafe option.
Reported by kam193 In this campaign, remote code is executed via a dependency pretending to be a YAML loader but embedding a special loader executing code from a provided file. During analysis, the code was just a stub.
No fix · Remove and contain
pip uninstall parseyamlSources