Skip to content

[global] actuator 관리 엔드포인트 허용 IP 접근 제한 - #12

Open
jyx-07 wants to merge 2 commits into
chore/eureka-defaultsfrom
feat/gateway-security
Open

jyx-07 wants to merge 2 commits into
chore/eureka-defaultsfrom
feat/gateway-security

Conversation

@jyx-07

@jyx-07 jyx-07 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

개요

actuator는 health만 공개하고, 나머지 관리용 엔드포인트는 허용 IP에서만 열리게 합니다.

본문

  • Spring Security 추가: 경로 접근 규칙, CORS, 보안 응답 헤더만 맡고 JWT 검증은 기존 필터 유지
  • gateway(라우트 조회만), circuitbreakers, info는 GATEWAY_ADMIN_ALLOWED_IPS에서만 접근, 그 외 403 공통 응답
  • 클라이언트 IP는 연결 IP 기준, TRUSTED_PROXIES에서 온 요청만 X-Forwarded-For 사용
  • config 서버 공통 설정이 exposure를 덮어쓰지 않도록 rush-gateway.yml에 지정

#10 위에서 작업했습니다. #10을 먼저 머지해 주세요.

@jyx-07
jyx-07 force-pushed the feat/gateway-security branch from 12bec58 to 6fe3dc1 Compare November 3, 2026 14:19

@cfcromn cfcromn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

잘못된 전달 IP를 처리하는 경우 하나 확인 부탁드립니다.

private val IPV4 = Regex("""^(\d{1,3})(\.\d{1,3}){3}$""")
private val IPV6 = Regex("""^[0-9a-fA-F:.]+$""")

fun isIpLiteral(value: String): Boolean = IPV4.matches(value) || (value.contains(':') && IPV6.matches(value))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

999.999.999.999도 이 정규식을 통과합니다. 신뢰 프록시에서 이 값을 전달하면 이후 IpAddressMatcher.matches()에서 파싱 예외가 발생해서 /actuator/info가 403 대신 500을 반환하는 것을 확인했습니다. 잘못된 IP는 접근 거부로 처리하고, 이런 입력도 테스트에 추가해 두면 좋을 것 같아요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cfcromn 92352b7 에서 반영했습니다. (근거: IpAddressMatcher가 잘못된 IP 리터럴에 예외를 던지는 Spring Security 동작) IPv4 옥텟 범위와 IPv6 형식을 검사해 잘못된 값은 IP가 아닌 것으로 보고, 매칭 중 예외가 나도 거부하도록 했습니다. 999.999.999.999 같은 입력은 IpRangeMatcherTest와 ClientIpResolverTest에 추가했습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 신규 기능

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants