Skip to main content

Security considerations when using Lisp features

Today, Kevin Rosenberg asked on IRC how to prevent code insertion when READing data from a string. A solution to that problem is binding *READ-EVAL* to NIL in code using READ.

Now, that got me wondering: which other security pitfalls are there in lisp? These are the other READ-related ones that came up in the discussion that followed:

  • READ can intern symbols in packages other than the one you want it to (could lead to bugs further down in the application)

  • READ (again) can produce self-referential objects (via #n=) that can make your application go into endless loops/recursion

  • And of course, EVALing code that you get from the outside world is always a bad idea. As is writing it to a file and using COMPILE/LOAD.

So, any others? I’m sure there are. Having them collected in a central place would be a really good thing. Improved awareness of security problems might help prevent stuff like this bug in an intrusion detection system that did not set *READ-EVAL*.