<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>V8 on Arzedlab 🪵</title><link>https://arzedlab.github.io/tags/v8/</link><description>Recent content in V8 on Arzedlab 🪵</description><generator>Hugo</generator><language>en-us</language><copyright>© Ravshan</copyright><lastBuildDate>Sat, 30 Mar 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://arzedlab.github.io/tags/v8/index.xml" rel="self" type="application/rss+xml"/><item><title>CVE-2021-38003 The Hole Leak to RCE</title><link>https://arzedlab.github.io/posts/cve-2021-38003-the-hole-leak-to-rce-ed84a7ccd2664916bb597042d3423439/</link><pubDate>Sat, 30 Mar 2024 00:00:00 +0000</pubDate><guid>https://arzedlab.github.io/posts/cve-2021-38003-the-hole-leak-to-rce-ed84a7ccd2664916bb597042d3423439/</guid><description>&lt;h1 id="cve-2021-38003--the-hole-leak-to-rce">CVE-2021-38003 | The Hole Leak to RCE&lt;/h1>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>&lt;strong>Type Of Vulnerability&lt;/strong>&lt;/th>
 &lt;th>The Hole Leak&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;strong>Security Severity&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>High&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Effected Components&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>Javascript, Turbofan&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Issue Source&lt;/strong>&lt;/td>
 &lt;td>&lt;a href="https://issues.chromium.org/issues/40057710">https://issues.chromium.org/issues/40057710&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Writeup Source(s)&lt;/strong>&lt;/td>
 &lt;td>None&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Tested Version&lt;/strong>&lt;/td>
 &lt;td>Google Chrome 95.0.4638.54 (Official Build) (x86_64)&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Vulnerable commit&lt;/strong>&lt;/td>
 &lt;td>a4252db3228433fed5c2bdb0fdff9a6b7b638f3b&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h1 id="deep-dive-into-vulnerability">Deep Dive Into Vulnerability&lt;/h1>
&lt;p>[1] The vulnerability arises as V8 attempts to handle exceptions in &lt;code>JSON.stringify()&lt;/code>. If a exception appears in the built-in function, &lt;code>pending_exception_&lt;/code> is set by the &lt;code>Isolate::set_pending_exception()&lt;/code> method. The calling code then moves to the V8 exception handling mechanism, where the &lt;code>Isolate::pending_exception()&lt;/code> member is fetched from the active isolate and the currently active JavaScript exception handler is invoked using it.&lt;/p></description></item><item><title>CVE-2020-6418 Type Confusion V8</title><link>https://arzedlab.github.io/posts/cve-2020-6418-incorrect-optimization-52d04cb78c1e47608e7874b83db5dcce/</link><pubDate>Fri, 02 Feb 2024 13:13:13 +0500</pubDate><guid>https://arzedlab.github.io/posts/cve-2020-6418-incorrect-optimization-52d04cb78c1e47608e7874b83db5dcce/</guid><description>&lt;h1 id="cve-2020-6418--incorrect-optimization">CVE-2020-6418 | Incorrect Optimization&lt;/h1>
&lt;h2 id="research-done-by-ravshan-rikhsiev-2023">&lt;strong>Research Done By Ravshan Rikhsiev (2023)&lt;/strong>&lt;/h2>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>&lt;strong>Type Of Vulnerability&lt;/strong>&lt;/th>
 &lt;th>Type Confusion&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;strong>Security Severity&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>High&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Effected Components&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>Javascript, Turbofan, Optimizer&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Issue Source&lt;/strong>&lt;/td>
 &lt;td>&lt;a href="https://issues.chromium.org/issues/40051542">https://issues.chromium.org/issues/40051542&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Writeup Source(s)&lt;/strong>&lt;/td>
 &lt;td>Later&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Tested Version&lt;/strong>&lt;/td>
 &lt;td>V8 8.2.0&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Vulnerable commit&lt;/strong>&lt;/td>
 &lt;td>bdaa7d66a37adcc1f1d81c9b0f834327a74ffe07&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>CVE-2020-6418&lt;/strong> is a security vulnerability that was identified in the V8 JavaScript engine, which is used in various web browsers including Google Chrome. This vulnerability was &lt;em>reported by Clement Lecigne of Google&amp;rsquo;s Threat Analysis Group on 2020-02-18&lt;/em> [1] and assigned CVE-2020-6418. It was classified as a type confusion bug in the V8 engine.&lt;/p></description></item><item><title>CVE-2019-5782 Out-Of-Bounds V8</title><link>https://arzedlab.github.io/posts/cve-2019-5782-oob-v8-f710491993d8478483ca99402710ec07/</link><pubDate>Fri, 01 Dec 2023 13:13:13 +0500</pubDate><guid>https://arzedlab.github.io/posts/cve-2019-5782-oob-v8-f710491993d8478483ca99402710ec07/</guid><description>&lt;h1 id="cve-2019-5782--oob-v8">CVE-2019-5782 | OOB V8&lt;/h1>
