Skip to content

Commit

Permalink
[stable-2.14] Ensure ANSIBLE_NO_LOG is respected (CVE-2024-0690) (#82565
Browse files Browse the repository at this point in the history
) (#82568)

(cherry picked from commit 6935c8e)
  • Loading branch information
sivel committed Jan 18, 2024
1 parent 080c3ce commit beb04bc
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/cve-2024-0690.yml
@@ -0,0 +1,2 @@
security_fixes:
- ANSIBLE_NO_LOG - Address issue where ANSIBLE_NO_LOG was ignored (CVE-2024-0690)
2 changes: 1 addition & 1 deletion lib/ansible/playbook/base.py
Expand Up @@ -722,7 +722,7 @@ class Base(FieldAttributeBase):

# flags and misc. settings
environment = FieldAttribute(isa='list', extend=True, prepend=True)
no_log = FieldAttribute(isa='bool')
no_log = FieldAttribute(isa='bool', default=C.DEFAULT_NO_LOG)
run_once = FieldAttribute(isa='bool')
ignore_errors = FieldAttribute(isa='bool')
ignore_unreachable = FieldAttribute(isa='bool')
Expand Down
4 changes: 0 additions & 4 deletions lib/ansible/playbook/play_context.py
Expand Up @@ -320,10 +320,6 @@ def set_task_and_variable_override(self, task, variables, templar):
display.warning('The "%s" connection plugin has an improperly configured remote target value, '
'forcing "inventory_hostname" templated value instead of the string' % new_info.connection)

# set no_log to default if it was not previously set
if new_info.no_log is None:
new_info.no_log = C.DEFAULT_NO_LOG

if task.check_mode is not None:
new_info.check_mode = task.check_mode

Expand Down
13 changes: 13 additions & 0 deletions test/integration/targets/no_log/no_log_config.yml
@@ -0,0 +1,13 @@
- hosts: testhost
gather_facts: false
tasks:
- debug:
no_log: true

- debug:
no_log: false

- debug:

- debug:
loop: '{{ range(3) }}'
5 changes: 5 additions & 0 deletions test/integration/targets/no_log/runme.sh
Expand Up @@ -19,3 +19,8 @@ set -eux

# test invalid data passed to a suboption
[ "$(ansible-playbook no_log_suboptions_invalid.yml -i ../../inventory -vvvvv "$@" | grep -Ec '(SUPREME|IDIOM|MOCKUP|EDUCATED|FOOTREST|CRAFTY|FELINE|CRYSTAL|EXPECTANT|AGROUND|GOLIATH|FREEFALL)')" = "0" ]

# test variations on ANSIBLE_NO_LOG
[ "$(ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "1" ]
[ "$(ANSIBLE_NO_LOG=0 ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "1" ]
[ "$(ANSIBLE_NO_LOG=1 ansible-playbook no_log_config.yml -i ../../inventory -vvvvv "$@" | grep -Ec 'the output has been hidden')" = "6" ]

0 comments on commit beb04bc

Please sign in to comment.