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

ansible-runner writes artifacts to world rw location by default #738

Closed
cidrblock opened this issue Jun 24, 2021 · 2 comments · Fixed by #742
Closed

ansible-runner writes artifacts to world rw location by default #738

cidrblock opened this issue Jun 24, 2021 · 2 comments · Fixed by #742

Comments

@cidrblock
Copy link
Contributor

related to: #722

@cidrblock cidrblock changed the title ansible-runner writes artifiacts to world rw location by default ansible-runner writes artifacts to world rw location by default Jun 24, 2021
@matburt
Copy link
Member

matburt commented Jun 25, 2021

I should have caught this beforehand, that whole first line probably just needs to be replaced with https://docs.python.org/3/library/tempfile.html#tempfile.mkdtemp

@cidrblock
Copy link
Contributor Author

yeah, and with a prefix for attribution

abadger added a commit to abadger/ansible-runner that referenced this issue Jun 28, 2021
…dtemp()

The previous code allowed for an easily exploitable race where the
attacker could pre-create a known directory name to gain access to
private files created by ansible-runner.  Using mkdtemp() closes that
hole because mkdtemp() ensures that the directory name returned has
been allocated with restrictive permissions by mkdtemp itself so the
attacker has no opportunity to inject their own directory.

Fixes ansible#738
abadger added a commit to abadger/ansible-runner that referenced this issue Jun 28, 2021
…dtemp()

The previous code allowed for an easily exploitable race where the
attacker could pre-create a known directory name to gain access to
private files created by ansible-runner.  Using mkdtemp() closes that
hole because mkdtemp() ensures that the directory name returned has
been allocated with restrictive permissions by mkdtemp itself so the
attacker has no opportunity to inject their own directory.

Fixes ansible#738
ansible-zuul bot added a commit that referenced this issue Jun 29, 2021
Secure tempfiles

Looking through the code, I found two separate race conditions with tempfile handling which can be exploited.  One of those is mentioned in #738. The other one happens because we create a tempdir and then delete it, then later reuse its name. An attacker can pre-create the tempdir in between the deletion and the second creation with the reused name.  This PR attempts to fix both.
Fixes #738

Reviewed-by: Shane McDonald <me@shanemcd.com>
Reviewed-by: Matthew Jones <bsdmatburt@gmail.com>
atbore-phx pushed a commit to atbore-phx/ansible-runner that referenced this issue Jun 29, 2021
…dtemp()

The previous code allowed for an easily exploitable race where the
attacker could pre-create a known directory name to gain access to
private files created by ansible-runner.  Using mkdtemp() closes that
hole because mkdtemp() ensures that the directory name returned has
been allocated with restrictive permissions by mkdtemp itself so the
attacker has no opportunity to inject their own directory.

Fixes ansible#738
atbore-phx pushed a commit to atbore-phx/ansible-runner that referenced this issue Jun 29, 2021
…dtemp()

The previous code allowed for an easily exploitable race where the
attacker could pre-create a known directory name to gain access to
private files created by ansible-runner.  Using mkdtemp() closes that
hole because mkdtemp() ensures that the directory name returned has
been allocated with restrictive permissions by mkdtemp itself so the
attacker has no opportunity to inject their own directory.

Fixes ansible#738
shanemcd pushed a commit to shanemcd/ansible-runner that referenced this issue Jul 2, 2021
…dtemp()

The previous code allowed for an easily exploitable race where the
attacker could pre-create a known directory name to gain access to
private files created by ansible-runner.  Using mkdtemp() closes that
hole because mkdtemp() ensures that the directory name returned has
been allocated with restrictive permissions by mkdtemp itself so the
attacker has no opportunity to inject their own directory.

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

Successfully merging a pull request may close this issue.

3 participants