← All issues

[8] NetworkProcess setRawCookie IPC validation

Severity: High | Component: WebKit NetworkProcess | fb75cae

Rated High because the diff fixes two co-located issues: a compromised WebProcess could plant cookies for arbitrary registrable domains (session fixation, login-CSRF), and a malformed commentURL could crash NetworkProcess via an unhandled NSException.

NetworkConnectionToWebProcess::setRawCookie validated allowsFirstPartyForCookies but not the cookie's own domain field or the url parameter. A compromised renderer could plant a cookie for bank.com from a session anchored to evil.com.

Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

MESSAGE_CHECK(allowCookieAccess != NetworkProcess::AllowCookieAccess::Terminate);
+ MESSAGE_CHECK(RegistrableDomain::uncheckedCreateFromHost(cookie.domain).matches(firstParty));
+ MESSAGE_CHECK(RegistrableDomain(url).matches(firstParty));

Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm

+ BEGIN_BLOCK_OBJC_EXCEPTIONS
auto nsCookies = createNSArray(cookies, [] (auto& cookie) -> NSHTTPCookie * {
return cookie.createNSHTTPCookie().autorelease();
});
- BEGIN_BLOCK_OBJC_EXCEPTIONS
[nsCookieStorage() setCookies:nsCookies.get() forURL:url.createNSURL().get() mainDocumentURL:mainDocumentURL.createNSURL().get()];
END_BLOCK_OBJC_EXCEPTIONS

Two MESSAGE_CHECKs confirm cookie.domain and the url argument are within the same registrable domain as firstParty. The BEGIN_BLOCK_OBJC_EXCEPTIONS macro is widened so it now wraps the cookie.createNSHTTPCookie() conversion loop, where Foundation's initializer can raise NSException on malformed properties (e.g. commentURL).

Trusting WebProcess-supplied IPC arguments at a privileged-process trust boundary without cross-validating the security-relevant fields (cookie domain vs. firstParty) against the asserted origin.

In WebKit's multi-process architecture, the WebProcess is sandboxed and untrusted from NetworkProcess's perspective; every IPC argument must be validated. RegistrableDomain represents an eTLD+1 computed via the Public Suffix List. cookie.domain is the Domain= attribute that the platform cookie store uses to decide which sites the cookie is sent to. BEGIN_BLOCK_OBJC_EXCEPTIONS installs @try/@catch around the enclosed block so a raised NSException does not propagate into C++ stack frames.

The classic "NetworkProcess trusts WebProcess-supplied tuple" pattern: a (firstParty, url, cookie) triple with only one component validated and the other two riding free. The companion BEGIN_BLOCK_OBJC_EXCEPTIONS placement bug is a recurring footgun — the macro must wrap every Objective-C call that can throw, including conversion helpers in the same C++ function.

🔒

The cross-process trust model around cookie IPC and the realistic attacker model for chaining this with a renderer compromise are analyzed in depth, alongside a secondary NetworkProcess availability angle.

Subscribe to read more

🔒

Four reusable audit patterns identified spanning IPC validation discipline and Objective-C exception scoping, with concrete grep targets for variant discovery across the NetworkProcess surface.

Subscribe to read more