-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[linux] how can psutil show exe
if the linx is not readable?
#2334
Comments
Magic explained: Lines 662 to 687 in 4407540
|
Well but as I wrote quite lengthy, this is actually a security hole as any process may thereby fake it's executable to be something else. So could you please reopen and ... well simply not do this? |
Sorry, I was in a rush and only focused on the first part of your post. |
No worries. Uhm, I would rather suggest to call it And adding some warning box in the documentation, that when this is |
Summary
Description
I wondered how
psutil
the following can happen.As a normal user:
the
exe
information (and others) for these processes (which areXorg
andlightdm
) cannot be read.But their
cmdline
can:Now, when again as the same user (UID
1000
), I do the following with psutil:So if
exe
is unreadable in both cases, how can it know theexe
in the first case?My assumption is, that it somehow takes
cmdline
, but perhaps only if that starts with an absolute path?I tried to look it up in the code, but couldn't find anything at a first glance:
https://github.com/giampaolo/psutil/blob/master/psutil/_pslinux.py#L1763-L1773
If it would somehow use
cmdline
, that would IMO be a security hole. Processes can modify their owncmdline
so when another process would e.g. trust thatexe()
returns the right executable, this might be wrong and so the user ofexe()
could be lead into doing bad things.Any idea how your code does the magic to get the executable despite the symlink in
/proc
not being readable?Thanks,
Chris.
The text was updated successfully, but these errors were encountered: