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

Local privilege escalation through temporary file #6

Closed
cym13 opened this issue Apr 17, 2018 · 2 comments
Closed

Local privilege escalation through temporary file #6

cym13 opened this issue Apr 17, 2018 · 2 comments

Comments

@cym13
Copy link

cym13 commented Apr 17, 2018

In engine/Logger.py line 13 we read:

if status:
    self.fd = open("/tmp/drupwn.txt", "w")

This opens the possibility for a privilege escalation as any user might create the file /tmp/drupwn.txt in advance and redirect its output through a symbolic link. Rewritting ~/.ssh/authorized_keys for example gives shell access to that user's account.

Granted most pentesters don't run security tools on shared machines, but there is no reason to leave that door open either. A securely opened and randomly named file should be used instead:

import tempfile

if status:
    self.fd = tempfile.NamedTemporaryFile(prefix="drupwn-", suffix=".txt", mode="w")

(mktemp is not secure in python, mkstemp isn't nice to work with,
TemporaryFile doesn't create an actual file on linux so it's no good for
logging, hence NamedTemporaryFile.)

Bonus: that also makes drupwn less platform dependent.

@immunIT immunIT self-assigned this Apr 17, 2018
@immunIT
Copy link
Collaborator

immunIT commented Apr 17, 2018

HI @cym13,

Thanks for your input. Even if the risks involved are low, I will check this out and release a patch for the next release.

@immunIT immunIT mentioned this issue Apr 19, 2018
@immunIT
Copy link
Collaborator

immunIT commented Apr 19, 2018

Hi,

This issue has been partially fix in the release 0.9.2. However, we still use the /tmp/ folder to save the logs. Indeed, knowing where this information are stored is inescapable to retrieve them using the docker image.

Thanks again for your review.

Best,

@immunIT immunIT closed this as completed Apr 19, 2018
@immunIT immunIT removed their assignment Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant