← All issues

[20] [WebCore] Fix INT32_MIN UB in BackForwardController distance arithmetic

Severity: Low | Component: WebKit UIProcess back/forward navigation | a6cd3ca

BackForwardController::canGoBackOrForwardWebBackForwardList::itemAtDeltaFromCurrentIndexINT32_MIN 산술 경로를 보강한 패치입니다. 패치 이전에는 INT32_MIN에서 static_cast<unsigned>(-distance)가 UB에 해당하며 underflow guard를 우회할 수 있었습니다. 다만 다운스트림 영향은 back-forward list 배열 인덱싱 범위 안에 한정되며, 제어 가능한 memory primitive를 제공하지는 않습니다.

부호 있는 negation이 안전한 widened 산술 연산으로 교체되었습니다. delta/distance 계산에는 더 넓은 타입이 사용되거나, negation 수행 전 INT32_MIN guard가 삽입됩니다.

Source/WebCore/history/BackForwardController.cpp

- return static_cast<unsigned>(-distance) <= backCount();
+ return distance != std::numeric_limits<int>::min() && static_cast<unsigned>(-distance) <= backCount();

공격자가 backForwardItemAtIndexForWebContent IPC를 통해 INT32_MIN을 전달할 수 있는 underflow guard 내의 signed integer overflow.

negation에 INT32_MIN guard가 추가되었습니다. 이 guard는 WebBackForwardList::itemAtDeltaFromCurrentIndex에도 동일하게 적용됩니다.

backForwardItemAtIndexForWebContent는 UI process의 IPC handler입니다. WebContent process가 현재 인덱스로부터의 delta를 전송하면, handler가 back/forward stack을 순회합니다.

패치 이전에는 음수 distance 분기에서 negation이 부호 있는 산술 연산으로 수행되었습니다. static_cast<unsigned>(-distance)는 먼저 -distanceint로 평가한 뒤 캐스팅합니다. distance == INT32_MIN인 경우 -INT32_MIN은 양수 int로 표현할 수 없어, signed integer overflow — 즉 UB — 가 발생합니다.

🔒

Explores how a single-line arithmetic pattern crosses an IPC trust boundary, and what realistically follows from undefined behavior in a privileged-process bounds check.

더 확인하려면 구독해 주세요

🔒

Multiple reusable audit patterns identified for finding sibling instances across WebKit's IPC surface, with concrete grep starting points.

더 확인하려면 구독해 주세요