Repository navigation
fix: presigned URL 발급 요청의 개수와 경로를 검증한다 - #832
Merged
Merged
Conversation
- uploadSize는 1 이상 50 이하만 허용한다 (INVALID_UPLOAD_SIZE, 400) - rootPath는 필수, 100자 이하, 앞뒤 / 한 개씩 제거 후 영문·숫자·_·- 세그먼트만 허용한다 (INVALID_ROOT_PATH, 400) - 검증은 URL 생성과 리소스 로그 저장 전에 수행하며 사용자·admin 경로에 함께 적용된다 - API 문서에 제약과 400 응답을 선언하고 OpenAPI 스냅샷 기준 파일을 갱신한다 Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
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.
배경
보안 검토에서
GET /api/v1/s3/presign-url과 admin 업로드 경로의 입력 검증이 없다는 점을 확인했다.uploadSize에 상한이 없다. 인증된 사용자가 요청 한 번으로 presigned URL과 리소스 로그 행을 원하는 만큼 생성시킬 수 있다. 0과 음수도 검증하지 않는다.rootPath가 검증 없이 S3 key 접두사가 된다. 값이 없으면 NPE로 500이 난다.변경 동작
uploadSizeINVALID_UPLOAD_SIZErootPath/한 개씩 제거 후[A-Za-z0-9_-]+(/[A-Za-z0-9_-]+)*INVALID_ROOT_PATHPreSignUrlProvider.validateUploadRequest에 두고ImageUploadService가 URL 생성과 로그 저장 전에 호출한다. 사용자 경로와 admin 경로에 함께 적용된다.호환성
다음 요청은 이 변경 뒤 400이 된다. 프런트엔드가 실제로 보내는 값은 이 저장소로 확인할 수 없으므로 병합 전에 확인이 필요하다.
rootPath에., 공백, 한글,//를 쓰거나 100자를 넘는 경우rootPath를 보내지 않는 경우 (기존에는 500)저장소 안에서 쓰이는 값은
uploadSize1~3,rootPathreview·admin/test·admin/upload-test·admin/multi-upload이며 모두 새 규칙을 통과한다. 운영resource_log.root_path의 distinct 값을 확인하면 실제 사용 값을 알 수 있다.검증
5748dc2의ci pipeline(pull_request)이 전체 성공했다. OpenAPI 스냅샷 테스트도 통과했다: https://github.com/bottle-note/bottle-note-api-server/actions/runs/46380009936추가한 테스트:
ImageUploadServiceTest:uploadSize0, -1, 1, 50, 51과rootPathnull, blank,.., 빈 세그먼트, 허용 외 문자, 100자와 101자. 위반 시 URL 생성 0회와 로그 0건.ImageUploadIntegrationTest,AdminImageUploadIntegrationTest: 경계값과 오류 코드, 위반 시 리소스 로그 없음.https://claude.ai/code/session_01DNr3PM1DZCQLC8RiGJwD3a
Generated by Claude Code