&lt;h1 id="research-done-by-ravshan-rikhsiev-2023">Research Done By &lt;strong>Ravshan Rikhsiev&lt;/strong> (2023)&lt;/h1>
&lt;table>
 &lt;thead>
 &lt;tr>
 &lt;th>&lt;strong>Type Of Vulnerability&lt;/strong>&lt;/th>
 &lt;th>&lt;strong>Out-Of-Bounds&lt;/strong>&lt;/th>
 &lt;/tr>
 &lt;/thead>
 &lt;tbody>
 &lt;tr>
 &lt;td>&lt;strong>Security Severity&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>High&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Effected Components&lt;/strong>&lt;/td>
 &lt;td>&lt;strong>Javascript, Turbofan, Compiler&lt;/strong>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Issue Source&lt;/strong>&lt;/td>
 &lt;td>&lt;a href="https://bugs.chromium.org/p/chromium/issues/detail?id=906043">https://bugs.chromium.org/p/chromium/issues/detail?id=906043&lt;/a>&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Writeup Source(s)&lt;/strong>&lt;/td>
 &lt;td>None&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Tested Version&lt;/strong>&lt;/td>
 &lt;td>V8 7.3.0&lt;/td>
 &lt;/tr>
 &lt;tr>
 &lt;td>&lt;strong>Vulnerable commit&lt;/strong>&lt;/td>
 &lt;td>18b28402118b7918512c3e5b6bc5c6f348d43564&lt;/td>
 &lt;/tr>
 &lt;/tbody>
&lt;/table>
&lt;h1 id="building">Building&lt;/h1>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>mkdir v8
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8be9fd;font-style:italic">cd&lt;/span> v8
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>fetch v8
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8be9fd;font-style:italic">cd&lt;/span> v8
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#6272a4"># Moving into vulnerable commit&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>git checkout 18b28402118b7918512c3e5b6bc5c6f348d43564
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#6272a4"># Sync depot tools&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>gclient sync -D
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#6272a4"># Installing dependencies &lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>build/install-build-deps.sh
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#6272a4"># Installing ninja to build&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo apt install -y ninja-build
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#6272a4"># Release and Debug versions of V8&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>tools/dev/gm.py x64.release; tools/dev/gm.py x64.debug
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h1 id="incorrect-optimization-assumptions-in-v8">&lt;strong>Incorrect optimization assumptions in V8&lt;/strong>&lt;/h1>
&lt;p>&lt;strong>Turbofan&lt;/strong> is an optimizing compiler in the &lt;strong>V8&lt;/strong> JavaScript engine. It translates JavaScript code into highly optimized machine code for better performance. It uses various techniques, such as inlining functions, optimizing data types, and eliminating unnecessary operations, to generate efficient code. This helps improve the execution speed of JavaScript programs running in V8.&lt;/p></description></item><item><title>V8 Internals: Tree</title><link>https://arzedlab.github.io/posts/v8-internals-ebdb3b1b2bdd4cc58f6f1d68382360b6/</link><pubDate>Sat, 05 Aug 2023 00:00:00 +0000</pubDate><guid>https://arzedlab.github.io/posts/v8-internals-ebdb3b1b2bdd4cc58f6f1d68382360b6/</guid><description>&lt;h1 id="v8-source-tree">V8 source tree&lt;/h1>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-cpp" data-lang="cpp">&lt;span style="display:flex;">&lt;span>v8&lt;span style="color:#ff79c6">/&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─ src&lt;span style="color:#ff79c6">/&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [api]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [asmjs]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [ast]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [base]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [baseline]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [bigint]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [builtins]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [codegen]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [common]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [compiler&lt;span style="color:#ff79c6">-&lt;/span>dispatcher]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [compiler]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [d8]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [date]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [debug]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [deoptimizer]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [diagnostics]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [execution]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [extensions]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [flags]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [fuzzilli]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [handles]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [heap]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [ic]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [init]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [inspector]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [interpreter]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [json]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [libplatform]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [libsampler]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [logging]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [maglev]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [numbers]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [objects]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [parsing]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [profiler]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [protobuf]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [regexp]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [roots]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [runtime]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [sandbox]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [snapshot]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [strings]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [tasks]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [temporal]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [third_party]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [torque]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [tracing]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [trap&lt;span style="color:#ff79c6">-&lt;/span>handler]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [utils]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [wasm]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>│ ├─ [zone]
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>├─ third_party&lt;span style="color:#ff79c6">/&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="v8srcapi">&lt;code>v8/src/api&lt;/code>&lt;/h2>
&lt;p>The &lt;code>v8/src/api&lt;/code> directory in the V8 codebase is part of the V8 API. The V8 API provides functions for compiling and executing scripts, accessing C++ methods and data structures, handling errors, and enabling security checks¹.&lt;/p></description></item><item><title>Getting Started with Embedding V8</title><link>https://arzedlab.github.io/posts/getting-started-with-embedding-v8-a91a35cbf98c46c08dde76f3f5958406/</link><pubDate>Thu, 06 Jul 2023 00:00:00 +0000</pubDate><guid>https://arzedlab.github.io/posts/getting-started-with-embedding-v8-a91a35cbf98c46c08dde76f3f5958406/</guid><description>&lt;h1 id="getting-started-with-embedding-v8">Getting Started with Embedding V8&lt;/h1>
&lt;h2 id="installing--testing-standalone-v8-application">Installing &amp;amp; Testing Standalone V8 application&lt;/h2>
&lt;ol>
&lt;li>Download the V8 source code&lt;/li>
&lt;li>Create a build configuration using the helper script:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>tools/dev/v8gen.py x64.release.sample
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>You can inspect and manually edit the build configuration by running:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>gn args out.gn/x64.release.sample 
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Build the static library on a Linux 64 system:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ninja -C out.gn/x64.release.sample v8_monolith
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Compile &lt;code>hello-world.cc&lt;/code>, linking to the static library created in the build process. For example, on 64bit Linux using the GNU compiler:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>g++ -I. -Iinclude samples/hello-world.cc -o hello_world -fno-rtti -lv8_monolith -lv8_libbase -lv8_libplatform -ldl -Lout.gn/x64.release.sample/obj/ -pthread -std&lt;span style="color:#ff79c6">=&lt;/span>c++17 -DV8_COMPRESS_POINTERS -DV8_ENABLE_SANDBOX
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>For more complex code, V8 fails without an ICU data file. Copy this file to where your binary is stored:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>cp out.gn/x64.release.sample/icudtl.dat .
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;ol>
&lt;li>Run the &lt;code>hello_world&lt;/code> executable file at the command line. e.g. On Linux, in the V8 directory, run:&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>./hello_world
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>V8 as a standalone virtual machine has some key V8 concepts such as &lt;strong>handles&lt;/strong>, &lt;strong>scopes&lt;/strong>, and &lt;strong>contexts.&lt;/strong> The V8 API provides functions for compiling and executing scripts, accessing C++ methods and data structures, handling errors, and enabling security checks. Your application can use V8 just like any other C++ library. Your C++ code accesses V8 through the V8 API by including the header &lt;code>include/v8.h&lt;/code>.&lt;/p></description></item></channel></rss>