Score:0

Remove Apache tomcat version from the app at the container level

cn flag

I am trying to send a GET request to my app as shown:

Request
GET /c%3a%5cboot.ini HTTP/1.1
Host: myapp.io
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Cache-Control: no-cache
Cookie: appCookie=MH3.7.9823272323477.1639691466;
User-Agent: Mozilla/5.0 (Windows NT 10.0; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.39
45.0 Safari/537.36

The response is:

HTTP/1.1 400
Connection: keep-alive
Content-Length: 795
Content-Language: en
Content-Type: text/html; charset=utf-8
Date: Thu, 16 Dec 2021 21:51:50 GMT
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/c
ss">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76
;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black
;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400
– Bad Request</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> Invalid URI
</p><p><b>Description</b> The server cannot or will not process the request due to something that is
perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or
deceptive request routing).</p><hr class="line" /><h3>Apache Tomcat/8.5.68</h3></body></html>

From this response, is there a way to remove the version in <h3>Apache Tomcat/8.5.68</h3> and display it as just <h3>Apache Tomcat</h3> at the container level, as this is a security issue.

My Dockerfile looks like this:

FROM maven:3.6.3-jdk-11 as builder

COPY . .
RUN mvn clean package -Dapp.host=$MYAPP_HOST

FROM tomcat:8.5-jdk11
ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

COPY --from=builder ./target/app.war /usr/local/tomcat/webapps/ROOT.war
RUN mkdir /usr/local/tomcat/webapps/ROOT
RUN cp /usr/local/tomcat/webapps/ROOT.war /usr/local/tomcat/webapps/ROOT/ROOT.war
RUN cd /usr/local/tomcat/webapps/ROOT && jar xvf ROOT.war

RUN apt-get update && apt-get install -y nginx && mkdir /etc/nginx/certs
COPY proxy.conf /etc/nginx/
COPY vhosts.conf /etc/nginx/conf.d/

EXPOSE 443
RUN echo '#!/bin/bash\nnginx\ncatalina.sh run' > start-wrapper.sh && chmod +x start-wrapper.sh && mv start-wrapper.sh /usr/bin/
CMD ["start-wrapper.sh"]

Can the Apache Tomcat version be removed here at the docker container level?

jp flag
https://tomcat.apache.org/tomcat-8.5-doc/security-howto.html#Valves
merilstack avatar
cn flag
@AlexD can use this command to modify the apache version? ```sed -i \ 's#^server.info=.*#server.info=Apache Tomcat#' \ CATALINA_BASE/lib/org/apache/catalina/util/ServerInfo.properties```
Score:0
in flag

The version info for the Apache server is defined in code, not in configuration or an external file. To change that you would need to fork the repo and build your own version after making the change.

merilstack avatar
cn flag
What change has to be made?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.