← All issues

CSP wasm-unsafe-eval directive is not enforced during WebAssembly byte compilation

4003087

CSP의 wasm-unsafe-eval은 browsing context에서 WebAssembly를 컴파일하고 실행할 수 있는지를 제어합니다. WebKit은 이를 globalObject->webAssemblyEnabled() 호출로 구현했습니다. 문제는 이 호출이 JSWebAssemblyInstance::tryCreate() (instantiation) 단계에만 존재했고, 컴파일 단계에는 없었다는 점입니다.

WebAssembly.Module은 스펙상 structured-cloneable입니다. 공격자는 check를 우회하는 context에서 컴파일한 뒤, Module을 same-origin Worker에 postMessage로 전달할 수 있습니다. 이후 해당 Worker에서 instantiate하면 정책 전체를 무력화할 수 있었습니다.

+ if (!globalObject->webAssemblyEnabled())
+ return JSValue::encode(throwException(globalObject, throwScope,
+ createEvalError(globalObject, globalObject->webAssemblyDisabledErrorMessage())));

이번 수정에서 check는 WebAssembly.compile(), new WebAssembly.Module(), WebAssembly.compileStreaming(), WebAssembly.instantiateStreaming() 각각에 추가되었습니다. bytecode 파싱이나 network fetch가 시작되기 전에 CompileError로 거부됩니다. 오랫동안 열려 있던 FIXME 두 건(bug 173977, 173105)도 함께 제거되었습니다.

streaming API 도입 이후 잠재해 있던 실질적인 CSP bypass를 해소했습니다. wasm-unsafe-eval이 이제 instantiation뿐만 아니라 Module 생성 자체를 차단합니다.

🔒

The new check placement across worker types and streaming redirect paths raises several edge cases worth security investigation.

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