[12] [WebCore] Re-validate same-origin after CSP sandbox application in view transitions
CSP sandbox 적용으로 새 document의 effective origin이 opaque 상태로 전환된 경우, view-transition pipeline이 캡처된 snapshot을 처리하지 않도록 Document::reveal() 시점에 second origin check를 추가했습니다. 패치 이전에는 outgoing document에서 캡처된 ImageBuffer와 element name이 sandbox-opaque document로 유출되었습니다. High로 평가된 이유입니다.
Document::reveal은 ViewTransitionParams를 설치하기 전에, source document의 origin과 새 document의 CSP 처리 이후 securityOrigin() 사이에서 same-origin 재검증을 수행합니다.
Source/WebCore/dom/Document.cpp
URL에서 도출된 origin 판단과 CSP 처리 이후 최종 origin 사이의 TOCTOU: CSP sandbox opaque-origin document에 cross-document view transition snapshot 설치.
Patch Details
Document::reveal에 CSP 처리 이후의 securityOrigin()을 사용하는 최종 same-origin check가 추가되었습니다. navigation 시작 시점의 admission gate(URL에서 도출된 origin)는 변경되지 않았습니다.
Background
Cross-document view transition은 outgoing document에서 element image와 geometry를 snapshot으로 캡처한 뒤, incoming document에서 재생합니다. 이 pipeline이 동작하려면 document 간 same-origin 조건이 충족되어야 합니다. HTML spec에 따르면, allow-same-origin 없이 Content-Security-Policy: sandbox가 지정되면 CSP 처리 이후 document의 effective origin이 opaque origin으로 교체됩니다.
Analysis
패치 이전 pipeline은 same-origin check를 한 번만 수행했습니다. 검사 시점은 DocumentLoader::navigationCanTriggerCrossDocumentViewTransition의 navigation 시작 단계로, response의 URL에서 도출된 origin을 기준으로 판단했습니다. CSP 처리는 이 이후에 실행됩니다. 결과적으로 Document::reveal() 내에서 resolveInboundCrossDocumentViewTransition이 실행되는 시점에는 이미 securityOrigin()이 opaque 상태였지만, pipeline은 재검증을 수행하지 않았습니다.
재검증 없이 내려진 admission 판단으로 인해, 이전 page에서 캡처된 데이터가 CSP sandbox 적용 이후 opaque origin으로 전환된 document에 유입되었습니다. 유입된 항목으로는 OrderedNamedElementsMap namedElements, initialLargeViewportSize, initialPageZoom, 그리고 ImageBuffer snapshot이 있습니다. 이로써 cross-origin pixel 읽기와 element metadata 유출이라는 exploit primitive가 확보됩니다.
이는 CSP sandbox가 적용된 환경에서 view transition snapshot 전달 과정의 same-origin invariant를 약화시킵니다.
Audit directions
- CSP/sandbox 적용 전 URL에서 origin을 계산하는 다른 admission gate. navigation 시점의 check가 이후 document lifecycle 단계에서 처리되는 모든 지점은
securityOrigin()에 대한 재검증이 필요합니다. ViewTransitionParams를 처리하는 코드. params를 읽는 모든 지점에서 현재 origin 일치 여부를 확인해야 합니다. 설치 시점의 check에만 의존해서는 안 됩니다.- cross-document 상태를 처리하는 다른 HTML spec 기능 (Document Picture-in-Picture, BFCache restoration animation)에서 동일한 TOCTOU 패턴이 있는지 확인해야 합니다.