fix(parser/hwpx): HwpUnitChar 값 2× 스케일 정수 오버플로 패닉 하드닝 — 손상 .hwpx DoS (#4839) - #4840
Closed
kevin9327 wants to merge 1 commit into
Closed
fix(parser/hwpx): HwpUnitChar 값 2× 스케일 정수 오버플로 패닉 하드닝 — 손상 .hwpx DoS (#4839)#4840kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
손상 .hwpx 의 header.xml HwpUnitChar <hp:case> 안 극단 정수값이 2× IR 스케일 변환(* 2)에서 곱셈 오버플로 패닉을 유발해 info/export-text/ export-structure/convert 전부가 손상 문서 한 건에 프로세스째 죽던 DoS 를 수정한다. header.rs 세 곳의 * 2 를 saturating_mul(2) 로 교체: - 1288: 문단 여백 left/right/intent/prev/next (i32) - 1357: 문단 lineSpacing (i32) - 1907: 탭 position (u32) 정상 문서 값은 수천 HWPUNIT 수준이라 무영향이고, 극단값만 i32::MAX/ u32::MAX 로 포화되어 그레이스풀하게 처리된다. 회귀 테스트 추가. 정상 샘플 3종 info/export-text/export-structure 출력 바이트 동일, cargo test --lib 3703 passed/0 failed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
jangster77
self-requested a review
August 15, 2026 13:29
Collaborator
|
통합 PR #4883(4412546)로 병합 완료했습니다. 원 head와 CI를 다시 확인해 누적 반영했고, 상세 검토·메인터너 보정·검증 근거는 archive 검토 기록에 남겼습니다. 중복 병합을 막기 위해 이 원 PR을 닫습니다. 감사합니다. |
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.
배경
close #4839
손상되거나 조작된
.hwpx의Contents/header.xml에서 HwpUnitChar<hp:case>안 극단 정수값이 "HwpUnitChar 1× → HWP5 2× IR 스케일" 변환(* 2)에서 정수 곱셈 오버플로 패닉을 일으킨다.parse_hwpx_header가 그대로 죽으면서info/export-text/export-structure/convert전부가 손상 문서 한 건에 프로세스째 종료된다 (DoS, exit 101). 퍼징(원본 바이트 손상 + XML 파트 손상, 샘플 4종)으로 발견했다.변경
src/parser/hwpx/header.rs세 곳의* 2를saturating_mul(2)로 교체한다. 셋 다 같은 스케일 변환이며 오버플로 가드가 없었다.1288i321357i321907u32정상 문서 값은 수천 HWPUNIT 수준이라 결과가 바뀌지 않고, 극단값만
i32::MAX/u32::MAX로 포화되어 그레이스풀하게 처리된다. (같은 함수의exact_value_from_default는 이미i64::from(...)승격이라 안전하다 — 손대지 않음.)재현 (수정 전)
정상
.hwpx의<hh:paraPr>에 HwpUnitChar<hp:case>+<hc:left value="2000000000"/>주입 후:exit 101. 호출 사슬:
parse_para_shape_switch→parse_para_shape→parse_hwpx_header→parse_hwpx.검증
info/export-text/export-structure/convert모두 exit 0, 패닉 없음.SO-SUEOP/hwp3-sample-hwpx/HWP5-nopassword-123456)의info/export-text/export-structure출력 바이트 동일(회귀 없음).hwpunitchar_oversized_value_saturates_without_panic추가 (여백·줄간격·탭 세 경로 모두 포화 확인).cargo test --lib3703 passed / 0 failed.rustfmt --edition 2021 --check src/parser/hwpx/header.rs통과.범위
HWPX 파서 전용(
src/parser/hwpx/header.rs)에 한정한다. renderervertical_pos+line_height,parser/mod.rs오버플로(#4821), HWP5 body 재귀(#4830) 등 다른 DoS 는 별도 PR 이 다루므로 건드리지 않았다.