Skip to content

Fix: UploadRateLimitAspect TTL 미설정 경쟁 조건 수정 #247

Description

@jjh75607

목적

increment → getExpire → expire 패턴의 비원자적 실행으로 Redis TTL이 미설정되어 사용자 계정이 영구 차단될 수 있는 버그를 수정하기 위해

작업 상세 내용

  • UploadRateLimitAspect.checkRateLimit()을 원자적 패턴으로 교체 (UploadRateLimitAspect.java:40)
    • redisTemplate.opsForValue().setIfAbsent(key, "1", duration) 성공 시 → 첫 요청으로 처리, 이후 increment
    • 또는 increment + TTL 설정을 Lua 스크립트 단일 명령으로 처리
  • TTL 누락으로 카운터가 리셋되지 않는 시나리오 테스트 추가

참고 사항

  • 현재 코드: increment()getExpire()ttl == -1L이면 expire() 설정
  • 두 스레드가 동시에 첫 increment를 실행하면 둘 다 ttl == -1L을 읽어 expire를 중복 호출하거나 누락할 수 있음
  • docs/project-audit.md SEC-M1 참고

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions