-
Notifications
You must be signed in to change notification settings - Fork 23.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to preserve an unsafe variable when accessing through an intermediary variable from hostvars. (cherry picked from commit 2936b80)
- Loading branch information
Showing
6 changed files
with
159 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
security_fixes: | ||
- Templating will not prefer AnsibleUnsafe when a variable is referenced via hostvars - CVE-2024-11079 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
- name: test CVE-2024-11079 loop variables preserve unsafe hostvars | ||
hosts: localhost | ||
gather_facts: false | ||
tasks: | ||
- set_fact: | ||
foo: | ||
safe: | ||
prop: '{{ "{{" }} unsafe_var {{ "}}" }}' | ||
unsafe: | ||
prop: !unsafe '{{ unsafe_var }}' | ||
|
||
- name: safe var through hostvars loop is templated | ||
assert: | ||
that: | ||
- item.prop == expected | ||
loop: | ||
- "{{ hostvars['localhost']['foo']['safe'] }}" | ||
vars: | ||
unsafe_var: bar | ||
expected: bar | ||
|
||
- name: unsafe var through hostvars loop is not templated | ||
assert: | ||
that: | ||
- item.prop == expected | ||
loop: | ||
- "{{ hostvars['localhost']['foo']['unsafe'] }}" | ||
vars: | ||
unsafe_var: bar | ||
expected: !unsafe '{{ unsafe_var }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters