주입 스캐너 inspect injection O(n^2) DoS 2건 수정 — 서술어 앞 한정·발췌 1회 수집 (#4835) - #4836
Closed
kevin9327 wants to merge 1 commit into
Closed
주입 스캐너 inspect injection O(n^2) DoS 2건 수정 — 서술어 앞 한정·발췌 1회 수집 (#4835)#4836kevin9327 wants to merge 1 commit into
kevin9327 wants to merge 1 commit into
Conversation
…4835) 유효 컨테이너에 악성 본문을 심은 퍼징에서, 파싱은 성공하나 `inspect injection` 스캔이 이차로 폭주하는 DoS 2건을 잡아 고친다(injection_scan.rs 고유 결함). - 버그 A: governing_object_start·scope_governs_override 가 목적어·범위어를 find_from 으로 문서 끝까지 훑는다. 건초더미를 &chars[..verb_at] 로 한정 — 서술어 뒤 매치는 원래 버렸으므로 매치 집합 동일, 낭비 스캔만 제거(선형). - 버그 B: visit_text 가 신호마다 make_excerpt 로 text.chars() 를 다시 모은다. chars 를 문단당 한 번만 모아 재사용(make_excerpt 를 excerpt_from_chars 코어로 분리). 실측(디버그): 버그 A "무시하"×32k 10.15s→1.23s, ×128k 타임아웃→4.21s. 정상 문서 17건 × 5명령(inspect/redact/sanitize) 출력 불변. 회귀 테스트 2건 추가. cargo test --lib 3704 통과·무회귀. rustfmt --check 통과. 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. |
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.
무엇을 · 왜
inspect injection주입 스캐너의 O(n^2) 알고리즘 DoS 2건을 고친다(#4835).유효 HWPX 컨테이너에 악성 본문을 심어 퍼징한 결과, 파싱은 성공하지만 스캔 로직이
이차로 폭주해 작은 악성 문서 하나로
rhwp inspect injection이 멈춘다. 렌더러/파서오버플로(#4817·#4820)와는 별개인 주입 스캐너 고유 결함이다.
src/document_core/queries/injection_scan.rs한 파일만 바꾼다.버그 A — 한국어 무효화 관용구 탐색이 문서 끝까지 헛돈다
governing_object_start·scope_governs_override는 서술어("무시하" 등) 매치마다목적어·범위어를
find_from(chars, ...)로 찾는데, 이 탐색이 건초더미 끝까지 간다.목적어는 서술어 앞에서만 의미가 있는데도(코드가
j >= verb_at로 이미 버린다)그 앞을 넘어서까지 훑는다. 목적어 없는 서술어를 반복한 입력에서 매 매치가 문서 끝까지
헛돌아 O(n^2).
수정: 건초더미를
&chars[..verb_at]로 한정. 서술어 뒤 매치는 원래 버렸으므로매치 집합 동일, 낭비 스캔만 제거(선형).
버그 B — 신호마다 발췌를 다시 만든다
SignalSite::visit_text가 신호 하나마다make_excerpt(text, ...)를 부르고, 그 안에서text.chars().collect()로 문단 전체를 다시 모은다. 신호가 O(n)개 나오면 O(n^2).수정:
visit_text가chars를 문단당 한 번만 모아 재사용(
make_excerpt를&[char]받는excerpt_from_chars코어로 분리). 발췌 내용 동일.실측 (수정 전 → 후, 디버그 빌드)
"무시하 "×N(목적어 없음)버그 A 는 입력 4배에 시간 15배(≈이차) → 고친 뒤 선형.
검증
포함 7)에
inspect injection·hidden-text·unicode·redact --dry-run·sanitize전량 실행 → 산출 경로 토큰 제외 완전 동일(발췌·신호·순서 포함).
문단(버그 B) → 선형 시간 + 탐지 규칙 불변 고정.
cargo test --lib무회귀. 변경 파일rustfmt --edition 2021 --check통과.