> ..
>> ..Can I change the security policy from within a java
[quoted text clipped - 4 lines]
> <http://groups.google.com/group/comp.lang.java.programmer/msg/
> f29ab45389d9f5f2>
> > ..
> >> ..Can I change the security policy from within a java
> >> program ??
>
> > Here is an example of replacing the current
> > security manager with one that is more strict..
...
> And here's an example of the opposite...
>
> http://jroller.com/page/tackline?entry=mixed_certification_an_examplehttp://jrol
ler.com/page/tackline?entry=system_setsecuritymanager_null
I only checked one of the URL's, but all I
saw was an *assertion*. The assertion was
that this line of code..
System.setSecurityManager(null);
..could be called from within an applet to
remove the security manager.
OK - lets turn that into a simple *example*.
<sscce>
import java.applet.Applet;
public class NoSecurityApplet extends Applet {
public void init() {
try {
System.out.println("java.version: " +
System.getProperty("java.version") );
System.setSecurityManager(null);
} catch(Throwable t) {
t.printStackTrace();
}
}
}
</sscce>
Both AppletViewer and IE produced similar
results, here is the output from AppletViewer.
java.version: 1.6.0
java.security.AccessControlException: access denied
(java.lang.RuntimePermission
setSecurityManager)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:
323)
at
java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:
532)
at java.lang.System.setSecurityManager0(System.java:273)
at java.lang.System.setSecurityManager(System.java:264)
at NoSecurityApplet.init(NoSecurityApplet.java:8)
at sun.applet.AppletPanel.run(AppletPanel.java:417)
at java.lang.Thread.run(Thread.java:619)
So. I feel fairly confident in calling
that assertion 'a load of old cobblers'.
If it was a security bug in some obscure
old version of the JVM - it has apparently
been fixed* (as I would have expected).
( * Fortunately, to spare us the the idiotic
games of people like this foul mouthed OP. ;)
Andrew T.
Andrew Thompson - 23 Mar 2007 15:36 GMT
> > > ..
> > >> ..Can I change the security policy from within a java
[quoted text clipped - 8 lines]
>
> I only checked one of the URL's, ..
..and the rest of this post was actually about
the *other* one (D'Oh!). That URL was..
<http://jroller.com/page/tackline?
entry=system_setsecuritymanager_null>
> ..here is the output..
..and some more, from the other two VM's
I have lying around, which can be called up
in a browser (or a close facsimile of a
browser, as the case may be).
MSVM (build 3810, AFAIU - 'Release 5.0.0.3310')
________________________________________________________
java.version: 1.1.4
java.lang.SecurityException: SecurityManager already set
at java/lang/System.setSecurityManager
at NoSecurityApplet.init
...
Symantec VM
________________________________________________________
Netscape Communications Corporation -- Java 1.1.5
Type '?' for options.
Symantec Java! ByteCode Compiler Version 210.065
Copyright (C) 1996-97 Symantec Corporation
java.version: 1.1.5
java.lang.SecurityException: SecurityManager already set
at java.lang.Throwable.<init>(Compiled Code)
...
Andrew T.
Tom Hawtin - 23 Mar 2007 16:53 GMT
> I only checked one of the URL's, but all I
> saw was an *assertion*. The assertion was
> that this line of code..
> System.setSecurityManager(null);
> ..could be called from within an applet to
> remove the security manager.
Funnily enough, you have to sign the class (and accept the certificate).
Then non-signed code in the same JVM has full reign.
So if Alice signs a class that clears the security manager. Bob accepts
classes signed by Alice, and so drops his security. Eve produces
malicious classes that make use of Bob's lack of security.
> So. I feel fairly confident in calling
> that assertion 'a load of old cobblers'.
> If it was a security bug in some obscure
> old version of the JVM - it has apparently
> been fixed* (as I would have expected).
It's not a bug in the JVM. It's a flaw in the signed code. Any
certificate that has ever been used to sign this sort of code must, in
my personal opinion, be revoked.
Tom Hawtin
..
> http://jroller.com/page/tackline?entry=mixed_certification_an_example
But I have to admit, I do not yet understand
this one. If the app. has already been granted
full permissions (as the example mentions), I
would expect it to be able to ..
- change security managers at any time
- edit policy files at will
- upload all your private information to a
malicious site,
- wipe parts of your drives,
- ...
Why would it be amazing that it can have
further effects on security?
Andrew T.
Tom Hawtin - 23 Mar 2007 16:58 GMT
> But I have to admit, I do not yet understand
> this one. If the app. has already been granted
[quoted text clipped - 9 lines]
> Why would it be amazing that it can have
> further effects on security?
If the classes granted full permission interfere with the process'
security, then other 'untrusted' classes running in the same process can
e-mail your credit card details to Eastern Europe, your porn stash to
your boss, etc.
Tom Hawtin
Andrew Thompson - 24 Mar 2007 02:59 GMT
> > ..I do not yet understand this one.
...
> > Why would it be amazing that it can have
> > further effects on security?
[quoted text clipped - 3 lines]
> e-mail your credit card details to Eastern Europe, your porn stash to
> your boss, etc.
Thanks for clarifying. That makes it somewhat
clearer to me.
That is not good, but OTOH, it is a relatively
specific and (I imagine) rare circumstance.
Each web start app. gets its own JVM, doesn't
it?
Andrew T.