Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Java Programming Security

Comparison of Java and .NET security 461

prostoalex writes "The Computer Science Department at the University of Virginia has published a comparative study of security in Java and .NET in Portable Document Format. DevMktg blog on MSDN summarizes the findings saying that due to careful design process, .NET presents security advantages over Java platform in several areas." From the article: "Where Java evolved from an initial platform with limited security capabilities, .NET incorporated more security capability into its original design. With age and new features, much of the legacy code of Java still remains for backwards compatibility including the possibility of a null SecurityManager, and the absolute trust of classes on the bootclasspath. Hence, in several areas .NET has security advantages over Java because of its simpler and cleaner design."
This discussion has been archived. No new comments can be posted.

Comparison of Java and .NET security

Comments Filter:
  • PDF text (Score:5, Informative)

    by Anonymous Coward on Saturday August 27, 2005 @05:09AM (#13414230)
  • by Krimszon ( 815968 ) on Saturday August 27, 2005 @05:36AM (#13414291)
    2 more months and we should have VS2005, the devs promised it wouldn't touch code and would produce valid xhtml.

    If it does, that's a good (although somewhat late) improvement (which should've been a free upgrade, since I consider the absence of that 'feature' a bug).
  • by wdmr ( 884924 ) on Saturday August 27, 2005 @05:57AM (#13414336)

    I notice the article did not talk much about the implications of having a .Net implementation on your network.

    The one (and only) multi-tiered .Net implementation I have had to work with was a networking nightmare. The whole thing used DCOM which is a total pain in the ass. No NAT'ing (DCOM doesn't function across NAT) means that production DMZ's had to have routeable IP's. DCOM uses RPC which means that firewalls have to allow the entire high port range (>1024) between tiers. The transaction protocol in the framework likes to talk all the way from web layer to db layer so defense in depth is pretty much thrown out the window.

    It may be that there is a way to use .Net without running into these issues, but the developers and the MS consultant all insisted this was standard and typical. Of course, they all also insisted that the environment would be better off flat and the MS consultant strongly urged not doing multi-tiered. So I suppose if you don't mind having your SQL server in the DMZ .Net is great.

    Didn't like it. No sir. Not at all.

  • by Johnno74 ( 252399 ) on Saturday August 27, 2005 @06:02AM (#13414348)
    Most of the source code for .Net is available here [microsoft.com] - Its called "rotor" and is Microsoft's open source implementation of .Net. It doesn't cover the complete framework, but it includes the runtime, C# compiler, and the parts of the framework that were submitted to ECMA.

    Anyone is free to download, modify and distribute rotor, it compiles on OSX and BSD. I believe someone has modified it to compile and run on Linux. Unfortunately the license prohibits commercial use...

    The major differences between Rotor and the full framework are a simplified garbage collector, and a simplified JIT compiler. Microsoft aren't saying how much of the framework code is shared between Rotor and the full version, but I've been told by people with access to the source that the answer is "pretty much all of it"
  • by boa13 ( 548222 ) on Saturday August 27, 2005 @06:08AM (#13414360) Homepage Journal
    you execute a program and it will run before next Christmas (not something you can say for Java)

    Heh, that part is quite a troll.

    I use Java apps daily (Eclipse, Moneydance, JAlbum), and now that you make me think of it, they might not be "lightning fast", but they're fast enough that I don't think about their speed. In my book, that's the definition of being "fast enough".

    I don't have experience with .Net apps however, so it might well be the case that they're faster. As others have commented, they only run on one platform, someone also said it's easy to embark native code in .Net, this might make a huge difference.

    Anyway, Java is not "slow" anymore, it may be not as fast as others, but it's fast enough.
  • by vdex42 ( 858798 ) on Saturday August 27, 2005 @06:26AM (#13414393)
    The whole point of a a virtual machine is to sandbox your code. So it doesn't matter how un-secure the layer is that is running it. The only way to get out of the virtual machine and buffer overflow the real PC would be to first buffer overflow your virtual machine, or find some other type of vulnerability in the VM first. Which as this article points out is pretty solid.
  • by iksrazal_br ( 614172 ) on Saturday August 27, 2005 @06:32AM (#13414406) Homepage
    I think this article overlooks the fact that many 'free as in speech' third party security libraries and frameworks are available for java.

    1) ACEGI - Aspect-orientaded-programming using a dependency injection model to replace or complement JAAS for authentication and authorization in an Application server independant way. A subproject of the Spring framework:

    http://acegisecurity.sourceforge.net/docbook/acegi .html/ [sourceforge.net]

    2) XML Encryption and XML Digital Signatures. Used in Web Service security or independently.

    http://xml.apache.org/security/ [apache.org]

    http://ws.apache.org/wss4j/ [apache.org]

    3) Container managed security implemented in every servlet container on the market, including tomcat.

    In short, I'd like to see a comparison of the features and availablity of what people actually use in their applications, rather than an entirely fudgable comparison of reported/unreported security flaws.

    "None are more hopelessly enslaved than those who falsely believe they are free. -- Goethe"

    iksrazal

  • by dedazo ( 737510 ) on Saturday August 27, 2005 @06:35AM (#13414409) Journal
    The whole thing used DCOM

    That's unfortunate, because .NET does not require DCOM at all.

    DCOM uses RPC which means that firewalls have to allow the entire high port range

    Yes, well, you can always open DCOMCNFG, switch to the protocols tab, select the TCP/IP entry and set the port range that suits you. Wow.

    MS consultant all insisted this was standard and typical

    An "MS consultant" told you you needed DCOM to jump over tiers with .NET and failed to tell you that you can select a port range to play nice with your firewall over the DMZ? Crap, I would have called his boss or the TAM at the regional office and have his ass fired.

    consultant strongly urged not doing multi-tiered

    You know what, while I don't doubt that there's someone dumb enough to recommend something like that out there, I really doubt it was an "MS consultant". Microsoft is moving away from heavy physical tier designs to avoid the wire overhead (which admittedly makes them look slightly stupid after years of telling everyone to use as many boxes as possible), but to recommend running the application and the database server on the same box is just plain retarded. MSCS (or whomever you were supposedly talking to) has some dumb people in the file and rank, but not *that* dumb.

    I'm gonna have to call bullshit on your apocryphal story here, unless by "MS consultant" you mean some random dude that has an MCSD and has read "Software Fortresses" five times while moving his lips.

  • by Richard_at_work ( 517087 ) on Saturday August 27, 2005 @06:46AM (#13414437)
    Java: price: free, well it is free Sure, but not as in beer. Can I independently create my own JVM and distribute it?

    Well, actually, yes you can. Theres nothing stopping you reimplimenting a JVM to the released specifications, infact Kaffe [kaffe.org] is one such reimplementation. Go get a book detailing the VM specifications and how to implement a good VM from Sun! [sun.com]

  • by zootm ( 850416 ) on Saturday August 27, 2005 @06:51AM (#13414454)

    Net can have lots of security features as long as you can pump a string directly into win32 in half of the classes, which triggers a buffer overflow everything is null and void in this article.

    You can't do that unless you're P/Invoking worse code, or running in the unsafe mode, both of which are similar to running a JNI interface with which you could do the same thing

    The CLI system is sandboxed, the underlying API is hidden and — in general, unless there's a problem with the implementation of the system — its shortcomings are essentially hidden.

  • by rjshields ( 719665 ) on Saturday August 27, 2005 @07:34AM (#13414548)
    If Sun adds real OOP features like multiple inheritance, operator overloading, traits, mixins, and introduces optional strong or weak dynamical typing
    Multiple inheritance is best avoided for clarity (multiple interface inheritance is OK). Operator overloading is rarely useful and often abused. Java is a strongly typed language and this is not going to change ("dynamical typing" doesn't mean anything by the way).

    Some of these points are misinformed and you missed out the things that bug people most about Java, the lack of deterministic finalisation and direct memory control, so it looks like your intellect is not superior after all. People who really do have superior intellect do not need to boast about it, it shows through in the things they do and say.
  • It's been done (Score:3, Informative)

    by Anonymous Coward on Saturday August 27, 2005 @08:05AM (#13414630)

    This is news? ONJava [onjava.com] did a detailed, four-part analysis of .Net and Java security a year or so ago:

  • by tommck ( 69750 ) on Saturday August 27, 2005 @09:15AM (#13414882) Homepage
    MSFT has ported the .NET Framework to FreeBSD themselves!

    AND, Mono and .GNU run on many platforms (Linux, Windows, BSD, OSX and Solaris). As long as you don't use System.Windows (the desktop app stuff), you can do cross-platform development in many languages!

    I have written GTK# apps in VS.NET and run it on my Windows and SuSE box with ZERO modifications.

    If you want to bash something, you should probably learn a bit more about it. That's the reason I read the Bible multiple times: so I can refute Bible thumpers' arguments.
  • Re:Interoperability? (Score:3, Informative)

    by CrazyLegs ( 257161 ) <crazylegstoo@gmail.com> on Saturday August 27, 2005 @09:44AM (#13415022) Homepage
    Dude.... I gotta comment. I'm a senior architect at a very large multi-national back and I can attest that (in our case):
    • Java interoperability is extremely important. It's not about running the same code on different platforms, though. It's more about being able to switch out the platform when we need to (e.g. going from Wintel servers, to Linux and z/OS)
    • .NET is not knocking the socks off of Java. They are both shaping up to find their places. In our org, anything we write is Java (any tier, including clients where balls-to-the-wall performance is required). When we buy stuff, we look at Java (very few products) and .NET (more products).
    • Web Services are simply grand. But someone please wake me up when there's a full-featured implementation that's interoperable. Until then, Java has not lost any advatange here (if there ever was an advantage here).
    • your comments about 'beloved Linux desktops' simply describes the power of a Web interface, which is not specific to ASP.NET. Incidently, a Web interface is not always the right solution, so how does the Linux front-end play with the Windows back-end there?
    Not trying to diss you here. Just trying to give some perspective from this corner.
  • by Anonymous Coward on Saturday August 27, 2005 @09:46AM (#13415034)
    you can emulate OO WITHOUT type polymorphism easily in C. And information hiding is hard to enforce. And stupid byte layout issues can make incompatibilities where there really should be none. Those are a pretty important things to be missing! You have to think of classes as as structures consisting of nothing more than function pointers that get allocated out of black boxes to get anything like what is required. (The Linux's virtual filesystem comes to mind here)

    But then you have to typecast, which spoils it all. Typecasting is a memory re-interpretation in C/C++. If it's not compatible in C, then you will start garbling memory in arbitrary ways.

    In a secure language architecture, OTOH, it's an attempt to assign to a compatible type...and if that type is not compatible the VM will throw an exception. Furthermore, the stringent typesafety requirements make it absolutely necessary that garbage collection is used so that pointers to deallocated data, orphaned data, etc are disallowed.

    Another important thing is no information hiding in C, So you won't get compiler errors when you try to go around the public interfaces (direct access, casting, etc). Even in C++, if you add a new private data member you have to re-compile the clients of the library...because everything in C/C++ is concerned with the actual byte layout of everything. this is a profoundly retarded way to make shrinkwrapped libraries.

    Java/.NET by contrast don't really define byte layout. In fact, memory layout could be randomized for security purposes for all you know. Datastructures could be much smaller or larger than you imagine by just looking at its members. As an example, he String classes in Java/.NET are doing a lot of magical stuff to share memory.

    And of course you missed the whole point of why you can't use any derivative of C for executing semi-trusted code. You can't allow type violations of any kind (buffer overflows, pointer arithmetic), Any security holes discovered in these VMs are business as usual in C (type violations, memory violations, flow violations) because everything in C is accomplished through some form of pointer arithmetic.

    In any case, this is no attempt to bash C. I like C and C++ for what they were intended. It's just that C will never address the issue of protecting the user from his own processes, which is what VM security is all about. There are times when you need to protect yourself even from code that's been signed by an entity that you trust.

    This is something that you can't address the same way that you protect the OS from its users (disallowing syscalls, using virtual memory pages). You need to be able to make calls out to dangerous functions, but be able to apply fine-grained policies to how this is allowed. And you can't enforce the policies if you can walk around them by violating the typesystem.

    BTW, the whole CVE comparison thing from the article was a bit unfair because the CVEs from before .NET even existed. But I do think that .NET does have more security features. But the fact that a compiled .NET binary will have a *.exe extension means that you "just click on the *.exe file in your web browser" is a very bad thing. It won't be safe to launch an untrusted *.exe until only .NET *.exe format is allowed.
  • by Anonymous Coward on Saturday August 27, 2005 @10:10AM (#13415130)
    More right here:

    Writing a Security Manager [sun.com]

    You can just do this at server startup and lock it down as much as you want.

    -- ac at home

  • by kelzer ( 83087 ) on Saturday August 27, 2005 @10:10AM (#13415133) Homepage

    You can write in lots of nice languages for it, wheras Java afaik only has Java and Ruby.

    No offense, but I guess you don't know much. Here are just a few of the available languages for the JVM:

  • by owlstead ( 636356 ) on Saturday August 27, 2005 @10:17AM (#13415159)
    You are trying to be funny, but I'll bite. .NET and Java are clearly a much cleaner subset of C++, with many runtime features. Both are designed to do away with many legacy programming features (like pointer arithmetic). These features will only take your eye off your original target (for a small speed advantage, granted).

    These languages are less error prone and easier to debug. Therefore, they are the tool of choice for someone to create a program within a certain timeframe, a program which sources that can be read and changed for years to come (if well documented).

    And yes, they use OO. Things like streams and those nice GUI's wouldn't be possible without it. Maybe namespaces are even more important though.
  • Re:PFMUTA blocks (Score:1, Informative)

    by xanatos367 ( 301885 ) on Saturday August 27, 2005 @11:20AM (#13415500) Homepage
    Hey, suprise. unsafe code blocks affect the apps security settings. What was that thing called in Java? JNI? Yeah, that was it.
  • by gregluck ( 668236 ) on Saturday August 27, 2005 @12:12PM (#13415805)
    C# includes the "unsafe" keyword to allow a block of code to run outside the verifier.

    The study authors say "Since a security policy cannot be enforced on unmanaged code, we only consider managed code." Given that most C# applications use unmanaged code, they are potentially vulnerable to buffer overflow attacks and the like.

    C# has been criticised repeatdely in the security community for this feature. Java always runs in safe or managed mode and is therefore more secure than C#.

    For more on what unsafe code means see http://msdn.microsoft.com/library/default.asp?url= /library/en-us/dncscol/html/Csharp10182001.asp [microsoft.com]

    That the authors of the paper make conclusions about C# security, while deliberatley excluding a gaping hole, and the papers appearance on an MS site leads me to the belief that the paper was probably sponsored by MS and they directed the study authors to exclude unmanaged code from the scope.

    Bill Caelli, one of the world's leading security experts, humiliated a Microsoft representative over unsafe code and stated that "Microsoft had missed an historic opporunity to improve security in their products".

  • Re:Except... (Score:3, Informative)

    by __aaitqo8496 ( 231556 ) on Saturday August 27, 2005 @12:28PM (#13415894) Journal
    ...and Linux, Windows, OSX, BSD, and Solaris

    Welcome to the world of hackers making life better

    http://www.mono-project.com/Main_Page [mono-project.com]
  • by 51337 ( 833354 ) on Saturday August 27, 2005 @12:31PM (#13415916)
    There are at least 9 security flaws in .NET. The paper conveniently dismisses them all as not being part of the framework even though Microsoft classifies them as such on their Knowledge Base. This is only to justify their pretty little chart in the introduction showing that .NET has zero security flaws. If .NET has zero security flaws... nevermind. The paper is deception.
  • Re:In addition (Score:2, Informative)

    by VGPowerlord ( 621254 ) on Saturday August 27, 2005 @12:47PM (#13416021)
    .NET is Free source (as in free speech, mono or dotGNU)

    Java isn't

    That's right, there's no open [gnu.org] source [gnu.org] Java [kaffe.org] solutions [nongnu.org]. You also can't download the source code [sun.com].

    Oh wait...

  • by skraps ( 650379 ) on Saturday August 27, 2005 @01:02PM (#13416126)
    I have quite a number of years experience with VS6, more specifically VB6[...]
    VB6 and VS6 were packaged together, but they were completely different programs! VB6 and all previous versions of VB have their own completely different IDE. The Visual Studio IDE evolved from the Visual C++ series of IDEs. Your comparison is based on a faulty assumption.
  • by dnoyeb ( 547705 ) on Saturday August 27, 2005 @03:05PM (#13416841) Homepage Journal
    Why should you care when the garbage collector runs?

    I don't mean to insult you, but you have a misunderstanding. Java does not have destructors. Finalizers are not destructors. Once you accept that, you wont ask for certain behavior of destructors to be attributed to finalizers. finalizers are just there for testing and information. No production environment should use them. In fact, in production, they should disappear like asserts...

    Why do you need a call to x.close in the finalizer? You opened it, you close it.

    My solution has been to do a sort of c++ style thing. I have a reference counting system, and when they reach 0, I close the thing myself. Java does not use reference counting to know when to release an object, so perhaps thats why they dont have a destructor.
  • by rshimizu12 ( 668412 ) on Saturday August 27, 2005 @03:22PM (#13416926)
    This is a really blatantly biased study. I wonder where his grant money is coming from.......??? There is some major flaws with his theory....... He is focusing on .NET framework vulnerabilities. Microsoft tries to act as though the languages and .net api's have had no vulnerabilities. Here is just a few ASP.NET vulnerabilites: " Microsoft ASP.NET URI Canonicalization Unauthorized Web Access Vulnerability (Vulnerabilities) Rank: 1000 Last modified on: 2004-10-05 18:00:00 MDT URL: http://www.securityfocus.com/bid/11342 [securityfocus.com] 2 Microsoft Ships Nimda To Korea in .NET (News) Rank: 952 Last modified on: 2002-06-13 18:00:00 MDT URL: http://www.securityfocus.com/news/480 [securityfocus.com] 3 Microsoft ASP.NET StateServer Cookie Handling Buffer Overflow Vulnerability (Vulnerabilities) Rank: 944 Last modified on: 2002-06-05 18:00:00 MDT URL: http://www.securityfocus.com/bid/4958 [securityfocus.com] 4 Microsoft Visual Studio .NET Debugger Privilege Enforcement Weakness (Vulnerabilities) Rank: 932 Last modified on: 2004-04-15 18:00:00 MDT URL: http://www.securityfocus.com/bid/10161 [securityfocus.com] 5 Microsoft Visual Studio .NET Korean Version Nimda Infected File Vulnerability (Vulnerabilities) Rank: 907 Last modified on: 2002-06-12 18:00:00 MDT URL: http://www.securityfocus.com/bid/5012 [securityfocus.com] 6 Microsoft Visual Studio .NET msdds.dll Remote Code Execution Vulnerability (Vulnerabilities) Rank: 885 Last modified on: 2005-08-17 00:00:00 MDT URL: http://www.securityfocus.com/bid/14594 [securityfocus.com] 7 Microsoft Visual C++ 7/Visual C++.Net Buffer Overflow Protection Weakness (Vulnerabilities) Rank: 882 Last modified on: 2002-02-13 17:00:00 MST URL: http://www.securityfocus.com/bid/4108 [securityfocus.com] 8 Microsoft ASP.NET Unicode Character Conversion Multiple Cross-Site Scripting Vulnerabilities (Vulnerabilities) Rank: 879 Last modified on: 2005-02-15 17:00:00 MST URL: http://www.securityfocus.com/bid/12574 [securityfocus.com] 9 Microsoft ASP.NET RPC/Encoded Remote Denial Of Service Vulnerability (Vulnerabilities) Rank: 871 Last modified on: 2005-07-11 18:00:00 MDT URL: http://www.securityfocus.com/bid/14217 [securityfocus.com] 10 Microsoft ASP.NET Request Validation Null Byte Filter Bypass Vulnerability (Vulnerabilities) Rank: 871 Last modified on: 2003-09-07 18:00:00 MDT URL: http://www.securityfocus.com/bid/8562 [securityfocus.com] 11 Multiple Vulnerabilities found in Microsoft .Net Passport Services Rank: 871 Last modified on: 2003-05-07 18:00:00 MDT URL: http://www.securityfocus.com/archive/82/320989 [securityfocus.com] 12 Multiple Vulnerabilities found in Microsoft .Net Passport Services Rank: 871 Last modified on: 2003-05-07 18:00:00 MDT URL: http://www.securityfocus.com/archive/1/320808 [securityfocus.com]" So the idea that there is no vulnerabilites in .net is bunk at best..... Another problem is that because of the MSDN EULA there has not been any hack challenges or external without Microsoft's permission. A few months ago Windows NT Pro magazine hosted a IIS6 hack challenge and it was mysteriously pulled fromt their site. I tried contacting them, but they never responded to my questions about the hack challenges. The big issue however is that there is architectual flaws in the Windows architecture Microsoft's Blind Spot (http://news.com.com/2010-1071-831385.html [com.com]
  • by khasim ( 1285 ) <brandioch.conner@gmail.com> on Saturday August 27, 2005 @04:03PM (#13417139)
    It isn't which is really more "vulnerable".

    It is how you define your criteria as to what is "vulnerable" and what is "safe".

    They would have done a LOT better in just sticking to the design of each instead of counting admitted vulnerabilities and patches.

    Microsoft has been known to sit on vulnerabilities for a LONG time (http://www.eeye.com/html/research/upcoming/index. html [eeye.com]

    Security starts with the security model. Here is where you'll see patches to disable stuff in a flawed model. You cannot just count the patches here, but they are useful for evaluating the model itself.

    Then that model has to be implemented in code. This is where you'll see bug fixes for code errors.

    The last thing to look at is any application built by someone else on that platform.

    And one last item to consider. Any platform is only as "secure" as the level beneath it. If .Net can be exploited by a vulnerability in Windows, then it can be exploited. This is particularly important because Microsoft builds both platforms.

    Here is where they get it wrong on Java:
    Both platforms need some way of bootstrapping to install the initial classes and loading mechanisms. Java 1.0 used a trusted file path that gave full trust to any class stored on the path. Code on the system CLASSPATH was fully trusted, so problems occurred when untrusted code could be installed on the CLASSPATH [15]. Java 2 treats code found on the CLASSPATH as any other code, but maintains backwards compatibility by using the bootclasspath to identify completely trusted code necessary to bootstrap the class loader.
    So, if Windows is compromised and code inserted to Java to run, then Java is at fault ... but if Windows is compromised and code is inserted for .Net to run, then that shouldn't count because the compromise happened before .Net was running.

    Either you count it as a flaw in both, or you don't count it for either.

"When the going gets tough, the tough get empirical." -- Jon Carroll

Working...