← All issues

[9] FairPlay CDM MTE hardening

Severity: Medium | Component: FairPlay CDM implementation in WebCore | 62e4c75

이 항목이 Medium으로 평가된 이유는 multi-stage exploit chain의 발판을 제거하는 hardening 조치이기 때문입니다. Commit에는 heap에 할당된 StringImpl 객체가 GPU process 내 arbitrary decrement primitive를 통해 exploit 가능하다고 명시되어 있으나, 실제 exploitation에는 공격자가 이미 해당 primitive를 보유한 상태여야 한다는 전제가 필요합니다.

FairPlay keySystem 문자열에 MAKE_STATIC_STRING_IMPL을 적용하여 StaticStringImpl을 heap 대신 __DATA 섹션에 배치하는 방식으로 변경되었습니다. Heap에 할당된 StringImpl 객체는 MTE 태그가 적용되지 않아, GPU process 내 arbitrary decrement primitive를 통한 exploit 가능성이 존재합니다.

Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm

const String& CDMInstanceFairPlayStreamingAVFObjC::keySystem() const
{
- static NeverDestroyed<String> keySystem { "com.apple.fps"_s };
- return keySystem;
+ static const NeverDestroyed<String> s_keySystem { MAKE_STATIC_STRING_IMPL("com.apple.fps") };
+ return s_keySystem;
}

이번 수정에서는 static String 초기화 방식이 변경되었습니다. 기존의 "com.apple.fps"_s 방식은 heap에 StringImpl wrapper를 생성합니다. 이를 MAKE_STATIC_STRING_IMPL("com.apple.fps")로 교체하여 StaticStringImpl이 binary의 __DATA 섹션에 위치하도록 했습니다. 아울러 변수에 const가 추가되고, 이름도 s_keySystem으로 변경되었습니다.

보안에 민감한 process에서 MTE 보호가 적용되지 않는 heap 할당 문자열 메타데이터. Arbitrary decrement primitive를 통해 reference count 조작이 가능한 구조.

MAKE_STATIC_STRING_IMPL은 컴파일 시점에 binary의 __DATA 섹션에 StaticStringImpl을 생성하는 WebKit 매크로입니다. Heap에 할당되는 StringImpl과 달리, StaticStringImpl에는 특수 플래그(s_refCountFlagIsStaticString)가 존재하여 reference counting 시스템이 increment/decrement 연산을 완전히 건너뜁니다. 이 객체는 해제되지 않습니다.

ARM Memory Tagging Extension(MTE)은 heap pointer와 해당 메모리 영역에 4비트 태그를 부여하는 하드웨어 기능입니다. 태그가 일치하지 않는 접근은 fault를 발생시킵니다. MTE는 heap 할당에는 적용되지만 static data 영역에는 적용되지 않습니다.

WebKit에서 _s 문자열 리터럴 suffix는 StringImplFromLiteral을 통해 StringImpl을 생성하는데, 이 경우에도 heap에 StringImpl wrapper가 할당됩니다. NeverDestroyed<T>는 내부 객체의 static destruction을 방지합니다.

수정 이전에는 CDMInstanceFairPlayStreamingAVFObjC::keySystem()"com.apple.fps"_s를 사용해 static String을 초기화했으며, 이 방식은 heap에 StringImpl을 할당합니다. Commit 메시지에 명시된 바와 같이, heap에 할당된 StringImpl 객체는 MTE 태그로 보호되지 않습니다.

GPU process 내에서 이미 arbitrary decrement primitive를 확보한 공격자는 StringImpl의 reference count 필드를 공격 대상으로 삼을 수 있습니다. 다른 reference가 살아 있는 상태에서 reference count가 0이 되면 free가 발동되어 use-after-free가 발생합니다.

문자열을 static storage로 이동하면 StaticStringImpl의 refcount는 사실상 무시됩니다. 결과적으로 이 exploit 대상이 완전히 제거됩니다.

🔒

Explores the exploitation model for heap-allocated string metadata in processes with limited memory tagging coverage

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

🔒

Multiple hardening audit patterns identified across security-sensitive WebKit processes, with concrete search targets for similar gaps

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