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

Fix password leak in logs for provider argument #32215

Merged
merged 3 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Ansible Changes By Release
* Include_role now complains about invalid arguments
* Added socket conditions to ignore for wait_for, no need to error for closing already closed connection
* Updated hostname module to work on newer RHEL7 releases

* Security fix to avoid provider password leaking in logs for network modules

<a id="2.3.2"></a>

Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/dellos10.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def run(self, tmp=None, task_vars=None):
pc.become = provider['authorize'] or False
pc.become_pass = provider['auth_pass']

# remove auth from provider arguments
provider.pop('password', None)
provider.pop('auth_pass', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/dellos6.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def run(self, tmp=None, task_vars=None):
pc.become = provider['authorize'] or False
pc.become_pass = provider['auth_pass']

# remove auth from provider arguments
provider.pop('password', None)
provider.pop('auth_pass', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/dellos9.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def run(self, tmp=None, task_vars=None):
pc.become = provider['authorize'] or False
pc.become_pass = provider['auth_pass']

# remove auth from provider arguments
provider.pop('password', None)
provider.pop('auth_pass', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
16 changes: 12 additions & 4 deletions lib/ansible/plugins/action/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def run(self, tmp=None, task_vars=None):
pc.become = provider['authorize'] or False
pc.become_pass = provider['auth_pass']

# remove auth from provider arguments
provider.pop('password', None)
provider.pop('auth_pass', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down Expand Up @@ -109,18 +113,22 @@ def run(self, tmp=None, task_vars=None):
if provider.get('username') is None:
provider['username'] = self._play_context.connection_user

if provider.get('password') is None:
provider['password'] = self._play_context.password

if provider.get('authorize') is None:
provider['authorize'] = False

if provider.get('validate_certs') is None:
provider['validate_certs'] = ARGS_DEFAULT_VALUE['validate_certs']

self._task.args['provider'] = provider
# copy auth to top level module arguments to correctly handle `no_log`.
if self._task.args.get('password') is None:
self._task.args['password'] = provider['password'] or self._play_context.password

# remove auth from provider arguments
provider.pop('password', None)

self._task.args['provider'] = provider
result = super(ActionModule, self).run(tmp, task_vars)

return result

def _get_socket_path(self, play_context):
Expand Down
4 changes: 4 additions & 0 deletions lib/ansible/plugins/action/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def run(self, tmp=None, task_vars=None):
pc.become = provider['authorize'] or False
pc.become_pass = provider['auth_pass']

# remove auth from provider arguments
provider.pop('password', None)
provider.pop('auth_pass', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/plugins/action/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def run(self, tmp=None, task_vars=None):
pc.password = provider['password'] or self._play_context.password
pc.timeout = provider['timeout'] or self._play_context.timeout

# remove auth from provider arguments
provider.pop('password', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/plugins/action/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def run(self, tmp=None, task_vars=None):
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
pc.timeout = provider['timeout'] or self._play_context.timeout

# remove auth from provider arguments
provider.pop('password', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
11 changes: 9 additions & 2 deletions lib/ansible/plugins/action/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def run(self, tmp=None, task_vars=None):
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
pc.timeout = provider['timeout'] or self._play_context.timeout

# remove auth from provider arguments
provider.pop('password', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down Expand Up @@ -105,8 +108,12 @@ def run(self, tmp=None, task_vars=None):
if provider.get('username') is None:
provider['username'] = self._play_context.connection_user

if provider.get('password') is None:
provider['password'] = self._play_context.password
# copy auth to top level module arguments to correctly handle `no_log`.
if self._task.args.get('password') is None:
self._task.args['password'] = provider['password'] or self._play_context.password

# remove auth from provider arguments
provider.pop('password', None)

if provider.get('use_ssl') is None:
provider['use_ssl'] = False
Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/plugins/action/sros.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def run(self, tmp=None, task_vars=None):
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
pc.timeout = provider['timeout'] or self._play_context.timeout

# remove auth from provider arguments
provider.pop('password', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down
3 changes: 3 additions & 0 deletions lib/ansible/plugins/action/vyos.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def run(self, tmp=None, task_vars=None):
pc.private_key_file = provider['ssh_keyfile'] or self._play_context.private_key_file
pc.timeout = provider['timeout'] or self._play_context.timeout

# remove auth from provider arguments
provider.pop('password', None)

display.vvv('using connection plugin %s' % pc.connection, pc.remote_addr)
connection = self._shared_loader_obj.connection_loader.get('persistent', pc, sys.stdin)

Expand Down