News for hackers. Stuff that matters.
Re:Is Lisp still useful in today's world? (2011) by pjungwir on Thursday February 21, 2013 @01:16PM (#5258993)
Yes, by "dangerous" I mean prone to security exploits. I've got nothing against Lisp--I think it's a beautiful language, and I've dabbled in CL, Scheme, and Clojure--but whenever I hear about using data as code I get a warning tingle in the back of my head. One of the lessons of the recent Ruby YAML debacle is that an executable data format will get used for untrusted input eventually somewhere or other. (Edit: For example I can totally imagine the digital circuits simulator from SICP 3.3.4 saving/reading Lisp code as an input document.)

Maybe the power of Lisp's data-as-code is worth the risk. We don't stop using string concatenation because of SQL injection. It's just that I've never even read so much as a warning about this feature, and I'm curious what Lisp users have to say about it.

Re:Is Lisp still useful in today's world? (2011) by pavelludiq on Thursday February 21, 2013 @01:29PM (#5259099)

  eval("dangerous python code here")
As I pointed out, it is a problem in any language that has eval. The way you deal with it, is you never eval anything untrusted, which is actually extremely easy to do. I don't believe I've ever used eval ever.

In CL specifically, because the reader can evaluate code as well, every time you use the read function, you should know these two things: 1) never use it for user input. 2) bind read-eval to nil. You'll be fine, or more accurately, no worse than anybody else :)

On the other hand macros, and having a json style serialization format that is much more powerful and actually extensible is a big plus :)

Re:Is Lisp still useful in today's world? (2011) by sdkmvx on Thursday February 21, 2013 @06:50PM (#5261479)
Is it actually dangerous to use read for user input?

    (defun read-data ()
      (let ((data (let ((*read-eval* 'nil)) (read))))
        (mapcar
         (lambda (x) (format 't "~a: ~a~%" (car x) (cdr x)))
         data)))
Then I can

    (read-data)
    (("a" . 1) ("b" . 2) ("c" . (funcall (lambda () (princ "I ran code!")))))
And the following will print.

    a: 1
    b: 2
    c: (FUNCALL (LAMBDA () (PRINC I ran code!)))
But of course unless I eval the code, arbitrary code will not run (assuming I haven't forgotten some aspect of the reader).
Re:Is Lisp still useful in today's world? (2011) by betterunix on Thursday February 21, 2013 @01:38PM (#5259161)
"It's just that I've never even read so much as a warning about this feature"

...have you really looked? Here is a warning, in the section titled, "Reader Security:"

http://letoverlambda.com/index.cl/guest/chap4.html

Re:Is Lisp still useful in today's world? (2011) by pjungwir on Thursday February 21, 2013 @01:44PM (#5259201)
> have you really looked?

To be fair, no. I'm not a practicing Lisp programmer; I just admire the language. But I've read a fair number of Lisp tutorials, as well as SICP, and I don't recall it being mentioned. I'm glad it's out there somewhere!

Re:Is Lisp still useful in today's world? (2011) by spacemanaki on Thursday February 21, 2013 @01:39PM (#5259170)
I don't buy your example from chapter 3 of SICP. You could just as easily serialize Python code and eval it. That would be bad practice in Python and it would be in Lisp.

The power of "code is/as data" means that Lisp macros can manipulate code as easily as other Lisp code manipulates data. It's not really about eval.

Re:Is Lisp still useful in today's world? (2011) by pjungwir on Thursday February 21, 2013 @01:57PM (#5259301)
> You could just as easily serialize Python code and eval it.

That seems to be the consensus among all the people replying to me. :-) Fair enough. The difference I see is that lots of Lisp authors praise "no syntax" and code-as-data, so it seems to be encouraged, whereas I don't see Python programmers encouraging use of eval. Lisp seems designed for this kind of meta-programming. And it's really cool! It just makes me nervous.

As an outsider, I really appreciate the responses from you all. Basically you seem to be saying, "It's not an issue. We use it for macros, not for untrusted inputs. Don't call eval and you're fine." Obviously I wouldn't want you to do anything else. :-)

Anyway, thanks for the replies. It's great to have a community where I can ask Lisp users about something like this and learn what they think! It's something I've wondered about for a long time.