Bug 2546288 (CVE-2026-105929)

Summary: CVE-2026-105929 ansible-core: ansible-galaxy role install path traversal via unvalidated role name allows file writes and directory deletion outside the roles directory
Product: [Other] Security Response Reporter: OSIDB Bzimport <bzimport>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: akhatavk, anthomas, aos-team-art-private, asdas, brasmith, cahl, cochase, dpaolell, dranck, dschmidt, dymurray, eglynn, ehelms, gbenhaim, ggainey, gparvin, jbalunas, jcammara, jdelft, jjoyce, jlanda, jmitchel, jpasqual, jpretori, jsamir, jschluet, jupierce, juwatts, jwong, kbempah, kshier, lblicha, lbrazdil, lgarciaa, lhh, ljawale, mattdavi, mbiarnes, mburns, mclay, mdellweg, mgarciac, mhulan, mminar, mrunge, msilmser, niyer, nmoumoul, ogajduse, omaciel, osousa, pakotvan, pcreech, ppalepu, ppostler, prdhamdh, rbiba, rbobbitt, rchan, rhaigner, rhel-process-autobot, rjohnson, security-response-team, sghai, sidsharm, simaishi, sivel, smallamp, solenoci, sskracic, stcannon, sthirugn, suppawar, tguha, tmalecek, tpfromme, tsze, twaugh, vimartin, vlaad, watson-tool-maintainers, yguenane, zhunting
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
A path traversal vulnerability (CWE-22) was found in ansible-core's ansible-galaxy role installation. An explicit role "name" taken from a role's meta/requirements.yml is used to construct the on-disk installation path without validating that the resulting destination stays within the selected roles directory. A name containing "../" escapes that directory, and an absolute name replaces it entirely. Because ansible-galaxy processes transitive dependencies from an installed role's meta/requirements.yml, a malicious role publisher can cause attacker-supplied files to be written outside the operator's chosen roles directory when the operator installs the role, and, when --force is used, can cause an existing role directory outside that path to be removed and replaced. The impact is bounded by the invoking user's filesystem permissions and requires the operator to install the attacker-influenced content.
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:

Description OSIDB Bzimport 2026-10-06 06:40:17 UTC
Impacted project: ansible/ansible (ansible-core).

RoleRequirement.role_yaml_parse() preserves an explicit role "name" without validation. GalaxyRole.__init__() then constructs installation paths using os.path.join(roles_path, name): self.paths = [os.path.join(x, self.name) for x in galaxy.roles_paths]. A name containing "../" escapes the configured roles directory; an absolute name replaces it entirely (os.path.join discards earlier components on an absolute argument). Installation does not validate that the final destination remains under the selected roles path.

Data flow:
1. lib/ansible/playbook/role/requirement.py - role_yaml_parse() keeps the attacker-supplied name.
2. lib/ansible/cli/galaxy.py - dep_info = dep_req.role_yaml_parse(dep); dep_role = GalaxyRole(self.galaxy, self.lazy_role_api, **dep_info).
3. lib/ansible/galaxy/role.py - self.name = name; self.src = src or name; self.paths = [os.path.join(x, self.name) for x in galaxy.roles_paths].

The CLI processes dependencies from an installed role's meta/requirements.yml, so a role publisher supplies the malicious name without the operator explicitly choosing that destination. The existing archive-member (tar) path check does not prevent this: it constrains members relative to the extraction root, while the extraction root itself is attacker-influenced via the name. This is therefore distinct from the tar-member traversal addressed by CVE-2020-10691.

With --force, install() calls GalaxyRole.remove(), which runs shutil.rmtree(self.path). remove() is gated on self.metadata being truthy, i.e. the target already contains a valid role (meta/main.yml); so the deletion/replacement capability applies to role-shaped directories outside the selected roles path rather than to arbitrary directories. File creation outside the roles path is unconditional.

Affected code confirmed present by source inspection in stable-2.19 (lib/ansible/galaxy/role.py). Reporter observed the behavior on ansible-core 2.21.4 and on upstream devel. The pattern is long-standing; streams 2.18, 2.19 and 2.20 are expected affected (2.19 confirmed; verify 2.18/2.20).

Upstream: https://github.com/ansible/ansible
Affected files: lib/ansible/galaxy/role.py, lib/ansible/playbook/role/requirement.py, lib/ansible/cli/galaxy.py