feat: 업로드 파일 내용(시그니처) 확인과 악성코드 검사 지점 - #116
Merged
Merged
Conversation
확장자와 Content-Type 은 클라이언트가 정하는 값이라, HTML·SVG 를 .png 로 올리면 기존 검사를 모두 통과했다. 브라우저가 내용을 보고 문서로 해석하면 저장형 XSS 가 된다. - FileSignatureValidator: 앞 16바이트가 확장자 형식(jpg/png/gif/webp/heic/pdf)인지 확인. 400 C006 - FileScanner 검사 지점: 기본 NoOp, STORAGE_SCAN_ENABLED=true 면 ClamAV(clamd INSTREAM, 의존성 없음) 악성 400 C007, 검사기 장애는 받지 않는다(fail-closed) 503 C008 - 저장은 검사한 바이트 그대로 쓴다 (스트림을 다시 열지 않음) - docker compose --profile scan 으로 clamav 를 함께 띄울 수 있다 - docs/reference/file-upload-security.md S3 + 서명 URL 은 비용·계정 결정이 필요해 이 변경에 넣지 않았다.
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.
Refs #49 (S3·서명 URL 은 남아 있어 이슈는 열어 둔다)
이슈 할 일 대응
FileSignatureValidatorFileScanner(NoOp 기본 / ClamAV), fail-closedFileStorageService구현체만 추가하면 된다오류 응답
테스트
FileSignatureValidatorTest— 7개 형식 인식, SVG/HTML/WAVE/isom/짧은 입력/모르는 확장자 거절LocalFileStorageServiceSecurityTest— 위장 파일·악성 판정 시 디스크에 아무것도 남지 않음, 검사기 장애 503ClamAvFileScannerTest— 가짜 clamd 로 INSTREAM 조각 전송(150KB → 3조각)·OK/FOUND 해석·연결 실패docker compose config통과실제 clamd 컨테이너로는 돌려 보지 않았다(이미지가 시그니처 DB 포함 1GB+). 프로토콜은 가짜 서버로 확인했다.