fix: 코드 리뷰 기반 보안·안정성 개선 2차
All checks were successful
Server CI/CD / deploy (push) Successful in 1m26s

보안:
- RPC 응답 HTTP 상태코드 검증 (chain/client)
- SSAFY OAuth 에러 응답 내부 로깅으로 변경 (제3자 상세 노출 제거)
- resolveUsername에서 username 노출 제거
- LIKE 쿼리 특수문자 이스케이프 (bossraid/repository)
- 파일명 경로 순회 방지 + 길이 제한 (download/handler)
- ServerAuth 실패 로깅 추가

안정성:
- AutoMigrate 에러 시 서버 종료
- GetLatest() 에러 시 nil 반환 (초기화 안 된 포인터 방지)
- 멱등성 캐시 저장 시 새 context 사용
- SSAFY HTTP 클라이언트 타임아웃 10s
- io.ReadAll/rand.Read 에러 처리
- Login에서 DB 에러/Not Found 구분

검증 강화:
- 중복 플레이어 검증 (bossraid/service)
- username 길이 제한 50자 (auth/handler, bossraid/handler)
- 역할 변경 시 세션 무효화
- 지갑 복호화 실패 로깅

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 17:48:05 +09:00
parent 61cf47070d
commit cc751653c4
12 changed files with 85 additions and 19 deletions

View File

@@ -27,6 +27,9 @@ func (h *Handler) Register(c *fiber.Ctx) error {
if req.Username == "" || req.Password == "" {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "아이디와 비밀번호를 입력해주세요"})
}
if len(req.Username) > 50 {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "아이디는 50자 이하여야 합니다"})
}
if len(req.Password) < 6 {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "비밀번호는 6자 이상이어야 합니다"})
}
@@ -111,9 +114,12 @@ func (h *Handler) UpdateRole(c *fiber.Ctx) error {
if err := c.BodyParser(&body); err != nil || (body.Role != "admin" && body.Role != "user") {
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"error": "role은 admin 또는 user여야 합니다"})
}
if err := h.svc.UpdateRole(uint(id), Role(body.Role)); err != nil {
uid := uint(id)
if err := h.svc.UpdateRole(uid, Role(body.Role)); err != nil {
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"error": "권한 변경에 실패했습니다"})
}
// 역할 변경 시 기존 세션 무효화 (새 권한으로 재로그인 유도)
_ = h.svc.Logout(uid)
return c.JSON(fiber.Map{"message": "권한이 변경되었습니다"})
}