Skip to content

fix: HWPX 업로드 실제 파일 구조 검증 (ZIP·mimetype·section0.xml) - #110

Merged
chaeliki merged 4 commits into
mainfrom
fix/109-hwpx-signature-validation
Aug 7, 2026
Merged

fix: HWPX 업로드 실제 파일 구조 검증 (ZIP·mimetype·section0.xml)#110
chaeliki merged 4 commits into
mainfrom
fix/109-hwpx-signature-validation

Conversation

@chaeliki

@chaeliki chaeliki commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

왜 필요한가요?

Closes #109

#80(PR #91) 리뷰에서 발견된 문제입니다. HWP는 OLE 시그니처까지 검증하는데,
HWPX는 요청 MIME이 application/hwp+zip이면 실제 파일 구조와 무관하게
허용하고 있었습니다. Agent(문서 초안 작성) 쪽은 이미 실제 ZIP을 열어서
내부 mimetype과 Contents/section0.xml 존재 여부를 확인하고 있어, Server와
검증 수준이 불일치했습니다.

완료된 범위

  • HwpxSignatureValidator 신설 (HwpSignatureValidator와 같은 위치)
    • ZIP 파싱 가능 여부 확인
    • 내부 mimetype 항목 값이 application/hwp+zip인지 확인
    • Contents/section숫자.xml(section0, section1 등 호환 경로) 존재 확인
  • FileService에 .hwpx 전용 분기 추가, ALLOWED_MIME_TYPES에서
    application/hwp+zip 제거 (문자열 MIME 비교로 우회 가능했던 경로 차단)

결정 사항

  • ALLOWED_MIME_TYPES에서 application/hwp+zip을 제거했습니다. .hwpx가 아닌
    파일에 이 MIME을 붙여서 화이트리스트를 우회할 수 있는 경로가 있었고,
    이제 .hwpx는 항상 시그니처 검증을 거칩니다.
  • HwpSignatureValidator와 동일하게, MIME 타입은 신뢰하지 않고 확장자 +
    실제 내용만으로 판단합니다.

어떻게 검증했나요?

  • ./gradlew clean test — 전체 통과
  • HwpxSignatureValidatorTest 단위 테스트 6개 (정상 구조, mimetype 불일치,
    section0.xml 없음, ZIP 아님, 빈 파일, 대체 section 번호)
  • 통합 테스트 3개
    • 정상 HWPX + application/octet-stream → 201
    • 일반 문자열 + application/hwp+zip → 415
    • 일반 ZIP이지만 HWPX 내부 파일 없음 → 415
  • UNSUPPORTED_FILE_TYPE이 HttpStatus.UNSUPPORTED_MEDIA_TYPE(415)로
    매핑되는 것을 코드로 직접 재확인

참고

@chaeliki chaeliki added area:server Spring Boot API·도메인·DB·tenant·Task Workflow 영역; Prompt·모델·Provider 구현 제외 priority:P1 핵심 작업 다음으로 처리할 중요 작업 security:privacy 개인정보·접근권한·토큰·보안 영향이 있는 작업 type:feature 사용자 또는 Agent가 사용하는 기능 개발 labels Aug 7, 2026
@chaeliki
chaeliki marked this pull request as ready for review August 7, 2026 07:16
@chaeliki
chaeliki requested review from hywznn and krestar August 7, 2026 07:20
@hywznn

hywznn commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

이젠 저 부분 client에서 어떻게 연결될지를 생각하면 될 것 같네요 짱이십니다

@chaeliki
chaeliki merged commit b5b46f1 into main Aug 7, 2026
4 checks passed
@chaeliki
chaeliki deleted the fix/109-hwpx-signature-validation branch August 7, 2026 08:06
@chaeliki chaeliki linked an issue Aug 7, 2026 that may be closed by this pull request
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:server Spring Boot API·도메인·DB·tenant·Task Workflow 영역; Prompt·모델·Provider 구현 제외 priority:P1 핵심 작업 다음으로 처리할 중요 작업 security:privacy 개인정보·접근권한·토큰·보안 영향이 있는 작업 type:feature 사용자 또는 Agent가 사용하는 기능 개발

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Document] HWPX 업로드 실제 파일 구조 검증 (ZIP·mimetype·section0.xml)

2 participants