Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password leaks in logs for datadog_windows_ddagentuser_password #562

Open
a-rhodes opened this issue Apr 4, 2024 · 1 comment
Open

Password leaks in logs for datadog_windows_ddagentuser_password #562

a-rhodes opened this issue Apr 4, 2024 · 1 comment

Comments

@a-rhodes
Copy link

a-rhodes commented Apr 4, 2024

# We set DD Password Arg here to prevent it from being printed in any kind of debug logs/messages prior usage
- name: Set DD Password Arg
set_fact:
agent_win_install_args: "{{ agent_win_install_args }} DDAGENTUSER_PASSWORD={{ datadog_windows_ddagentuser_password }}"
when: datadog_windows_ddagentuser_password | default('', true) | length > 0

When ansible verbosity level of 1 or more is used (aka -v) the password is written to logs. This task should have a no_log: true on it.

Example playbook to reproduce:

- name: Debug
  hosts: all
  gather_facts: false
  vars:
    agent_win_install_args: "DDAGENTUSER_USER=FOOBAR"
    datadog_windows_ddagentuser_password: "{{ lookup('ansible.builtin.env', 'MY_SECRET_PASS') }}"
  tasks:
    # We set DD Password Arg here to prevent it from being printed in any kind of debug logs/messages prior usage
    - name: Set DD Password Arg
      set_fact:
        agent_win_install_args: "{{ agent_win_install_args }} DDAGENTUSER_PASSWORD={{ datadog_windows_ddagentuser_password }}"
      when: datadog_windows_ddagentuser_password | default('', true) | length > 0

Running the above command:

$ MY_SECRET_PASS=MySecretPassword ansible-playbook -i inventory.yaml playbook-debug.yaml -v
No config file found; using defaults

PLAY [Debug] ************************************************************************************************************************************************************************************************

TASK [Set DD Password Arg] **********************************************************************************************************************************************************************************
ok: [demo-host] => {"ansible_facts": {"agent_win_install_args": "DDAGENTUSER_USER=FOOBAR DDAGENTUSER_PASSWORD=MySecretPassword"}, "changed": false}

PLAY RECAP **************************************************************************************************************************************************************************************************
demo-host                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

Adding no_log: true to the task, the result looks like:

$ MY_SECRET_PASS=MySecretPassword ansible-playbook -i inventory.yaml playbook-debug.yaml -v
No config file found; using defaults

PLAY [Debug] ************************************************************************************************************************************************************************************************

TASK [Set DD Password Arg] **********************************************************************************************************************************************************************************
ok: [demo-host] => {"censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result", "changed": false}

PLAY RECAP **************************************************************************************************************************************************************************************************
demo-host                  : ok=1    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
@wayofthepie
Copy link

wayofthepie commented Apr 29, 2024

Same problem here it seems:

- name: Initialize internal datadog_config variable
set_fact:
agent_datadog_config: "{{ datadog_config }}"
That leaks the api_key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants