CVE-2021-3583: Template Injection Vulnerability in Ansible

ansible Updated 02 Oct 2025

Summary

22/09/2021
Yes i
High
7.1

CVE-2021-3583: A flaw was found in Ansible, where a user's controller is vulnerable to template injection. Affects ansible versions < 2.9.23. Fixed in 2.9.23. How to fix ↓

Also tracked for

The same CVE-2021-3583 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Ansible is an open-source automation tool that allows users to automate tasks such as configuration management, application deployment, and orchestration. It uses a declarative language to describe system configurations and relies on modules to perform specific tasks on managed nodes. Ansible is widely used in IT infrastructure management and has a large community of contributors and users. However, a vulnerability has been discovered in Ansible that allows for template injection, potentially leading to command injection and disclosure of sensitive information.

Vulnerability Detail

The vulnerability in Ansible arises when a user's controller processes templates that contain multi-line YAML strings. If the facts used in the template do not routinely include special template characters, an attacker can exploit this flaw to perform command injection. This can result in the disclosure of sensitive information and compromise the confidentiality and integrity of the system. The vulnerability has been assigned CVE-2021-3583 and is also tracked as GHSA-2pfh-q76x-gwvm.

How To Fix

Latest published version: 14.5.0 as of 22 Oct 2026

pip install --upgrade "ansible==14.5.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.9.23

This is the first release that contains the fix.

pip install --upgrade "ansible==2.9.23"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating Ansible is not immediately feasible, users can implement a workaround by ensuring that the facts used in templates always include special template characters. This can help prevent the template injection vulnerability from being exploited. Here is an example of how to modify a template to include special characters:

- name: Example Template
  template:
    src: example.j2
    dest: /path/to/destination
    validate: /usr/bin/validate-command

Conclusion

The template injection vulnerability in Ansible (CVE-2021-3583) poses a risk to the confidentiality and integrity of systems using the affected versions. It is crucial to update Ansible to version 2.9.23 or later to mitigate this vulnerability. If immediate updating is not possible, implementing the provided workaround can help reduce the risk. For further support and assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for ansible →

Share this vulnerability

FAQ

Ansible is an open-source automation tool used for configuration management, application deployment, and orchestration.

Template injection is a vulnerability that occurs when user input is not properly sanitized and is included in a template. This can lead to the execution of arbitrary code and potential information disclosure.

The vulnerability in Ansible allows for template injection, which can be exploited to perform command injection and disclose sensitive information. This can compromise the confidentiality and integrity of the system.

To fix this vulnerability, update Ansible to version 2.9.23 or later. Alternatively, ensure that the facts used in templates always include special template characters.

Yes, if updating Ansible is not immediately feasible, you can modify templates to include special characters in the facts used. This can help mitigate the risk of template injection.

Related vulnerabilities

Recent vulnerabilities recorded for ansible.

How To Fix

Latest published version: 14.5.0 as of 22 Oct 2026

pip install --upgrade "ansible==14.5.0"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2.9.23

This is the first release that contains the fix.

pip install --upgrade "ansible==2.9.23"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback