-
Notifications
You must be signed in to change notification settings - Fork 119
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
Docker image and Tomcat configuration hardening #39
Conversation
…ge escalation attacks within containers
I really like this. Thx a lot! One thing that comes to my mind: #34 also adds a custom We should have this in mind, once one of these PRs should be merged. |
I just found this on a search to change the default Tomcat port 8080 as we would like to use this in a docker network where port 8080 is already taken. @buehner do all config options that this |
I think it makes sense to use an explicit user ID when adding/creating the geoserver user. Something like This might help in case someone has problems with user permission (after merging this PR) that could be solved by something like |
Generally it would be nice to also add some lines to the |
Many thanks for the adjustments. There is one more point that came to my mind: There is a Line 97 in 0966018
Lines 104 to 107 in 0966018
This is also used in #44 I think it makes sense to handle aspects like this as uniformly as possible, so I would suggest to adapt this accordingly. For this PR this would probably mean that we remove What do you think? |
Maybe I am also mixing things up here. I guess we always want the hardened server.xml, so maybe my previous post is not fully correct. But maybe it still makes sense to add such an (optional) possibility to allow the use of custom xmls in a uniform way |
@ahennr Thx for letting me push some more commits to your branch :-) Please review my latest changes. If you are happy, I think we can merge this |
Looks good @buehner , I've no further comments. Please merge at will |
@fleimgruber Not sure what exactly changed in the |
@buehner thanks for checking back!
Part of my confusion was that there was no original one in this repo - this very PR adds it. In the meantime I created a fresh server.xml based on upstream as you suggested and mounted it much like it is done in this PR here, but instead in a Docker compose file. So all questions answered and sorry for hijacking this PR. |
Is it possible that this PR broke the Jenkins Docker build job, last working on 9 Feb? see: https://build.geoserver.org/job/geoserver-release-docker/buildTimeTrend The error in https://build.geoserver.org/job/geoserver-release-docker/lastBuild/console:
matches the newly added code. |
@petersmythe I think you are right. I just had a very quick look and I don't know much about jenkins, but could this be some kind of jenkins specific error? This seems to run fine locally, so I guess locally a zero code is returned from the line. But i think @ahennr and I will try to find some time soon to have a deeper look here. Thx for reporting |
This issue is also affecting the 2.23.5 release (or, as an alternative, we'll have to release without the Docker image) |
@petersmythe @aaime We could easily fix this in #51 Successful build: https://build.geoserver.org/job/geoserver-release-docker/759/ The reason was a missing Thx for the help @ahennr |
Could someone please double check I get a permission denied error:
|
I just ran |
But We will have a look again |
@petersmythe We added this: #52 |
Hey folks, without using a jira ticket I have no way of capturing changes to the docker environment for the release announcement. I looks like this change was done earlier in the year and I am not sure we managed to tell our users about it! |
In this PR some of recommendations listed in the CIS Apache Tomcat (9) and CIS Docker Benchmarks (see also https://www.cisecurity.org/cis-benchmarks) have been applied.
These recommendations contain best practices for configuring Tomcat and Docker in a secure way.
However, there exist much more benchmarks for other software as well.
Attackers often use sensitive information provided by the webserver (e.g. versions, headers, stack traces…) in their attacks. The Recommendations regarding Tomcat should increase the complexity of determination of this information.
In particular, I've integrated the following configuration changes:
webapps
folder (since it is not required for GeoServer AFAIK)server.xml
which is copied to$CATALINA_HOME/conf/
:allowTrace="false"
in HTTP-Connector (sinceTRACE
requests often contain sensitive information)xpoweredBy="false"
explicitly (will removeX-Powered-By
HTTP header)startup.sh
script, theSHUTDOWN
command inserver.xml
is replaced to a non deterministic value (here: sequence of ten random chars). Usually Tomcat listens on TCP port 8005 to accept shutdown requests (If this port needs is exposed by any application). Herewith, its prevented that malicious local users shutting down Tomcat.server.info
String in order to hide version number and build date for attackers (e.g. on 404 not found). If the default shutdown command should be as is,ENABLE_DEFAULT_SHUTDOWN
can be set totrue
an an environment variable.Beside, based on the work in @alapierre 's fork of GeoServer docker (see https://github.com/alapierre/geoserver-docker/blob/master/Dockerfile#L108), I've added a user
geoserver
(in groupgeoserver
) which is used to run GeoServer in the docker image. Usually containers should run as a non-root user (see also https://docs.docker.com/develop/develop-images/instructions/#user and CIS Docker Benchmark).Furthermore, the CIS Docker benchmark recommends to remove
setuid
andsetgid
permissions in the docker image to prevent privilege escalation attacks within containers.I'm not sure if these are useful settings / improvements for the GeoServer base image itself, or rather for another variant as proposed in #27 (multi variant build), what do you think about it?