← All reports

[Remote Snapshotting] Serialize fonts, gradients, filters and graphics state by value

Component: WebCore Display Lists | f59de9b

Source/WebCore/platform/graphics/displaylists/DisplayList.cpp

+RefPtr<const DisplayList> DisplayList::createResolvingResources(Vector<Item>&& items, std::span<const Ref<const FontBase>> fonts, std::span<const Ref<const DisplayList>> displayLists)
+{
+ for (auto& item : items) {
+ bool isValid = WTF::switchOn(item,
+ [&](DrawDisplayList& item) {
+ if (item.isResolved())
+ return true;
+ if (item.displayListIndex() >= displayLists.size())
+ return false;
+ item.setDisplayList(displayLists[item.displayListIndex()].copyRef());
+ return true;
+ },
+ [&](DrawGlyphs& item) {
+ if (item.glyphs().size() != item.advances().size())
+ return false;
+ ...
+ if (item.fontIndex() >= fonts.size())
+ return false;
+ item.setFont(fonts[item.fontIndex()].copyRef());
+ return true;
+ },
+ ...
+ if (!isValid || !isResolved(item))
+ return nullptr;
+ }
+ return create(WTF::move(items));
+}

Remote snapshotting에서는 GPU process가 페이지 내용을 display list로 기록합니다. 이 display list는 print process로 전달되고, print process가 이를 replay하여 PDF 출력을 생성합니다. 이때 GPU process가 렌더링하는 web content에는 cross-origin iframe이 포함될 수 있습니다. 즉 serialize된 list 안에 신뢰할 수 없는 페이지에서 유래한 데이터가 실릴 가능성이 있습니다.

한편 font, 중첩 display list, web font data는 여러 곳에서 공유되는 객체입니다. 그래서 index table로 중복을 제거한 뒤, item 내부에서는 index로 참조합니다. 수신 측은 먼저 font를 만들고, 이어서 display list를 bottom-up 순서로 생성하여 table을 재구성합니다. 그런 다음 item 안의 index를 실제 객체로 다시 채워 넣습니다.

이번 변경으로 DisplayListData는 font, web font data, gradient, graphics state, control part, system image, filter를 값 그대로 encode하게 되었습니다. DrawGlyphs와 DrawDisplayList는 이제 Font나 중첩 DisplayList 대신 index를 보유할 수 있습니다. Decoder는 font, web-font, bottomUpDisplayLists table에서 이 index를 해석하며, 해석되지 않은 item이 하나라도 남으면 decode를 실패 처리합니다. 다만 image, pattern brush, ARKit badge가 필요한 item과 source image 또는 FEImage를 가진 filter는 여전히 encode에 실패합니다.

GPU process                                   Print process
  encode: webFontData[] ─► fonts[] ─► bottomUpDisplayLists[]
                    │ IPC
                    ▼
  decode: parse webFontData ─► create Fonts ─► create nested DLs
          ─► create outer DL, replace indices with objects
          ─► any item still isResolved()==false ─► decode FAILS

GPU process로부터 받은 web font 바이트와 index로 연결된 객체 그래프를 parsing하는 cross-process decoder가 print process에 새로 생겼습니다. 이전까지 GPU-to-print 채널은 단순한 값 형태의 item만 전달했습니다. 결과적으로 이 채널의 공격 표면이 크게 넓어진 셈입니다.