<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Garamond,Georgia,serif;" dir="ltr">
<p></p>
<p>Hi all,</p>
<p><br>
</p>
<p>I want to attach the thread below since there is some context for what I will say next, and I believe it should be okay since the issue has been addressed in <a href="https://github.com/openjdk/jdk/pull/29728" class="OWAAutoLink" id="LPlnk457021">https://github.com/openjdk/jdk/pull/29728</a>.</p>
<p><br>
</p>
<p>I want to explore the idea of sharing AOTCache as software supply chain artifact. Currently, Java packages are published on Maven Central and consumers can run them as applications or reuse them as libraries. I am proposing that AOTCache is shared along
with the Java package by the developer/publisher so that downstream consumers can use it to achieve optimal performance. They could either 1) use the AOTCache as-is for the corresponding application or the downstream developer could 2) <i>merge the AOTCache
from Maven Central with the AOTCache from their application.</i> In this way the distribution of AOTCache as a supply chain artifact can take place.</p>
<p><br>
</p>
<p><img size="22280" contenttype="image/png" style="max-width: 99.9%;" id="img890783" contextid="img330187" tabindex="0" src="cid:5f9ec946-9815-45e5-affa-da2032f00e67"><br>
<br>
</p>
<p><br>
</p>
<p>In this figure, each rectangle is a Java package, and each cylinder is an AOTCache. As you can see, the AOTCache of App (AOTApp) is generated by merging all its dependencies' caches.</p>
<p><br>
</p>
<p>The thread below can also be summarised in a figure.</p>
<p><img size="24921" contenttype="image/png" style="max-width: 99.9%;" id="img630097" contextid="img205700" tabindex="0" src="cid:1b52b633-5ec5-49b5-b5aa-ed4767298ee2"></p>
<p>Basically, the red AOT11 contains a poisoned class that shares the fully qualified name with a class name in say D2. In this case, the App was loading the class from the AOTCache (AOTApp) instead the benign class in D2.</p>
<p><br>
</p>
<p>I think sharing AOTCache by developers is a good idea because:</p>
<ol style="margin-bottom: 0px; margin-top: 0px;">
<li>Developers would probably have a better idea of how well to exercise their application and hence their downstream consumer does not have to worry about creating an "ideal" workload.</li><li>Merging AOTCache in this way does not require creating complex workloads because your library code is already available in the AOTCache. You only need to add your own classes from the application.</li></ol>
<div><br>
</div>
<p><br>
</p>
<p>Now, 1) "<span>use the AOTCache as-is for the corresponding application</span>" could be realized by developers pushing their AOTCache on Maven Central along with their jars. However, achieving 2 is non-trivial because merge option is not available in the
JVM.</p>
<p><br>
</p>
<p>How have I tried to achieve merging:</p>
<ol style="margin-bottom: 0px; margin-top: 0px;">
<li>I first tried to create a parser for *.aot files. The idea was to <a href="https://github.com/chains-project/aotp/blob/main/src/main/java/io/github/chains_project/aotp/oops/klass/SPECIFICATION.md" class="OWAAutoLink">
deserialize this memory mapped file into objects declared by src/hotspot/share/oops</a>. And then do the merging using Java APIs I created. However, there were too many pointers that needed to be adjusted and I did not understand how I would parse or generate
the bitmap region.</li><li>I took a step back and tried to modify *.classlist files generated using CDS training run. Here I tried creating separate classlists for different submodules of
<a href="https://github.com/apache/pdfbox" class="OWAAutoLink">PDFBox</a> and then combining them manually. Then I created the CDS archive (.jsa file) using this "combined" classlist. During the production run, I could observe that some classes from different
classlist were loaded from shared object files. (I had to disable some checks for time and size of jar in JDK for this work). However, I am more inclined to have the AOTCache or CDS archive as an artifact which is distributed.</li><li> Now I am trying to patch JDK code with an option "-XX:+AOTMerge" which would work with "-XX:AOTCache"and this would return "merged.aot". To me, AOTCache is a dump of the memory so I think this is feasible. Given the size of JDK code and how sophisticated
HotSpot is, I can be completely wrong about this. I spun up a <a href="https://github.com/openjdk/jdk/commit/9d303022edfa6b67a895b7e826382bdbf246c230" class="OWAAutoLink">
blueprint for this feature</a> and now I am trying to use APIs like "<span>AOTMetaspace::dump_static_archive(thread);</span>" which, of course, end in SEGFaults. Can anyone please give me advice on how to go about implementing this feature? I can use some advice
on how exactly AOTCache is dumped.</li></ol>
<div><br>
</div>
<div>Caveats I have considered.</div>
<ol style="margin-bottom: 0px; margin-top: 0px;">
<li>I know AOTCaches and CDS archive are specific to a single JVM version, classpath, etc</li><li>The merged AOTCache may be too bloated.</li></ol>
<p>Yet I am motivated to explore more here.</p>
<p><br>
</p>
<p>Please share your thoughts on this, and I would also love some technical advice. Thank you in advance!</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, "EmojiFont", "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div id="m_4935352394101912768Signature">
<div name="divtagdefaultwrapper"><font size="2" color="#808080"><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"><span id="divtagdefaultwrapper" style="font-size:12pt">
<div style="margin-top:0; margin-bottom:0"><span style="color:rgb(0,0,0); font-family:Garamond,Georgia,serif">Regards,</span></div>
<span style="font-family:Garamond,Georgia,serif"></span><span style="font-family:Garamond,Georgia,serif"></span><span style="color:rgb(0,0,0)"></span><span style="font-family:Garamond,Georgia,serif"></span><span style="font-family:Garamond,Georgia,serif"></span>
<div style="margin-top:0; margin-bottom:0"><span style="color:rgb(0,0,0); font-family:Garamond,Georgia,serif">Aman Sharma</span></div>
</span><br>
</span></font></div>
<div name="divtagdefaultwrapper"><font size="2" color="#808080"><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"></span><span class="im">PhD Student<br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">KTH Royal Institute of Technology</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
</span><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">School of Electrical Engineering and Computer Science (EECS)</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">Department of Theoretical Computer Science (TCS)</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"><a href="http://www.kth.se" target="_blank" id="LPNoLP"></a><a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"></a><a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"></a></span></font></div>
</div>
<a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"><span style="font-size:10pt"></span></a><a href="https://algomaster99.github.io/" class="OWAAutoLink" id="LPNoLP">https://algomaster99.github.io/</a><br>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block; width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Aman Sharma<br>
<b>Sent:</b> Friday, January 30, 2026 11:53 AM<br>
<b>To:</b> leyden-dev@openjdk.org<br>
<b>Cc:</b> Martin Monperrus; roberto.castaneda.lozano@oracle.com<br>
<b>Subject:</b> Integrity violation in AOTCache</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Garamond,Georgia,serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p><font face="Garamond,Georgia,serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols" size="3" color="black"><span id="divtagdefaultwrapper" style="font-size:12pt"><font face="Garamond,Georgia,serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols" size="3" color="black"><span id="divtagdefaultwrapper" style="font-size:12pt"></span></font></span></font></p>
<font face="Garamond,Georgia,serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols" size="3" color="black"><font face="Garamond,Georgia,serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols" size="3" color="black">
<div style="margin-top:0; margin-bottom:0">Hi all,</div>
<div style="margin-top:0; margin-bottom:0"><br>
</div>
<div style="margin-top:0; margin-bottom:0">I have been playing around with AOTCache and I tried a small with it experiment whose idea was to shadow a class using AOTCache. By class shadowing, I mean loading a different class than intended but they both share
the same fully qualified name. We also explored this concept in the paper: <a href="https://arxiv.org/abs/2407.18760v4" class="OWAAutoLink"><span>Maven-Hijack: Software Supply Chain Attack Exploiting Packaging Order</span></a>, and now I am trying to extend
it to AOTCache.</div>
<div style="margin-top:0; margin-bottom:0"><br>
</div>
<div style="margin-top:0; margin-bottom:0">The steps in the experiment are based on
<a href="https://github.com/chains-project/maven-hijack-poc" target="_blank" rel="noopener noreferrer">
POC</a> from the same paper and are written briefly below. The exact commands are documented
<a href="https://github.com/chains-project/maven-hijack-poc/blob/main/java/maven/abstract-project/AOTCache.md" class="OWAAutoLink">
here</a>.</div>
<ol style="margin-top:0; margin-bottom:0">
<li>Build the application with one of the dependencies having malicious class. The malicious class has the same name as one of the other classes, say `org.postrgresql.Driver` but
<a href="https://github.com/chains-project/maven-hijack-poc/blob/0310de24103a55d1f51f70ef625933a40a7a55b3/java/maven/abstract-project/install-me-first/D11/src/main/java/org/postgresql/Driver.java#L8-L23" class="OWAAutoLink">
has malicious contents</a>.</li><li>Create an AOTCache using these dependencies in jar. <i>This creates a "polluted AOTCache".</i></li><li>Now using the polluted cache, run the application that is packaged with genuine dependencies. Apparently, the JVM initializes the malicious class from AOTCache instead of loading it from classpath. In other words, `<span style="font-family:"Courier New",monospace">java
-XX:AOTCache=maven.aot -jar target/victim-1.0.jar</span>` and `<span style="font-family:"Courier New",monospace">java -jar target/victim-1.0.jar</span>` give different outputs.</li></ol>
<div><br>
</div>
<div>I see this as a weakness if the poisoned AOTCache is distributed as an artifact for consumers to be used because maybe it is not expected from consumers to perform a training run themselves. I believe there should be some sort of integrity checks before
a class is initialized from AOTCache. I noticed there are <a href="https://github.com/openjdk/jdk/blob/e3b5b261af6acbe7ab074f301c70283b06c17d39/src/hotspot/share/code/aotCodeCache.cpp#L435" class="OWAAutoLink">
already some</a> (please share if there are more, and I have missed them), but none of them relate to what I am mentioning. I am happy to listen to some thoughts on this.</div>
</font></font>
<p></p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,"EmojiFont","Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div id="m_4935352394101912768Signature">
<div name="divtagdefaultwrapper"><font size="2" color="#808080"><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"><span id="divtagdefaultwrapper" style="font-size:12pt">
<div style="margin-top:0; margin-bottom:0"><span style="color:rgb(0,0,0); font-family:Garamond,Georgia,serif">Regards,</span></div>
<span style="font-family:Garamond,Georgia,serif"></span><span style="font-family:Garamond,Georgia,serif"></span><span style="color:rgb(0,0,0)"></span><span style="font-family:Garamond,Georgia,serif"></span><span style="font-family:Garamond,Georgia,serif"></span>
<div style="margin-top:0; margin-bottom:0"><span style="color:rgb(0,0,0); font-family:Garamond,Georgia,serif">Aman Sharma</span></div>
</span><br>
</span></font></div>
<div name="divtagdefaultwrapper"><font size="2" color="#808080"><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"></span><span class="im">PhD Student<br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">KTH Royal Institute of Technology</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
</span><span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">School of Electrical Engineering and Computer Science (EECS)</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)">Department of Theoretical Computer Science (TCS)</span><br style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif">
<span style="font-family:Arial,"Helvetica Neue",helvetica,sans-serif; background-color:rgb(255,255,255)"><a href="http://www.kth.se" target="_blank" id="LPNoLP"></a><a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"></a><a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"></a></span></font></div>
</div>
<a href="https://www.kth.se/profile/amansha" class="OWAAutoLink" id="LPNoLP"><span style="font-size:10pt"></span></a><a href="https://algomaster99.github.io/" class="OWAAutoLink" id="LPNoLP">https://algomaster99.github.io/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>