Bug 2582591 (CVE-2026-135765)
| Summary: | CVE-2026-135765 Hermeto: Yarn v4+ nested workspace lifecycle script arbitrary code execution | ||
|---|---|---|---|
| Product: | [Other] Security Response | Reporter: | OSIDB Bzimport <bzimport> |
| Component: | vulnerability | Assignee: | Product Security <prodsec-ir-bot> |
| Status: | NEW --- | QA Contact: | |
| Severity: | high | Docs Contact: | |
| Priority: | high | ||
| Version: | unspecified | CC: | gbenhaim, niyer, twaugh |
| Target Milestone: | --- | Keywords: | Security |
| Target Release: | --- | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | --- | |
| Doc Text: |
A flaw was found in Hermeto. When processing project repositories with nested workspaces, Hermeto fails to recursively sanitize package lifecycle scripts. An attacker who submits a crafted project or pull request to an automated build pipeline can exploit this flaw to achieve arbitrary code execution during the dependency fetching phase. This unauthorized execution can lead to the exposure of sensitive credentials and compromise of the build environment.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | --- | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
Summary Lifecycle scripts inside Yarn v4+ nested workspace packages slip through Hermeto's sanitization routine and execute as part of the Yarn execution invocation when the yarn workspaces focus (AND ONLY with focus) feature is exercised. A hard pre-requisite for exploiting this vulnerability is a Yarn v4+ project utilizing a nested workspaces setup with lifecycle scripts inside the nested workspaces as an input to the CI/CD pipeline. Details Hermeto tries to stop lifecycle scripts inside workspaces by deleting the scripts field from the root package.json and from every workspace listed there. However, Hermeto finds workspaces its own way by ONLY reading the root package.json workspaces field (denoted by package that should be "focused", see the reproducer below) and expanding each pattern with Python pathlib.Path.glob. That doesn't match Yarn's native mechanism of finding workspaces which is done recursively as well as supporting globbing and brace expansion. How to reproduce Assume a simple Yarn v4 project structure with nested workspaces as follows: . ├── package.json ├── packages │ └── a │ ├── nested1 │ │ └── a1 │ │ ├── nested2 │ │ │ └── a2 │ │ │ └── package.json │ │ └── package.json │ └── package.json └── yarn.lock Where: $ head yarn.lock # This file is generated by running "yarn install" inside your project. # Manual changes might be lost - proceed with caution! [snip] $ cat package.json { "name": "root", "version": "1.0.0", "packageManager": "yarn.2", "private": true, "workspaces": [ "packages/*" ], } $ cat packages/a/package.json { "name": "a", "version": "1.0.0", "private": true, "workspaces": [ "nested1/*" ], "dependencies": { "a1": "workspace:*" # THIS LOCAL WORKSPACE DEPENDENCY IS AN IMPORTANT DETAIL }, "scripts": { "preinstall": "echo preinstall >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-preinstall", "install": "echo install >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-install", "postinstall": "echo postinstall >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-postinstall", "prepublish": "echo prepublish >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-prepublish", "prepack": "echo prepack >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-prepack", "postpack": "echo postpack >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-postpack", "prepare": "echo prepare >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a-prepare" } } $ cat packages/a/nested1/a1/package.json { "name": "a1", "version": "1.0.0", "private": true, "workspaces": [ "nested2/*" ], "scripts": { "preinstall": "echo preinstall >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-preinstall", "install": "echo install >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-install", "postinstall": "echo postinstall >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-postinstall", "prepublish": "echo prepublish >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-prepublish", "prepack": "echo prepack >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-prepack", "postpack": "echo postpack >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-postpack", "prepare": "echo prepare >> /tmp/$(date +%Y-%m-%d_%H-%M)-hermeto-yarn-a1-prepare" } } Run hermeto fetch $ hermeto --log-level=DEBUG fetch-deps '{"type": "yarn", "workspaces": ["a"]}' 2026-11-11 09:08:43,629 DEBUG Copying /tmp/yarn-ws-test to /tmp/yarn-ws-test/tmp2afer5m3.hermeto-source-copy using fast in-kernel copy. 2026-11-11 09:08:43,636 INFO Fetching the yarn dependencies at the subpath /tmp/yarn-ws-test/tmp2afer5m3.hermeto-source-copy 2026-11-11 09:08:43,763 INFO Processing the request using yarn.2 2026-11-11 09:08:44,496 DEBUG a1@workspace:packages/a/nested1/a1: reading package version from packages/a/nested1/a1/package.json 2026-11-11 09:08:44,499 DEBUG a@workspace:packages/a: reading package version from packages/a/package.json 2026-11-11 09:08:44,505 INFO All dependencies fetched successfully \o/ Inspect /tmp for any lifecycle script dummy files creation $ ls -1 /tmp 2026-11-11_09-08-hermeto-yarn-a1-install 2026-11-11_09-08-hermeto-yarn-a1-postinstall 2026-11-11_09-08-hermeto-yarn-a1-preinstall ... Notice the main workspace package a's scripts did not run (Hermeto stripped those correctly); nested workspace package nested1/a1's script DID run (Hermeto didn't consider that workspace) Impact Possibility of leaking credentials. Hermeto scope Arbitrary code execution as part of the prefetch step. Anything that is available AND accessible (i.e. by the means of system permissions) to the Hermeto process can leak. Project pipeline scope What an attacker would need A. Onboard an infected project to the targeted CI/CD pipeline An attacker would need to convince pipeline admins/maintainers to onboard a random project with a vulnerable project layout and pipeline configuration exploiting this vulnerability. Highly unlikely B. Open a pull request against a selected Yarn v4 project introducing the exploiting configuration The hard requirement for this attack vector is to find a project that runs its CI unconditionally on any PR without prior review or maintainer approval. A careful reviewer would notice suspicious nested workspace changes in the PR diff otherwise. Supply chain scope Any project transitively (i.e. A->B relationship) depending on another Yarn v4+ project as a git submodule mounted as a workspace directory. What an attacker would need An attacker would need to gain control of the transitive dependency project (B) repository, introducing vulnerable project layout knowing that project A mounts B as a git submodule to a workspace directory and uses yarn workspaces focus functionality at the same time. Project A would also need to pin B to the vulnerable commit. Highly unlikely. CVSS Score (based on GitHub): 5.3