-
Notifications
You must be signed in to change notification settings - Fork 324
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
crun follows symlinks when creating mount points #111
Comments
The obvious fix is to do the equivalent of https://github.com/cyphar/filepath-securejoin. However, that library is not race-safe at all (see CVE-2018-18554 to see what I mean). I have been working on a race-safe version (which also makes use of new kernel features I'm working on), and that would be a better thing to eventually switch to (https://github.com/openSUSE/libpathrs). Unfortunately it's currently not packaged by anyone (though we should also fix that). Interestingly, one thing I just figured out is that Since we're doing everything in a mount namespace the symlink-unsafety of |
Yes, I've spent some time playing with that. It's possible to replace |
What I meant is that you could create a symlink to EDIT: Oh shit, I just checked and EDIT2: Ah I forgot we do
|
the current implementation of chroot_realpath skipped resolving symlinks for the last path component. A malicious image could create files on the host. Closes: containers#111 Signed-off-by: Giuseppe Scrivano <[email protected]>
There is something similar to I've done some minor changes to adapt it to crun, such as return partial resolved paths, and now to resolve also the last component. I'll look into using https://github.com/openSUSE/libpathrs. Do you have any example of using it from C? Can it be used as a copylib? |
Note that at the moment it is still in the "heavy development" phase (so there's a lot of emphasis ojn the "eventually" in "eventually switch to") -- though I would appreciate feedback regarding the APIs. It definitely works as-is (I have some not-yet-pushed tests that use it with a Python FFI wrapper to double-check that CVE-2018-16554 attacks are defended against).
There is a trivial example in the README -- it looks like this:
The key interfaces all look like the above:
If you mean an actual program which uses it, I'm currently working on porting
I'm not sure what that means? |
From what I understood you'd like to get libpathrs packaged. I was just wondering if I could just add it as a git submodule for now and start using it without waiting for packages. Would you have anything against it? Can I get a resolved path from a handle so that I can use it with |
I have no problem with that at all -- as long as you can build it and it works for you that's totally fine with me (obviously please avoid out-of-tree patches but that's a given).
I am about to write a wrapper for If you really try, you can get resolved pathrs through |
the current implementation of chroot_realpath skipped resolving symlinks for the last path component. A malicious image could create files on the host. Closes: containers#111 Signed-off-by: Giuseppe Scrivano <[email protected]>
crun follows symlinks when creating mount points, allowing a malicious container to create arbitrary empty files in the host filesystem.
runc resolves the symlink relative to the container rootfs using SecureJoin and creates /opt/resolv.conf inside the container instead.
/CC @giuseppe @rhatdan @cyphar
Works with SELinux on.
Tested with crun at 66cd22c and podman 1.5.1 on Fedora 30.
(
--no-cache
required when playing with the POC due to containers/buildah#1875)The text was updated successfully, but these errors were encountered: