-
Notifications
You must be signed in to change notification settings - Fork 2.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
podman top not work with userns=keep-id container #10941
Comments
Thanks for reporting, @pendulm. That's something we need to fix in |
I am a bit lost. It looks like we shouldn't join the user NS but do. @giuseppe, do you know what's going on? |
Does it work differently if you run |
From what I can see, the error seems to be in the target pid used to join the user namespace. The command should look like |
Same issue. |
I think it is trying to join the wrong pid, it should not be 1 |
Any update? I encountered this as well, however I seem to be getting another error:
Without keep-id everything works perfectly. |
@vrothberg PTAL |
A friendly reminder that this issue had no activity for 30 days. |
Seems to work on main branch.
|
I can reproduce this issue with the latest podman version from main as well as with 3.4.4, but only with certain images. For example: $ podman run --userns=keep-id --rm -d registry.opensuse.org/opensuse/tumbleweed-dnf sleep infinity
$ podman top $CONTAINER_ID
Error: error executing "nsenter -U -t 1 cat /proc/1/status": exec: "nsenter": executable file not found in $PATH
$ podman run --userns=keep-id --pull always --rm -d registry.opensuse.org/opensuse/busybox sleep infinity
$ podman top $CONTAINER_ID
Error: error executing "nsenter -U -t 1 cat /proc/1/status": exit status 1 whereas the above commands work for I have tried using strace to figure what exactly is going wrong here, but I fail to find the place where the actual issue appears. |
@vrothberg PTAL |
I took a look at this (it's happening with Tumbleweed images). It turns out it just boils down to However I'm slightly more confused why EDIT: Ah, the join namespace code gets triggered automatically if the namespaces don't match. Why isn't The |
@vrothberg is on PTO and will be back on Monday, so he should be able to answer. I think the issue is psgo attempts to show IDs from the User Namespace perspective as well as from the hosts. So entering the User Namespace is attempting to show what the HUSER versus USER, HGROUP versus GROUP of processes within the container. |
I need some time to look into it since I haven't looked at this code in a long while. |
A quick update from looking at this again: This happens no matter what userns mode you use, so long as the container uses user namepsaces you hit this issue. The However if the only reason the namespace is being joined is in order to convert uids and gids, this can be done in Go entirely by just reading |
It should also be noted that this behaviour means that I'm also fairly sure that If |
containers/psgo#92 should resolve the issue, though I'm not quite sure how to test whether the mapping functionality works. I couldn't figure out how to get the mapping functionality to work with the |
With containers/psgo#92 merged, we can close the issue. It'll get vendored before we cut a new release. |
@vrothberg Did you plan to make a security advisory for the issue? Unless I'm mistaken this is technically a privilege escalation vector (though not a complete escalation since most of the namespaces are still joined). |
Thanks for checking! I am not (yet) convinced there's a security issue since we joined the user namespace and mount namespace of the container. But I may be off. Can you elaborate how we could escalate? We should probably move over to email ([email protected]) to not paste an attack here. |
This issue has now been fixed in the |
We don't backport unless it is to supported Branches like in RHEL, and even there we frown on it. |
That doesn't apply to the current state since we cannot bump Fedora 35 to v4.0. We actually did backport quite some patches to Podman v3.4 because of that. |
Daniel J Walsh ***@***.***> writes:
We don't backport unless it is to supported Branches like in RHEL, and even there we frown on it.
This issue most certainly impacts RHEL as well. It impacts everything
but the main branch (and possibly the 4.0 release)
|
I'm trying to determine the security impact for this bug. It might deserve assigning a CVE (which I can take care of). Forgive my basic questions as I'm not very familiar with Podman yet. Below are my guesses/questions to the CVSS score, used in determining severity. Please correct me if any assumptions are wrong. Attack Vector Attack Complexity Privileges Required User Interaction Scope Confidentiality Impact Integrity Impact Availability Impact |
No. As an attacker I would try push a malicious image on a public registry and wait for users to run it and run
It is largely independent from how the container is run.
I don't think that's a hurdle. A simple Dockerfile is sufficient.
The latter. As mentioned above, I would try to push an evil image on a public registry.
It is possible to send signals to the host's systemd which allows, in principle, to reboot the machine. AFAICS, we're not in the user NS of the container but the main one of Podman (if run rootless). We're only in the container's mount NS. |
That helps a lot! I will be assigning a CVE. Can we come up with a better title for the security issue? The current title "podman top not work with userns=keep-id container" was how it was discovered but the userns switch is actually irrelevant to the security impact. How about "Privilege escalation in 'podman top'"? Podman will need to be updated to use a fixed version of psgo right? |
Sounds good to me, thanks.
v4.0 has the fix. Older ones need to be updated. |
Yeah we're only in the mount ns. There are a few other attacks you should be able to do carry out in addition to the one mentioned (you might be able to get access to the host filesystem using You can also probably access any databases on the host through SYSV memory sharing and so on, and you could intercept (and send out) any network traffic you like. Basically, you can probably gain full access to the host with a clever enough exploit AFAICS. The impact should be high. |
Thanks for helping figure out the severity. CVE-2022-1227 has been assigned. |
Nick Tait ***@***.***> writes:
Thanks for helping figure out the severity. CVE-2022-1227 has been assigned.
Does that mean we'll get a backport to 3.4?
|
Yes. |
@vrothberg Now that there is a CVE assigned, can you add me to the credits section of the vulnerability entry? Thanks. |
That is outside my competences but @nickthetait may be able to help. |
Yep, done. |
Thank you, @nickthetait! |
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
Steps to reproduce the issue:
top with --userns=keep-id container
top with normal container
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:The text was updated successfully, but these errors were encountered: