fix(actuator): 관리 포트를 loopback에 고정해 무인증 노출을 막는다
`management.server.address`가 비어 있어 Spring이 관리 커넥터를 모든 인터페이스
(0.0.0.0)에 바인딩했다. 별도 포트는 별도 네트워크가 아니다. 그 포트의
health·prometheus·info는 permitAll이고 actuator 체인에 인증 메커니즘이 없어,
파드/호스트 네트워크의 누구에게나 무인증으로 응답한다.
동적으로 확인했다(bootRunH2): `ss`가 `*:9001`, `curl :9001/actuator/health·info·
prometheus`=200. info는 build group/artifact/version·capabilities를, prometheus는
disk 경로·free/total·JVM·timing을 유출한다(API 표면·인프라 토폴로지). compose의
`127.0.0.1:9001` publish는 Docker 호스트만 막고 같은 compose 네트워크의 형제
컨테이너나 NetworkPolicy 없는 k8s/bare 배포는 막지 못한다. 선행 리뷰(07-13)는
compose publish만 확인했고 앱의 bind 주소는 보지 않았다.
observability.yml에 `management.server.address: ${MANAGEMENT_SERVER_ADDRESS:
127.0.0.1}`를 둬서 posture가 compose·NetworkPolicy에 의존하지 않고 앱 자체에서
loopback으로 닫히게 한다. 원격 스크레이프 배포는 그 env를 명시하거나 loopback
사이드카로 긁는다. 노출 allowlist는 그대로다.
버린 대안:
- 하드코딩 `127.0.0.1` → operator override 불가, env-driven 관례 위반.
- compose/NetworkPolicy에만 의존 → 앱 밖 설정에 보안 posture를 맡김(이 발견의 원인).
검증: 막는 계약 시험 `actuator-contract:management-address-loopback`를 더했다.
desktop에서 RED→GREEN 확인 — address 줄을 빼면 그 시험이 실패(rc=1,
ManagementActuatorSecurityContractTest.java:239 AssertionError), 넣으면
`:app-bootstrap:test` rc=0. build-logic `EnvContractVerifierTest` rc=0(env-keys와
설정 정합).
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
+29
@@ -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<String, Object> 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:<default>}) 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:<loopback>}")
|
||||
.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<String, Object> mgmt = managementSubtree();
|
||||
|
||||
Reference in New Issue
Block a user