Repository navigation
fix(backend): secure deployment defaults - #627
Merged
Merged
Conversation
- docker-compose.yml: do not publish the database port, bind the backend to 127.0.0.1:8080 and activate the prod profile. The development override publishes the database on 127.0.0.1:5432 and activates the dev profile. - Jib image: set SPRING_PROFILES_ACTIVE=prod by default. - application.yml now holds the production defaults (Swagger and API docs off, production CORS origins, no database password fallback). The new dev profile enables them for local development, ./gradlew bootRun activates it. - Replace ForwardedHeaderFilter, which trusted X-Forwarded-* from any client, with Tomcat's RemoteIpValve (server.forward-headers-strategy=native) that only trusts loopback and private network proxies. - Document that a TLS reverse proxy is required and update the threat model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N7axs4a1fVatUhpWytJ3vr
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 10724937 | Triggered | Generic Password | 426523f | backend/src/test/resources/application-test.yml | View secret |
| 10724937 | Triggered | Generic Password | 426523f | backend/src/main/resources/application-dev.yml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
application.yml already holds the production defaults, so the public cache header (max-age 300) moves there as well and application-prod.yml is removed. The dev profile disables the cache header. Production no longer needs a Spring profile, so the image and docker-compose.yml do not set one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N7axs4a1fVatUhpWytJ3vr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docker-compose.yml: the database port is no longer published, and the backend binds to127.0.0.1:8080only. Docker port publishing bypasses host firewalls such as ufw. The development override (docker-compose.override.yml) publishes the database on127.0.0.1:5432and activates the newdevprofile.application.ymlnow holds the production settings: Swagger UI and API docs off, CSP header on, tormap.org CORS origins,Cache-Control: public, max-age=300on/relay/**, and no database password fallback.application-prod.ymlis removed, so production needs no Spring profile.application-dev.ymlfor local development: Swagger UI, CORS forhttp://localhost:3000, no cache headers, database password fallbackpostgres../gradlew bootRunactivates it unlessSPRING_PROFILES_ACTIVEis set.ForwardedHeaderFiltertrustedX-Forwarded-*from any client. It is replaced by Tomcat'sRemoteIpValve(server.forward-headers-strategy: native), which only applies these headers for connections fromserver.tomcat.remoteip.internal-proxies(loopback and private networks).THREAT_MODEL.mdis updated.SecurityRulesTestnow checks the real defaults (Swagger and OpenAPI denied, CSP header sent) instead of forcing them.SecuritySwaggerEnabledTestruns with thedevprofile.SecurityConfigTestchecks that noForwardedHeaderFilteris registered and that the native strategy is configured.Deployment notes
127.0.0.1:8080. Put a TLS-terminating reverse proxy on the same host in front of it. Clients that reached<host>:8080directly no longer can.docker compose exec database psql ...for admin access, or add a127.0.0.1port binding in your own override file.SPRING_DATASOURCE_PASSWORDorTORMAP_DATABASE_PASSWORD. Outside thedevprofile there is nopostgresfallback any more. The compose file already enforces it.SPRING_PROFILES_ACTIVE=prodkeeps working, because Spring ignores a profile without a config file, and can be removed. Never activatedevin production../gradlew bootRunand the compose override: setSPRING_PROFILES_ACTIVE=devto get Swagger,localhost:3000CORS, no cache headers and thepostgrespassword fallback.X-Forwarded-For,-Protoand-Hostare only trusted from loopback and private networks (10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7). If your proxy or CDN connects from another address, add it withSERVER_TOMCAT_REMOTEIP_INTERNAL_PROXIES. Otherwise the logged client IP will be the proxy's and the scheme will show ashttp.devprofile now sendsCache-Control: public, max-age=300on/relay/**.Testing
./gradlew test: 129 tests, all passing.docker compose config, with and without the override: no database port and the backend on127.0.0.1in production; database on127.0.0.1:5432and thedevprofile in development.postgres.No dependencies were added or changed, so no dependency vetting or SCA scan was needed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01N7axs4a1fVatUhpWytJ3vr