<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="auto">Ron,</div>
<div dir="auto"><br>
</div>
<div dir="auto">In the cases I've seen, it is the application that is loading the agent programmatically, first thing they do in their static_void_main method.</div>
<div dir="auto"><br>
</div>
<div dir="auto">This has some benefits like allowing the application to depend on an agent as they do with any other library, through a dependency management tool (Maven/Gradle), and having more easily version upgrading mechanisms.</div>
<div dir="auto"><br>
</div>
<div dir="auto">The -javaagent deployment model is not an option to this, nor is the flag to enable the programmatically approach, as it requires the application *developer* to tune JVM flags to do so.</div>
<div dir="auto"><br>
</div>
<div dir="auto">Only possible solution I thought about was to give jlink a flag that would enable the feature. I wonder if this has been considered.</div>
<div><br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div dir="auto">Sent from mobile device.</div>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> jdk-dev <jdk-dev-retn@openjdk.org> on behalf of Ron Pressler <ron.pressler@oracle.com><br>
<b>Sent:</b> Thursday, May 11, 2023 11:37:56 AM<br>
<b>To:</b> Jack Shirazi <jacks@fasterj.com><br>
<b>Cc:</b> jdk-dev@openjdk.org <jdk-dev@openjdk.org><br>
<b>Subject:</b> [EXTERNAL] Re: New candidate JEP: 451: Prepare to Disallow the Dynamic Loading of Agents</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">The general policy in effect since JEP 261 [1] was delivered in JDK 17 (and included the dynamic agents change) is that the application and not libraries gets to decide what encapsulation-bypassing mechanisms are allowed. In the case
of agents, JEP 451 states:<br>
<br>
> To ensure that the owner of an application approved the use of agents, JDK 5 required agents to be specified on the command line with the -javaagent or -agentlib options, and loaded the agents immediately at startup. This represented an explicit grant of
privileges by the application owner.<br>
<br>
This is in line with the policy; letting libraries decide that they want to deploy an encapsulation-bypassing agent without the applications explicit consent is not. The full motivation behind the policy, and what integrity (not to be confused with security)
means, is explained in this information JEP draft: <a href="https://openjdk.org/jeps/8305968">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fopenjdk.org%2Fjeps%2F8305968&data=05%7C01%7Cbruno.borges%40microsoft.com%7C5a4d3650a0dd44b581f008db524f6a43%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638194273275917659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rxNIzxToUyWC%2F8ysUWcIkMcwlGHYULt9sPrOGu8n8h8%3D&reserved=0</a><br>
<br>
[1]: <a href="https://openjdk.org/jeps/261">https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fopenjdk.org%2Fjeps%2F261&data=05%7C01%7Cbruno.borges%40microsoft.com%7C5a4d3650a0dd44b581f008db524f6a43%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638194273275917659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JxP3fiUxm6bnrt7YdsFnz2R%2Fkdi7iRh6W5dZdULXu0s%3D&reserved=0</a><br>
<br>
> On 11 May 2023, at 11:11, Jack Shirazi <jacks@fasterj.com> wrote:<br>
> <br>
> This proposes to deprecate one mechanism for agent loading, but the ability to run an agent in the JVM is unchanged. This means that if disallowed in future, there will still be absolutely no change in "the balance between serviceability, which involves ad-hoc
changes to running code, and integrity, which assumes that running code is not arbitrarily changed". Applying the deprecation will still leave the exact same ability for arbitrary changes to the code.<br>
> <br>
> For libraries that may use this mechanism, I checked the <a href="https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=java">
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcve.mitre.org%2Fcgi-bin%2Fcvekey.cgi%3Fkeyword%3Djava&data=05%7C01%7Cbruno.borges%40microsoft.com%7C5a4d3650a0dd44b581f008db524f6a43%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638194273275917659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Pf7ZVhNy5uMsYUAmaTU4KpLU4TuR9SflMKUL4SbxjQ8%3D&reserved=0</a>
CVEs for the last five years and can't find any recorded abuse of it. I find it hard to believe that developers wouldn't know that their dependencies use this, if they do.<br>
> <br>
> Ultimately, integrity may be preferred, but there is a balance. For example we are not proposing to remove java agent capability, reflection, dynamic class loading, etc, all of which in one way or another violate integrity, because these are features which
make the JVM hugely successful.<br>
> <br>
> I don't see the benefit here. What future improvement would happen if the deprecation is subsequently applied?<br>
> <br>
> On 08/05/2023 20:17, Mark Reinhold wrote:<br>
>> <a href="https://openjdk.org/jeps/451">https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fopenjdk.org%2Fjeps%2F451&data=05%7C01%7Cbruno.borges%40microsoft.com%7C5a4d3650a0dd44b581f008db524f6a43%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638194273275917659%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=m0zCVNxYTFR%2FSOd7vpZH6HYF9WzjK47%2FPyrA%2BEK6bfg%3D&reserved=0</a><br>
>> <br>
>> Summary: Issue warnings when agents are loaded dynamically into a<br>
>> running JVM. These warnings aim to prepare users for a future release<br>
>> which disallows the dynamic loading of agents by default in order to<br>
>> improve integrity by default. Serviceability tools that load agents at<br>
>> startup will not cause warnings to be issued in any release.<br>
>> <br>
>> - Mark<br>
<br>
</div>
</span></font></div>
</body>
</html>