Re:Clojure's Default Reader is Unsafe
by willismichael on Friday March 08, 2013 @11:35AM
(#5344285)
From that comment it seems like the Java constructor loophole has been closed. With that gone, I don't understand why the reader is still dangerous. What am I missing?
[ Parent
| on HN ]
I was wondering this too, and deliberately tried to break something using the clojure 1.5 reader with read-eval false. (Makes a change from building things all day!).
Result:
user=> (binding [*read-eval* false] (read-string "``````````x"))
OutOfMemoryError Java heap space clojure.lang.RT.cons (RT.java:570)There's a huge IRC log that explains the reasoning here. Mostly, it comes down to: you can't trust that libraries haven't changed read-eval back, which means that now instead of being assured that a certain fn can never be harmful, you would need to audit all libraries you use. It's the assumption itself (that read and read-string are safe) what makes it unsafe...