<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Using JFR does not require that command-line option; it’s required only for specific kinds
<div class="">of use. Its current events might be not have everything you want, but will be expanded, in </div>
<div class="">part to address the functionality that will be lost with the removal of Security Manager. And </div>
<div class="">yes, I believe it is possible to use JFR streaming and recording at the same time, but perhaps </div>
<div class="">a JFR expert will chime in.</div>
<div class=""><br class="">
</div>
<div class="">Libraries that can disable the Security Manager aren’t able to circumvent OS-level</div>
<div class="">sandboxing. If you’re not afraid of that, then they’re trusted and JFR is superior;</div>
<div class="">if they’re untrusted, then configuring the Security Manager correctly for untrusted rich </div>
<div class="">libraries is very difficult. There is no argument that this is a powerful capability *in theory*;</div>
<div class="">the problem is that it’s difficult to correctly employ this capability correctly *in practice*. See</div>
<div class="">this paper for an empirical study: <a href="http://www.cs.cmu.edu/~clegoues/docs/coker15acsac.pdf" class="">http://www.cs.cmu.edu/~clegoues/docs/coker15acsac.pdf</a></div>
<div class=""><br class="">
</div>
<div class="">The point is that while you *think* SM gives you a useful sandboxing capability, in practice, </div>
<div class="">in most cases it doesn’t.</div>
<div class=""><br class="">
</div>
<div class="">— Ron</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 21 Apr 2021, at 13:28, Lim <<a href="mailto:lim.chainz11+mailing@gmail.com" class="">lim.chainz11+mailing@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">
<blockquote type="cite" class="">Monitoring network connections can be done with JFR. It will tell you which classes<br class="">
perform the connections. It does not require a Java agent.<br class="">
</blockquote>
<br class="">
Hi Ron, I read about the JFR and it required a command line argument<br class="">
"-XX:StartFlightRecording" and it is not suitable since it is<br class="">
distributed to the *end user*. Does JFR able capture the URLs<br class="">
performed by those libraries (which can be obtained by getting the<br class="">
name of URLPermission)? I have used it before in JMC and it only shows<br class="">
the hostname address only. Is there an alternative besides JFR that is<br class="">
capable of using programmatically means like SM such as<br class="">
setSecurityManager, ability to capture logs, perform blocking in real<br class="">
time?<br class="">
If JFR is capable of operating *without using command line flags*, can<br class="">
you please link it to the relevant documentation? Besides that, if<br class="">
using JFR streams, can it be used with JMC concurrently?<br class="">
<br class="">
<blockquote type="cite" class="">Setting up the SM to *block* connections while also not allowing those libraries to<br class="">
disable the SM is not very easy.<br class="">
</blockquote>
<br class="">
Well if those libraries are able to disable SM, those libraries are<br class="">
able to circumvent the native restrictions of the operating system<br class="">
too. But these mostly occur in malicious-like libraries that are less<br class="">
well known or in the worst possible case, popular libraries that are<br class="">
hijacked.<br class="">
<br class="">
<blockquote type="cite" class="">Those libraries are trusted, and monitoring is more effective than sandboxing for trusted code.<br class="">
</blockquote>
<br class="">
I disagree to a degree, not all libraries can be vetted by the<br class="">
operators of the websites, especially those who do not use those<br class="">
distribution websites. This is because some of the libraries might be<br class="">
obfuscated by the library authors themselves and thus unable to<br class="">
determine the trustworthiness, or libraries are unknowingly tampered<br class="">
by 3rd parties. Not every end user will know how to perform hash<br class="">
checking of the downloaded library, even more on verifying the<br class="">
signature of the library. The users implicitly trust because they<br class="">
assume the distribution sites will perform checks on the library for<br class="">
malicious code. They rely on users reporting the library that is<br class="">
malicious. This means that there is a chance that untrustworthy code<br class="">
is executed before knowing it.<br class="">
<br class="">
In addition, assume if the end user needs to decide if the library is<br class="">
"trusted" before they introduce it to the game, but not everyone has<br class="">
the knowledge to audit those libraries themselves. For example, if I<br class="">
have downloaded a modpack that contains 100 mods (which are libraries<br class="">
that are bundled together), do I need to audit each one or will the<br class="">
producer of the pack perform the audit? I believe it will be a waste<br class="">
of time since some of the library is frequently updated with features<br class="">
and bug fixes.<br class="">
<br class="">
For a hypothetical scenario: I have developed a popular library that<br class="">
has intuitive APIs, and this library is constantly updated with<br class="">
features and in one day, I have added a "subtle feature" to gather and<br class="">
upload sensitive information of the monetization purpose and this code<br class="">
is not found in the source. Assuming the user has a monitoring library<br class="">
using the JFR streams, it was able to detect the unknown remote<br class="">
connection to the author server, but it is already too late since when<br class="">
you see the log, it has already happened.<br class="">
<br class="">
I would like to ask in this scenario, what is the best possible<br class="">
solution to mitigate it for the end user perspective besides not<br class="">
downloading it since it can be included implicitly as a dependency,<br class="">
and how can I help the end user to mitigate this scenario?<br class="">
<br class="">
- Lim<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
<br class="">
On Wed, Apr 21, 2021 at 4:24 PM Ron Pressler <<a href="mailto:ron.pressler@oracle.com" class="">ron.pressler@oracle.com</a>> wrote:<br class="">
<blockquote type="cite" class=""><br class="">
Monitoring network connections can be done with JFR. It will tell you which classes<br class="">
perform the connections. It does not require a Java agent.<br class="">
<br class="">
Setting up the SM to *block* connections while also not allowing those libraries to<br class="">
disable the SM is not very easy. Those libraries are trusted, and monitoring is<br class="">
more effective than sandboxing for trusted code.<br class="">
<br class="">
— Ron<br class="">
<br class="">
<blockquote type="cite" class="">On 21 Apr 2021, at 06:26, Lim <<a href="mailto:lim.chainz11+mailing@gmail.com" class="">lim.chainz11+mailing@gmail.com</a>> wrote:<br class="">
<br class="">
Hi all, apologize if I interrupted this thread.<br class="">
<br class="">
I agreed on what Reinier has said and I have similar concerns about<br class="">
the removal of SecurityManager.<br class="">
<br class="">
I have developed a "Mod" for a certain game to monitor which "Mods"<br class="">
are using network connections. The mod is a kind of library since<br class="">
other libraries can use them to extend the library functionality such<br class="">
as add-on. In this context, library refers to Mod, a modification that<br class="">
can provide extra features to the base game. These libraries are<br class="">
usually obtained from reputable websites by the end user. However, not<br class="">
all libraries can be obtained in these websites, some which are hosted<br class="">
by the author themselves that are readily compiled.<br class="">
<br class="">
Most of the library in this game does not require network connections<br class="">
to work except, for legitimate reasons such as version checker,<br class="">
downloading required resources, but some requested network connections<br class="">
anyway without reasons. This gives the concern, are the network calls<br class="">
justified for a game that can be played offline?<br class="">
<br class="">
Besides that, Reinier gives good point of why the ability to<br class="">
deny/allow network is important and I would like to give an example<br class="">
when I am developing the library:<br class="">
<br class="">
On 2021-04-16 09:29, Reinier Zwitserloot wrote:<br class="">
<blockquote type="cite" class="">* Any library could have the bright idea to 'phone home' and make a<br class="">
network call simply to give the library author some idea of how<br class="">
widespread their library is used. This could have an entirely innocuous<br class="">
purpose: The library author thought it'd be a cool idea to have a live<br class="">
map of the planet on their website, with a little animated blip every<br class="">
time their library is used to, say, parse some JSON. SecurityManager is<br class="">
the simplest way to spot this and stop it.<br class="">
</blockquote>
<br class="">
Although most of the recent libraries do not have analytics that I've<br class="">
seen, I have seen one older version of the library that has analytics<br class="">
enabled without any way to disable except performing bytecode<br class="">
modifications. This has implications to the users' privacy since they<br class="">
do not anticipate it has analytics within them and libraries that have<br class="">
analytics are frowned upon in the mod community. This also violates<br class="">
some of the privacy laws in some countries.<br class="">
<br class="">
The security manager is the only viable way to control these libraries<br class="">
from "phone home" in my opinion. Since the end user "install" these<br class="">
libraries by putting into a specific folder for the loader to launch<br class="">
the game with these modifications. They are not expected to change<br class="">
their system just to know if a particular library has these<br class="">
"features". For example, using firewall/hosts file/DNS/other<br class="">
monitoring tools. It might help but it does not provide insight into<br class="">
which class/package which Reinier has said and that's where the<br class="">
SecurityManager can help.<br class="">
<br class="">
By using the "checkConnect" methods in SecurityManager, I can<br class="">
allow/deny and notify appropriate messages in the log for the end user<br class="">
to check. In addition, there is a configuration that allows the end<br class="">
user to configure which hosts are allowed for the network connections.<br class="">
<br class="">
I hope that the core SecurityManager functionality will be preserved.<br class="">
Will there be an alternative that is able to provide similar<br class="">
functionality through programmatic means for my use case? I have read<br class="">
the comments about using JFR stream/bytecode instrumentation but it<br class="">
required the usage of Java Agent and command line flags which is not<br class="">
acceptable in this use case.<br class="">
<br class="">
Thanks<br class="">
</blockquote>
<br class="">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>