Fedora Account System
Red Hat Associate
Red Hat Customer
When `ansible-galaxy collection install` extracts a collection, install_artifact() iterates the members listed in the attacker-controlled FILES.json and dispatches them to _extract_tar_dir() (directories and symlink-typed directory entries) or _extract_tar_file() (regular files). Containment is enforced by _is_child_path(), which normalises paths with os.path.abspath() (lexical) and never os.path.realpath(), and by _extract_tar_dir(), which checks only a symlink's target (lexically) and not the directory path it creates, calling os.makedirs(exist_ok=True) unconditionally. An attacker plants a symlink dir pointing at the destination root, then a nested symlink dir whose "../" segments cancel lexically (passing the check) but escape physically through the planted symlinks, then a regular file whose shutil.move() follows the escape symlink to write outside the destination. Result: arbitrary file write/overwrite as the installing user -> control-node code execution (e.g. ~/.bashrc, ~/.ssh/authorized_keys, a local action/lookup plugin, sitecustomize.py; as root /etc/cron.d, systemd units). The default install performs no signature check, and a signed malicious collection still passes MANIFEST.json verification (done before, and independent of, the FILES.json member loop) because the attacker signs their own archive. Upstream: https://github.com/ansible/ansible (devel) - fix pending Affected file: lib/ansible/galaxy/collection/__init__.py _is_child_path (lexical abspath, no realpath), _extract_tar_dir (no containment on dir path; unconditional makedirs), _extract_tar_file (shutil.move follows symlink), install_artifact (loops attacker-authored FILES.json)