백오피스 게이트 경로 판정을 dispatcher 와 같게 정규화 - #987
Merged
Merged
Conversation
- shouldNotFilter 가 raw requestURI 로 게이트 적용 여부를 판정하는데 Spring 은 디코딩 경로로 라우팅해, /%61dmin/announcements 가 세션·세션-IP 바인딩·allowlist 검사를 통째로 건너뛴 채 백오피스에 도달했다 - 로컬에서 게이트를 켜고(ADMIN_LOCAL_BYPASS=false) 실측: 수정 전 이 경로가 200 과 함께 공지 발송 페이지 HTML 을 그대로 반환했고, 수정 후 404 로 막힌다. 정상 /admin 은 세션 없으면 그대로 404, grant 진입점(/admin-access/**)은 400 으로 게이트를 통과해 흐름이 유지되는 것도 함께 확인했다 - matrix param(/admin;x=1/...)과 중복 슬래시(//admin/...)는 게이트는 뚫려도 메인 Security 체인이 401 로 막고 있었다. 실제 노출은 percent-encoding 경로 하나였지만, 판정 층이 어긋나 있다는 사실은 같으므로 함께 막는다 - 형제 필터 EnvironmentAccessFilter 가 같은 우회 유형을 이미 UrlPathHelper 로 막고 있었다. 그 구조(isGatedRequest/isGatedPath 를 companion 으로 노출)를 그대로 따라 두 게이트의 모양을 맞추고 경로 판정을 단위 테스트로 고정했다
|
Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Situation
AdminAccessFilter.shouldNotFilter가 게이트 적용 여부를 rawrequest.requestURI로 판정하는데, Spring 은 디코딩·정규화된 경로로 라우팅한다. 판정 층과 라우팅 층이 다른 경로를 보고 있었다.그래서
/admin을 다르게 표기하면 게이트만 건너뛰고 컨트롤러에는 그대로 도달했다.getRequestURI()가 디코딩되지 않은/%61dmin/announcements를 반환하므로uri == "/admin"과uri.startsWith("/admin/")이 모두 false 가 되고,shouldNotFilter가 true 를 리턴해 세션·세션-IP 바인딩·allowlist 검사가 한 줄도 실행되지 않았다.형제 필터인
EnvironmentAccessFilter는 이 우회 유형을/%64ocs/index.html예시까지 들어 주석에 문서화하고UrlPathHelper로 막아뒀다. 그 수정이 dev 문서 게이트에만 적용되고 prod 백오피스 게이트에는 적용되지 않았다.Task
Action
shouldNotFilter의 경로 판정을UrlPathHelper.defaultInstance.getPathWithinApplication기반으로 바꿨다.removeSemicolonContent·urlDecode가 기본 on 이라 matrix param 제거와 percent-decoding 이 함께 적용된다.isGatedRequest/isGatedPath로 companion 에 노출해EnvironmentAccessFilter와 구조를 맞췄다. 두 게이트가 같은 모양이면 한쪽만 고쳐지는 이번 같은 어긋남이 눈에 띈다./admin-access·/admin-assets가 과매칭되지 않는 것을 함께 잠갔다. 후자가 깨지면 grant 진입 자체가 막혀 아무도 백오피스에 못 들어간다.실측
로컬에서
ADMIN_LOCAL_BYPASS=false로 게이트를 실제로 켜고, 수정 전후 같은 요청을 보냈다. 쿠키 없음, allowlist 미등록 상태다./admin/%61dmin/announcements/admin/%69tem-quota/admin;x=1/announcements//admin/announcements/admin-access/grant수정 전
/%61dmin/announcements는 200 과 함께 백오피스 공지 발송 페이지 HTML 을 그대로 반환했다. 리뷰가 지적한 세 가지 표기 중 실제로 노출로 이어진 것은 percent-encoding 하나이고, matrix param 과 중복 슬래시는 게이트를 뚫은 뒤 메인 Security 체인이 401 로 막고 있었다. 다만 판정 층이 어긋나 있다는 사실은 셋 다 같으므로 함께 막았다./admin-access/grant가 404 가 아니라 400 인 것은 게이트를 통과해 컨트롤러까지 도달했고 파라미터가 없어 400 이 났다는 뜻이다. 이 수정이 grant 진입을 함께 막지 않았음을 확인하는 값이다.Result
/%류 경로로 훑어 실제 시도가 있었는지 확인해 볼 수 있다. 이번 PR 범위 밖이라 별도로 남긴다.연관 이슈