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

package and service modules allow arbitrary modules to be executed #67796

Closed
samdoran opened this issue Feb 26, 2020 · 2 comments
Closed

package and service modules allow arbitrary modules to be executed #67796

samdoran opened this issue Feb 26, 2020 · 2 comments
Assignees
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category security Related to a vulnerability or CVE support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category

Comments

@samdoran
Copy link
Contributor

SUMMARY

CVE-2020-1738

Both package and service modules use facts to determine the name of the module to run if use is not passed to the module. The ansible_facts['pkg_mgr'] and ansible_facts['service_mgr'] facts could be set to another module name or a module name installed in a collection such as ansible_collections.namespace.name./tmp/reverse-shell, which would allow arbitrary code execution on the managed node.

A potential fix would be to whitelist valid modules for package and service and/or have the collection loader validate the collection path to not allow arbitrary files.

The collection loader part may already be fixed in 2.9.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

lib/ansible/plugins/action/service.py
lib/ansible/plugins/action/package.py

ANSIBLE VERSION
2.10
CONFIGURATION
default
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

@samdoran samdoran added the security Related to a vulnerability or CVE label Feb 26, 2020
@ansibot
Copy link
Contributor

ansibot commented Feb 26, 2020

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. module This issue/PR relates to a module. packaging Packaging category support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category labels Feb 26, 2020
Akasurde added a commit to Akasurde/ansible that referenced this issue Feb 27, 2020
When 'use' parameter is not used in package and service module,
ansible relies on ansible facts such as 'pkg_mgr' and 'service_mgr'.

This would allow arbitrary code execution on the managed node.

Fix is added by adding a whitelist of allowed package manager modules and
service manager modules to avoid arbitrary code execution on the managed node.

Fixes: ansible#67796

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Feb 27, 2020
**security issue** (CVE-2020-1738)
When 'use' parameter is not used in package and service module,
ansible relies on ansible facts such as 'pkg_mgr' and 'service_mgr'.

This would allow arbitrary code execution on the managed node.

Fix is added by adding a whitelist of allowed package manager modules and
service manager modules to avoid arbitrary code execution on the managed node.

Fixes: ansible#67796

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Feb 27, 2020
**security issue** (CVE-2020-1738)
When 'use' parameter is not used in package and service module,
ansible relies on ansible facts such as 'pkg_mgr' and 'service_mgr'.

This would allow arbitrary code execution on the managed node.

Fix is added by adding a whitelist of allowed package manager modules and
service manager modules to avoid arbitrary code execution on the managed node.

Fixes: ansible#67796

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@bcoca bcoca assigned bcoca and unassigned Akasurde Apr 3, 2020
@ansibot ansibot added the has_pr This issue has an associated PR. label Apr 3, 2020
Akasurde added a commit to Akasurde/ansible that referenced this issue Apr 16, 2020
**security issue** (CVE-2020-1738)
When 'use' parameter is not used in package and service module,
ansible relies on ansible facts such as 'pkg_mgr' and 'service_mgr'.

This would allow arbitrary code execution on the managed node.

Fix is added by adding a whitelist of allowed package manager modules and
service manager modules to avoid arbitrary code execution on the managed node.

Fixes: ansible#67796

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Apr 16, 2020
**security issue** (CVE-2020-1738)
When 'use' parameter is not used in package and service module,
ansible relies on ansible facts such as 'pkg_mgr' and 'service_mgr'.

This would allow arbitrary code execution on the managed node.

Fix is added by adding a whitelist of allowed package manager modules and
service manager modules to avoid arbitrary code execution on the managed node.

Fixes: ansible#67796

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@bcoca
Copy link
Member

bcoca commented Apr 16, 2020

Going to close this one as it requires the remote to already be compromised in a way that this does not expand upon. To trigger this you already need to be able to either intercept communications with the target (so you can already alter payloads) or intercept what is executed on the target (so you already can control what is executed).

As for having the user install malicious collection to use in conjunction with this to execute arbitrary code on the controller, instead you can have them install a malicious role and override builtin actions, which is a much simpler approach w/o requiring an additional exploited remote target.

@bcoca bcoca closed this as completed Apr 16, 2020
@ansible ansible locked and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.10 This issue/PR affects Ansible v2.10 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. packaging Packaging category security Related to a vulnerability or CVE support:core This issue/PR relates to code supported by the Ansible Engineering Team. system System category
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants