Live data from Hacker News

Oracle plans to dump risky Java serialization

infoworld.com

131–140 of 157 posts

Re: Oracle plans to dump risky Java serialization

#131
post #48
post #20

Earlier quoted context omitted.

That only works because Python is an interpreter. Won't cause a thing on Java.

The JRE has had arbitrary code execution attacks on serialization. The leaked classes eventually invoke a class loader and instantiate your binary code as a new java class.

Does the serialization work with bytecode though? Doesn't it stream just data members, not method implementations?

Re: Oracle plans to dump risky Java serialization

#132
post #113

Earlier quoted context omitted.

There are plenty of other options though, such as JSON, MessagePack, Protocol Buffers etc. And BinaryFormatter has always performed poorly against 3rd party libs, especially other binary formatters such MessagePack

Do any of these options support proper handling of cycles in the object graph out of the box?

Yes.

Using the Newtonsoft library you can configure it using `JsonSerializerSettings.ReferenceLoopHandling`, and with with protobuf-net you set `AsReference` on your class's `ProtoContractAttribute`. I don't think MessagePack-CSharp or msgpack-cli support cyclic references tho.

Re: Oracle plans to dump risky Java serialization

#133
post #115

Earlier quoted context omitted.

There's really no such thing as a "binary object graph format." Objects are not data. Code is not data. It's why serializing objects is so very complicated and dangerous. Serialized "data" is a program that can do everything a normal Java program can do. In the 90s we called this feature "mobile code" and thought it might be the future of distributed computing. Today we call it a "code injection attack" and recognize…

> Code is not data Lisp would, of course, disagree. :-)

(import (ice-9 match))

(define data '(display code))

(define code (let ((pe primitive-eval)) (match data ((fun arg ...) (lambda () (apply (pe fun) arg))))))

(code)

Re: Oracle plans to dump risky Java serialization

#134
post #110

Earlier quoted context omitted.

Regarding YAML, it's not just Ruby: * Python's yaml.load() hapilly executes arbitrary code. * Some Perl YAML libraries deserialize objects by default: http://blogs.perl.org/users/tinita/2018/02/safely-load-untru...

Python's YAML libraries come with a safe_load function that disables !! commands, so it can be used without loading arbitrary objects.

And they warn quite clearly about that. Though in hindsight, having load and unsafe_load would have been safer.

Re: Oracle plans to dump risky Java serialization

#135

Can someone briefly explain the problems and how general they are to other serialization interfaces?

> and how general they are to other serialization interfaces? This class of problems was very common when that serialization appeared in Java. It was possible to inject code into pretty much anything, e-mails (1), office documents (2), web pages. Since that time, most developers / managers have learned their lesson and started to pay attention / allocate resources so modern software/protocols/formats tend to be more…

Except that (1) was completely normal executable program (albeit in not well-known "format", which windows has many) and was not in any way executed automatically (and has nothing to with Java). And (2) is VBA macro virus which again has nothing to do with Java.

Re: Oracle plans to dump risky Java serialization

#136
post #104

I applaud the general decision, but I wonder what will happen to existing blobs of serialized data. Will there be any migration tools provided? Apart from the horrible security, what annoyed me the most with serialization is the lack of control you have over the process. There doesn't seem to be a way to access serialized data as a simple parse tree or record sequence - you have to construct objects of the actual cla…

In fact the Java Serialization Stream format (contrary to most other serialization formats) is designed such that it has well-defined grammar and you can in theory build parser that creates parse trees given only the definitions of classes involved without running any code from these classes. (ie. the parts that depend on behavior of writeObject()/readObject() are delimited inside the stream and you only need to know whether class implements such methods)

Many other language-specific serialization mechanisms just write arbitrary binary data into stream which can then only be parsed by ad-hoc recursive descent parser implemented by equivalent of java's readObject().

Re: Oracle plans to dump risky Java serialization

#137
post #115

Earlier quoted context omitted.

There's really no such thing as a "binary object graph format." Objects are not data. Code is not data. It's why serializing objects is so very complicated and dangerous. Serialized "data" is a program that can do everything a normal Java program can do. In the 90s we called this feature "mobile code" and thought it might be the future of distributed computing. Today we call it a "code injection attack" and recognize…

There's no such thing as "data". Every piece of "data" eventually gets interpreted, thus becoming a "command" in some level of abstraction. The core of every security vulnerability is the belief that "this is just a piece of data".

A parable for that viewpoint: https://en.wikipedia.org/wiki/BLIT_(short_story)

Re: Oracle plans to dump risky Java serialization

#139
post #115
post #104

I applaud the general decision, but I wonder what will happen to existing blobs of serialized data. Will there be any migration tools provided? Apart from the horrible security, what annoyed me the most with serialization is the lack of control you have over the process. There doesn't seem to be a way to access serialized data as a simple parse tree or record sequence - you have to construct objects of the actual cla…

There's really no such thing as a "binary object graph format." Objects are not data. Code is not data. It's why serializing objects is so very complicated and dangerous. Serialized "data" is a program that can do everything a normal Java program can do. In the 90s we called this feature "mobile code" and thought it might be the future of distributed computing. Today we call it a "code injection attack" and recognize…

The IBM J9 JVM comes with a library called PackedObjects, ie objects whose memory can be off-heap too.

Re: Oracle plans to dump risky Java serialization

#140
post #135

Earlier quoted context omitted.

> and how general they are to other serialization interfaces? This class of problems was very common when that serialization appeared in Java. It was possible to inject code into pretty much anything, e-mails (1), office documents (2), web pages. Since that time, most developers / managers have learned their lesson and started to pay attention / allocate resources so modern software/protocols/formats tend to be more…

Except that (1) was completely normal executable program (albeit in not well-known "format", which windows has many) and was not in any way executed automatically (and has nothing to with Java). And (2) is VBA macro virus which again has nothing to do with Java.

The comment I replied to specifically asked about other serialization interfaces.

Both that VBS, and DOC/XLS, contain some code inside. But users though they are just data files, so they opened these things, running the code.

Also, old MS office files were not limited to embedded VBA. They are OLE compound files, so a specially crafted file can create and run ActiveX objects (often implemented as Win32 DLLs registered under HKEY_CLASSES_ROOT key of the registry) installed on user’s system. This is very similar to the way Java serializer creates and runs objects when desterilizing data received from untrusted source.

Post reply on HN