-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
grsec (in)compatibilities (security feature) #20303
Comments
If you are reporting a new issue, make sure that we do not have any duplicates already open. You can ensure this by searching the issue list for this repository. If there is a duplicate, please close your issue and add a comment to the existing issue instead. If you suspect your issue is a bug, please edit your issue description to include the BUG REPORT INFORMATION shown below. If you fail to provide this information within 7 days, we cannot debug your issue and will close it. We will, however, reopen it if you later provide the information. For more information about reporting issues, see CONTRIBUTING.md. You don't have to include this information if this is a feature request (This is an automated, informational response) BUG REPORT INFORMATIONUse the commands below to provide key information from your environment:
Provide additional environment details (AWS, VirtualBox, physical, etc.): List the steps to reproduce the issue: Describe the results you received: Describe the results you expected: Provide additional info you think is important: ----------END REPORT --------- #ENEEDMOREINFO |
Note that the best possible outcome here would be for |
Related bug against Gentoo docker package @ https://bugs.gentoo.org/show_bug.cgi?id=574664 |
For everyone who is using Alpine Linux and getting the following error : |
This seems to be out of scope for this project. grsec is somewhat of a moving target because the stable kernel patches aren't available for the general public to use. We can't implement changes in Docker which would weaken security on all other Linux distributions in order to improve grsec compatibility. The best thing to do is to figure out how all these issues can be addressed and maybe send a PR to add documentation on how to run in such a setup. I'm going to close this issue now since there's nothing actionable for the Docker community to work on this. Please feel free to continue the discussion. |
@unclejack The relevant grsec functionality has been stable for many years and is a core feature. It does not vary with Linux distribution or manual patching, it is in fact constant. Let me try to rephrase the issue. The purpose of grsec's 'deny mknod in chroot' feature is to stop people breaking out of The purpose of grsec's 'deny chmod in chroot' feature is to stop people breaking out of The problem is that Docker currently executes the In short, Docker makes it impossible to use useful security features of Ideally, Docker would fix the problem by making the changes suggested above. Alternatively, Docker should at least check that, if the kernel sysctls above are present, that their value is zero, and if not then give a meaningful error message. Closing this issue after months languishing here with no useful feedback demonstrates an unimpressive level of commitment to user security on Docker's behalf. |
Not surprised to see no response here after one week... the docker team's attitude to security seems to speak for itself. |
@globalcitizen if you have time to create a PoC PR, feel free to do so. Please note that Docker is open source, and "the docker team" includes you. @unclejack raised his concerns that we may not be able to support this on all distros, without weakening security for some. If you have a PoC PR to discuss this, and shows that that change does not negatively affect other distros, feel free to do so. |
@thaJeztah I have made quite a few security-related contributions to docker, but I'm not paid, so there is a limit to my contribution. For example, I am not going to learn an entirely new language go just to make a PoC for an issue that I consider, given your supposed commercial trajectory toward production deployments, should be resolved by your paid staff rapidly on security grounds. From comments it seems @unclejack does not comprehend the nature of grsec, which is a set of kernel patches that can be applied to any distro and usually result in exactly the same sysctls being added in a distro-generic manner. There is no threat of weakening security, this is an entirely baseless accusation, which I assume is based upon the straw man that running In fact, |
@globalcitizen nice to hear that you contribute back. I think it is reasonable that you "scratch your own itch" when you don't pay for the product. In fact this issue affects me too but I have not (yet) bothered enough to actually fix it. After a quick look it does seems fixable without too much effort. Apparently, the I can have a look at it later, so I vote for re-opening it. |
@globalcitizen I'm very sorry if my comment made it seem I don't understand what the grsec patches do and what they are. Leaving that aside, what I was saying is that we shouldn't make changes to Docker if that means having less secure systems in the absence of the grsec patched kernels. The points I was making in the previous comment are still valid. There's no simple way for the Docker community to provide support for would be grsec+Docker users. The issue of support is a very serious one because we can't test the exact same setup you're using for grsec. Do we all need Gentoo to run the exact same kernel with the exact same configuration, down to the exact same gcc version with the exact same flags? Do we need to have n versions of the Linux kernel with m versions of the grsec patches to make sure it's all OK? Please keep in mind I'm not against grsec or supporting it with Docker. It's a bad idea if we're giving up security elsewhere to enable it to run on some systems. |
@cpuguy83 Thanks for re-opening @unclejack I feel like you have repeated yourself with the hand-waving suggestion there is some kind of problem 'supporting' grsec. Could you please explicitly explain what you mean about "giving up security elsewhere"? This does not make sense to me. The situation right now is that kernels with grsec work fine already, regardless of version/distro, except for some specific grsec features which have been identified. Looking forward, I have outlined two approaches which would be trivial and help to resolve this problem which multiple users have already reported. The first and preferred approach is changing docker to not The second, which is more of a failure mode and statement of no intent to resolve the problem, is simply checking for the sysctls in question and exiting with a reasonable error message advising the user that those grsec features are incompatible with docker. Frankly though, the first approach is so easy the second approach should probably not be implemented. I feel that your testing comments are a straw man, as test coverage for an arbitrary-kernel system does not need to be perfect and we can generally assume the Linux kernel does not break things between releases. |
seems like the untar in chroot was introduced with 1cb17f0 but it does not say anything about why or what problem it is supposed to solve. So I can only guess why its done that way. One possible reason might be to prevent overwriting files from locations outside the target dir. For example the tar archive could have an entry with It looks like there is a check for preventing that https://github.com/docker/docker/blob/master/pkg/archive/archive.go#L714 to happen, but it does not seem to handle the case where you have a symlink pointing to a directory. For example if you had a symlink in archive
The above example may be fixed with something like (untested): diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go
index 5f8cd09..0ab28e3 100644
--- a/pkg/archive/archive.go
+++ b/pkg/archive/archive.go
@@ -707,7 +707,7 @@ loop:
}
path := filepath.Join(dest, hdr.Name)
- rel, err := filepath.Rel(dest, path)
+ rel, err := filepath.Rel(filepath.EvalSymlinks(dest), filepath.EvalSymlinks(path))
if err != nil {
return err
} But I don't know if there are more similar cases. So I don't think we can simply remove the chroot without fully understanding the consequences. @unclejack do you have any url to issue or discussion that led to the introduction of the |
We might actually be able to avoid the But I don't think we can work around the Another option might be to check content of |
@ncopa I think if you look at all the the changes (and tests) for the 1.3.2 release combined, it should give some context: #9323 (and https://github.com/docker/docker/blob/master/CHANGELOG.md#132-2014-11-20) |
@ncopa It was for security reasons. That shouldn't be bypassed in any way. |
@unclejack i figured it was for security reasons. However, since The problem at hand is that to be able to use docker with grsecurity patched kernel, you have to system wide disable 2 other security features which will actually make My feeling so so far have been that docker's use of |
@ncopa You're probably familiar with the reason why the chroot is necessary now. We could also replace that chroot with a container. |
I've opened #22506 which replaces chroot with pivot_root. |
pivot_root is now used by default on Linux. |
This covers all the issues raised, so I think we can close this now. Feel free to open other issues around grsec, I plan to do some more testing. |
Folks, I'll close this now and will re-open if needed. Please feel free to comment. |
run command : sysctl -w kernel.grsecurity.chroot_deny_chmod=0 |
Thank you so much @globalcitizen - I had this exact issue and didn't feel comfortable to weaken my kernel. Temporarily changing the sysctl flags is also a solution I read in grsec's manuals, so I am doing that before building a docker image to then reenable the protection. That still feels a bit scary, but it works. :) |
@orangecms Docker 1.12 only does a chroot as a fallback if there was some issue with pivot_root. |
I just hit almost the same issue as #14363 (mine reads "ApplyLayer exit status 1 stdout: stderr: chmod /bin/mount: permission denied") , also under Gentoo. It is related to the use of the kernels built with
grsec
such as Gentoo'shardened-sources
package.After some digging, I changed the following:
This appears to fix the problem, but hits another problem more like that shown in #14363, "ApplyLayer exit status 1 stdout: stderr: operation not permitted". So I tried adding the following from #14363, just to test if it works. (Note that disabling this option appears to be a very bad idea from a security standpoint!)
The result was that it worked.
To save anyone the hassle in future, Docker could check for the existence of
/proc/sys/kernel/grsecurity/chroot_deny_chmod
and/proc/sys/kernel/grsecurity/chroot_deny_mknod
and, if present, ensure the values of both are 0.The text was updated successfully, but these errors were encountered: