OWASP / OWASP/SecurityShepherd
Replace brittle Tomcat server.xml/web.xml patches with a robust mechanism
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 515
- Avg merge
- 3h 46m
- Merged PRs (30d)
- 1
Description
Context
The Docker image configures Tomcat by patching the base image's stock config files:
docker/tomcat/serverxml.patch— adds the HTTPS connector, enables the thread-pool connector, comments out the plain 8080 connector.docker/tomcat/webxml.patch— adds aCONFIDENTIALtransport-guarantee security constraint.
These are context diffs pinned to a specific server.xml/web.xml. When the Tomcat base image changes those files, the context lines drift and the patch fails at docker build time.
This just bit us during the JDK 8 → 17 upgrade (#802 / PR #847): the Tomcat 9 base image (9.0-jre17-temurin) added maxParameterCount="1000" to its connectors, shifting context lines and causing serverxml.patch Hunk #1 to fail — breaking the Docker Compose Build CI step. Fixed in PR #847 by regenerating the patch, but the underlying fragility remains.
Problems
- Fragile across Tomcat upgrades: every base-image bump risks breaking the patch; failures only surface at image build time, not in a unit test.
- Hard to read:
serverxml.patchtoggles which connectors are commented out — the intent isn't obvious from the diff. - The
database.properties/mongo.propertiesfiles in theDockerfileare generated fresh withprintf(robust); only the XML config is patched (fragile).
Proposal
Replace the patch step with one of:
- Full config files — commit a complete
server.xml+web.xmlwith the HTTPS connector andCONFIDENTIALconstraint baked in, andCOPYthem into the image instead of patching. No more context-drift breakage; cost is owning the full config and re-syncing on major Tomcat changes. - Targeted in-place edits — use
sed/xmlstarletin the Dockerfile to uncomment the thread-pool connector and append the HTTPS connector. More resilient than a context diff, smaller than full files, but still some fragility if Tomcat restructures the XML.
Acceptance criteria
-
docker/tomcat/*.patchremoved (or the patch mechanism replaced). - HTTPS connector (port 8443, keystore wiring via the existing
TLS_KEYSTORE_FILE/TLS_KEYSTORE_PASS/ALIAS/HTTPS_PORTbuild args) preserved. -
CONFIDENTIALtransport-guarantee security constraint preserved. -
docker compose buildsucceeds; resulting container serves HTTPS and redirects HTTP → HTTPS as before. - Approach is resilient to (or at least fails loudly/early on) Tomcat base-image config changes.
Related
- #802 — JDK 8 → 17 upgrade (introduced the Tomcat 8 → 9 bump that exposed this)
- PR #847 — regenerated the patch as a stopgap
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading docker/tomcat/serverxml.patch, docker/tomcat/webxml.patch, and the Dockerfile steps that apply them, then inspect the related Tomcat configuration context. Compare the proposed full-file and targeted-edit approaches against the listed TLS and redirect requirements. Done means the patch mechanism is replaced, docker compose build succeeds, and HTTPS plus HTTP-to-HTTPS behavior are preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, java
- Domain
- backend, build-system, devops
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100