Conversation
[Hotfix] WAF 차단으로 인한 로그인 실패 문제 임시 조치
[Fix] ua 조건 제거 및 x-origin-verify Header 검사 추가
WalkthroughWAF 구성이 확장되었습니다: 기본 동작을 block으로 전환하고, 검증 헤더 기반 허용 규칙과 브라우저 요청 허용 규칙을 추가했으며, 기존 규칙의 우선순위를 재배치했습니다. 로깅에는 특정 헤더의 마스킹이 도입되었고, 로컬 변수의 임계값이 상향 조정되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant E as Edge/ALB
participant W as WAF Web ACL
participant R as Rules Engine
participant L as WAF Logging
participant S as SSM Parameter Store
Note over W: 기본 동작: Block (변경됨)
C->>E: HTTP(S) 요청
E->>W: 요청 검사 위임
par 초기화(계획/적용 시)
W->>S: /common/CLIENT_HEADER_SECRET 조회
S-->>W: x-origin-verify 시크릿
end
W->>R: 규칙 평가 시작 (우선순위 재정렬 반영)
alt 서버 검증 허용 규칙
R->>R: User-Agent(node/Vercel) AND x-origin-verify 매치
R-->>W: Allow
else 브라우저 허용 규칙
R->>R: header size constraints (origin/referer)
R-->>W: Allow
else 기타 규칙/관리형 그룹
R-->>W: Match? → Block / Count / Allow
else 매치 없음
Note over W: Default Block
W-->>E: Block
end
W-->>L: 로그 전송 (x-origin-verify 헤더 마스킹)
E-->>C: 응답
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
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. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
📄 Terraform Plan Summary🛡️ Common InfrastructureStatus: ✅ No Changes 🚀 Production EnvironmentStatus: ✅ No Changes 📋 Full Results: View in Actions |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
terraform/common/waf/main.tf (2)
13-77: User-Agent 기반 검증의 보안 취약점을 고려하세요.이 규칙은 User-Agent에 "node" 또는 "Vercel"이 포함되어 있고
x-origin-verify헤더가 일치하는 경우 요청을 허용합니다. User-Agent는 쉽게 위조 가능하므로 실질적인 보안은x-origin-verify헤더 검증에서만 제공됩니다.User-Agent 검증을 추가한 의도가 공격 표면을 줄이기 위한 것이라면 이해되지만,
x-origin-verify헤더만으로도 충분한 인증을 제공할 수 있습니다. User-Agent 검증이 정상 트래픽을 의도치 않게 차단할 가능성이 있는지 확인해주세요(예: Node.js 버전 업그레이드 시 User-Agent 문자열 변경).
1-272: WAF 설정 변경에 대한 단계적 배포 전략을 권장합니다.이 PR은 WAF 구성을 전면적으로 변경하여 allow-by-default에서 block-by-default로 전환합니다. 이는 중요한 보안 변경사항이며 잘못 구성 시 서비스 장애로 이어질 수 있습니다.
배포 전 확인사항:
- dev 환경에서 충분한 기간 동안 테스트되었는지
- 모든 정상 트래픽 패턴이 allow 규칙으로 커버되는지
/common/CLIENT_HEADER_SECRETSSM 파라미터가 prod 환경에 존재하는지- CloudWatch 메트릭과 로그 모니터링 설정이 준비되었는지
배포 전략 제안:
- 먼저 WAF를 count 모드로 배포하여 차단될 트래픽 패턴 확인
- CloudWatch 메트릭 모니터링
- 문제 없음 확인 후 block 모드 활성화
- 롤백 계획 준비
특히 "Allow-Browser-Requests" 규칙의 보안 취약점을 수정하는 것을 강력히 권장합니다.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
terraform/common/locals.tf(1 hunks)terraform/common/main.tf(1 hunks)terraform/common/waf/main.tf(7 hunks)
🧰 Additional context used
🪛 GitHub Actions: Notify Discord on `/noti` Comment
terraform/common/main.tf
[error] 1-1: No such file or directory
terraform/common/locals.tf
[error] 1-1: No such file or directory
terraform/common/waf/main.tf
[error] 1-1: No such file or directory
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (6)
terraform/common/locals.tf (1)
253-253: 프로덕션 환경의 트래픽 패턴에 대해 임계값을 검증하세요.request_threshold를 200에서 2000으로 10배 증가시켰습니다. WAF의 기본 동작이 block으로 변경된 점을 고려할 때, 이 임계값이 프로덕션 트래픽 패턴에 적합한지 확인이 필요합니다. dev 환경에서 이 설정이 충분히 테스트되었는지, 그리고 정상적인 피크 트래픽이 이 제한에 걸리지 않는지 확인해주세요.
terraform/common/main.tf (1)
77-81: LGTM!WAF 로그에서
x-origin-verify헤더를 마스킹하는 설정이 올바르게 추가되었습니다. 인증 토큰이 로그에 노출되는 것을 방지하는 필수적인 보안 조치입니다.terraform/common/waf/main.tf (4)
126-143: LGTM!Rate-Limit 규칙의 우선순위가 20으로 조정되어 allow 규칙들(우선순위 5, 10) 이후에 실행됩니다. 이는 올바른 순서입니다. 다만 IP당 2000 요청/5분 제한이 프로덕션 트래픽에 적합한지는 앞서 언급한 대로 검증이 필요합니다.
148-248: LGTM!모든 AWS Managed Rule의 우선순위가 일관되게 조정되어 새로운 allow 규칙(우선순위 5, 10)과 rate-limit 규칙(우선순위 20) 이후에 실행됩니다. 상대적인 우선순위 순서는 유지되어 올바른 실행 순서를 보장합니다.
1-3: SSM 파라미터 존재 및 SecureString 타입 수동 확인 필요
/common/CLIENT_HEADER_SECRETSSM 파라미터가 AWS 콘솔 또는 권한 있는 CLI로 존재하며 SecureString으로 설정되어 있는지 수동으로 확인하세요. 누락되거나 타입이 올바르지 않으면 Terraform 배포가 실패합니다.
9-11: 기본 동작이 allow→block으로 변경된 주요 보안 변경입니다.명시적 allow 규칙이 누락되면 정상 트래픽이 차단될 수 있으므로, dev 환경에서 브라우저 요청·서버 간 통신·외부 API 호출 등 모든 정상 트래픽이 허용되는지 반드시 검증하세요.
leegwichan
left a comment
There was a problem hiding this comment.
승로님 고생하셨습니다! 여러 일 병행하시면서 서비스 개선까지 하시는 모습 너무 존경스럽습니다!
|
🎉 This PR is included in version 1.9.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |



✨ 개요
🧾 관련 이슈
🔍 참고 사항 (선택)
Summary by CodeRabbit