diff --git a/docs/registries/env-keys.yaml b/docs/registries/env-keys.yaml index fa58d49c..1f883922 100644 --- a/docs/registries/env-keys.yaml +++ b/docs/registries/env-keys.yaml @@ -83,6 +83,19 @@ env_keys: reload_policy: restart-only owner_branch: feature-management-actuator-security-contract validation: port_range_1_65535 + + - name: MANAGEMENT_SERVER_ADDRESS + # source: W4 red team BE-CONFIG-001 2026-11-11 — management.server.address was unset, so the + # actuator connector bound every interface; health/prometheus/info (permitAll) were reachable + # unauthenticated off-loopback. Default to loopback; remote scraping sets this explicitly. + type: string + default: 127.0.0.1 + allowed_values: null + classification: public-config + required: false + reload_policy: restart-only + owner_branch: feature-management-actuator-security-contract + validation: host_or_ip_address compatibility_impact: behavior-change required_test: actuator-contract:management-port-separated diff --git a/src/bootstrap/app/src/main/resources/config/observability.yml b/src/bootstrap/app/src/main/resources/config/observability.yml index 06babdfb..327a862e 100644 --- a/src/bootstrap/app/src/main/resources/config/observability.yml +++ b/src/bootstrap/app/src/main/resources/config/observability.yml @@ -27,6 +27,11 @@ management: # endpoints are not exposed on the same socket as the app API. Default: 9001. server: port: ${MANAGEMENT_SERVER_PORT:9001} + # W4 red team BE-CONFIG-001: an unset address binds every interface, so health/prometheus/info + # (permitAll, no auth mechanism) are reachable unauthenticated from any pod/host on the network — + # a separate PORT is not a separate NETWORK. Pin the bind to loopback by default; a deployment + # that scrapes remotely sets MANAGEMENT_SERVER_ADDRESS explicitly (or scrapes via a loopback sidecar). + address: ${MANAGEMENT_SERVER_ADDRESS:127.0.0.1} endpoints: web: # D2: production allowlist — only safe, scrape-friendly endpoints are exposed. The actuator diff --git a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java index b94041c6..d19d0f47 100644 --- a/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java +++ b/src/bootstrap/app/src/test/java/dev/caskeleton/bootstrap/contract/ManagementActuatorSecurityContractTest.java @@ -7,6 +7,7 @@ import dev.caskeleton.bootstrap.contract.support.ShippedConfiguration; import dev.caskeleton.shared.error.Category; import dev.caskeleton.shared.error.OperationalError; import java.io.InputStream; +import java.net.InetAddress; import java.nio.file.Files; import java.nio.file.Path; import java.util.LinkedHashMap; @@ -222,6 +223,34 @@ class ManagementActuatorSecurityContractTest { .isEqualTo("${MANAGEMENT_SERVER_PORT:9001}"); } + // ---- actuator-contract:management-address-loopback (BE-CONFIG-001) ---- + // A separate management PORT is not a separate NETWORK: with management.server.address unset, + // Spring binds the actuator connector to every interface, so health/prometheus/info (permitAll, + // no auth mechanism) answer any pod/host on the network. application.yml must pin the bind to a + // loopback default so the posture holds without depending on Compose publish or a NetworkPolicy. + @Test + void applicationYmlManagementAddressPinsLoopbackDefault() throws Exception { + Map mgmt = managementSubtree(); + Object address = nested(mgmt, "server", "address"); + + assertThat(address) + .as("application.yml must pin management.server.address — unset binds all interfaces " + + "(BE-CONFIG-001): health/prometheus/info reachable unauthenticated off-loopback") + .isNotNull(); + + // Keep it env-driven (${MANAGEMENT_SERVER_ADDRESS:}) so a remote-scrape deployment can + // opt in, and require the shipped DEFAULT to be a loopback address. + String expr = String.valueOf(address); + assertThat(expr) + .as("management.server.address must stay env-driven ${MANAGEMENT_SERVER_ADDRESS:}") + .startsWith("${MANAGEMENT_SERVER_ADDRESS:") + .endsWith("}"); + String defaultValue = expr.substring(expr.indexOf(':') + 1, expr.length() - 1); + assertThat(InetAddress.getByName(defaultValue).isLoopbackAddress()) + .as("management.server.address default must be a loopback address, but was: " + defaultValue) + .isTrue(); + } + @Test void applicationYmlPinsShowDetailsNeverAndShutdownDisabled() { Map mgmt = managementSubtree();