Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ruby's Marshal library is not quite as blatantly insecure as pickle (it won't do any string interpolation on load), but you shouldn't trust any of these facilities: you're essentially passing data to a very weird variant of eval().

But [edit, should have said this to begin with] pickle isn't an interchange format. It's not supposed to be secure. Python already offers a myriad of good interchange formats. Interchange isn't pickle's job, and if you use it for that, you've made a serious design error.

Ruby unfortunately blurs the line here by using Marshal as an interchange format in some cases. None of those cases are insecure by design (they all allow code execution by design), but the usage does create a confusing precedent.

You're better off with ASN.1/BER than you are with Pickle or Marshal as a file or protocol format; that's how inappropriate Pickle is to the task.



> not quite as blatantly insecure as pickle (it won't do any string interpolation on load)

Are you saying that pickle works via string interpolation (or that this problem is possible because of interpolation)? That's incorrect...


No; Marshal and pickle are very different (and I confused things by talking in Ruby terms and referring to Python). Ruby Marshal isn't a virtual machine. Pickle is more like Flash or Postscript than RTF, which is what Marshal is like.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: