Skip to content

Commit 6027fb5

Browse files
authored
detail about playbook conditionals from changelog (#423)
This change manually includes details from the 2.17.0 changelog that were not included in the porting guide.
1 parent 876b0ef commit 6027fb5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

10/porting_guide_10.rst

+21-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,27 @@ We suggest you read this page along with the `Ansible 10 Changelog <https://gith
1818
Playbook
1919
========
2020

21-
No notable changes
21+
* Conditionals - due to mitigation of security issue CVE-2023-5764 in ansible-core 2.16.1,
22+
conditional expressions with embedded template blocks can fail with the message
23+
"``Conditional is marked as unsafe, and cannot be evaluated.``" when an embedded template
24+
consults data from untrusted sources like module results or vars marked ``!unsafe``.
25+
Conditionals with embedded templates can be a source of malicious template injection when
26+
referencing untrusted data, and can nearly always be rewritten without embedded
27+
templates. Playbook task conditional keywords such as ``when`` and ``until`` have long
28+
displayed warnings discouraging use of embedded templates in conditionals; this warning
29+
has been expanded to non-task conditionals as well, such as the ``assert`` action.
30+
31+
.. code-block:: yaml
32+
- name: task with a module result (always untrusted by Ansible)
33+
shell: echo "hi mom"
34+
register: untrusted_result
35+
# don't do it this way...
36+
# - name: insecure conditional with embedded template consulting untrusted data
37+
# assert:
38+
# that: '"hi mom" is in {{ untrusted_result.stdout }}'
39+
- name: securely access untrusted values directly as Jinja variables instead
40+
assert:
41+
that: '"hi mom" is in untrusted_result.stdout'
2242
2343
2444
Command Line

0 commit comments

Comments
 (0)