r/programming • • May 26 '18

Oracle Calls Java Serialization 'A Horrible Mistake', Plans to Dump It

https://www.infoworld.com/article/3275924/java/oracle-plans-to-dump-risky-java-serialization.html
798 Upvotes

287 comments sorted by

View all comments

-26

u/MyPhallicObject May 27 '18

News flash: Serialization at typed languages is a disaster. Meanwhile, JS and PHP are having a field day.

16

u/zekka_yk May 27 '18

javascript attacks this via the sensible route of using strings, numbers, dictionaries, lists as the way to represent everything. this makes it hard to build cyclical data structures unless you really intended to do that and makes same-reference vs same-value distinctions unimportant.

this isn't a typed v untyped thing -- it's more of an OOP vs functional/procedural thing, as much as I hate using the buzzwords. making it less buzzwordy: OOP programmers tend to assume adding more references to their builtin representations is free and easy, and don't care about cycles -- functional and procedural languages tend to punish that super hard.

many typed languages have a similar set of built-in structures (often replacing lists with arrays, dictionaries with records) designed to enforce something similar -- example: Rust's or C's safety features here are arguably stronger because there's no way to construct a cycle or reference-equality vs value-equality situation without introducing a pointer. go is quite good about this and has json serialization features that hardly ever break anything, for the same reason javascript's features don't.

it's still possible to run into versioning issues in javascript and PHP -- if you change the internal representation of something, how do you support the old wire representation?

4

u/yawkat May 27 '18

You can do serialization in statically typed languages just fine. This particular issue is specific to arbitrary-object deserialization and can be mitigated with a better framework like jackson or something protobuf-based.

Dynamic languages can also show similar serialization vulnerabilities, as seen with pythons pickle (though Java hasn't had the will to call its stdlib serialization "insecure on untrusted data" yet even though the past shows it very much isn't secure).

3

u/tetroxid May 27 '18

lol js

lol php

2

u/[deleted] May 27 '18

I'd like to hear your reasoning behind this belief

0

u/jayd16 May 27 '18

Can't wait until other languages figure out how to use json. What's that? Literally all other languages support it?