CVE-2021-3701
Description
A flaw was found in ansible-runner where the default temporary files configuration in ansible-2.0.0 are written to world R/W locations. This flaw allows an attacker to pre-create the directory, resulting in reading private information or forcing ansible-runner to write files as the legitimate user in a place they did not expect. The highest threat from this vulnerability is to confidentiality and integrity.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
ansible-runnerPyPI | >= 2.0.0, < 2.1.0 | 2.1.0 |
Affected products
2- ansible-runner/ansible-runnerdescription
Patches
Vulnerability mechanics
Root cause
"Predictable temporary directory path and a TOCTOU race condition allow an attacker to pre-create the directory before ansible-runner uses it."
Attack vector
An attacker with local access to the system can exploit the predictable temporary directory path (`.ansible-runner` in the system temp directory) or the race between deletion and reuse of a `TemporaryDirectory` name. By pre-creating the directory with world-writable permissions before ansible-runner uses it, the attacker can cause ansible-runner to write files into an attacker-controlled location, potentially reading private information or forcing writes as the legitimate user. This is a TOCTOU race condition combined with incorrect default permissions [CWE-276].
Affected code
The vulnerability is in `ansible_runner/config/_base.py` and `ansible_runner/streaming.py`. In `_base.py`, when no `private_data_dir` is provided, the code used `os.path.join(gettempdir(), ".ansible-runner")` — a fixed, predictable path — and then called `os.makedirs(..., exist_ok=True, mode=0o700)` on it. In `streaming.py`, the code used `tempfile.TemporaryDirectory().name` which creates a tempdir, immediately exposes its name, and then deletes it, allowing an attacker to pre-create a directory with that same name.
What the fix does
The patch replaces the fixed path `os.path.join(gettempdir(), ".ansible-runner")` with `tempfile.mkdtemp(prefix=".ansible-runner-")`, which creates a uniquely-named temporary directory atomically, eliminating the predictability that enabled the race. In `streaming.py`, `tempfile.TemporaryDirectory().name` is replaced with `tempfile.mkdtemp()`, avoiding the delete-then-recreate window. Additionally, `os.makedirs(self.private_data_dir, exist_ok=True, mode=0o700)` is moved inside the `if private_data_dir:` branch so it only runs when the user explicitly provides a path, not on the auto-generated one.
Preconditions
- authAttacker must have local access to the system where ansible-runner runs
- inputAttacker must be able to create directories in the system temporary directory
Generated on Jun 20, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
8- github.com/advisories/GHSA-wwch-cmqr-hhrmghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-3701ghsaADVISORY
- access.redhat.com/security/cve/CVE-2021-3701ghsax_refsource_MISCWEB
- bugzilla.redhat.com/show_bug.cgighsax_refsource_MISCWEB
- github.com/ansible/ansible-runner/issues/738ghsax_refsource_MISCWEB
- github.com/ansible/ansible-runner/pull/742ghsaWEB
- github.com/ansible/ansible-runner/pull/742/commitsghsax_refsource_MISCWEB
- github.com/pypa/advisory-database/tree/main/vulns/ansible-runner/PYSEC-2022-43067.yamlghsaWEB
News mentions
0No linked articles in our index yet.