{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/10805","repository_url":"https://api.github.com/repos/sympy/sympy","labels_url":"https://api.github.com/repos/sympy/sympy/issues/10805/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/10805/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/10805/events","html_url":"https://github.com/sympy/sympy/issues/10805","id":140331432,"number":10805,"title":"sympify shouldn't use eval","user":{"login":"The-Penultimate-Defenestrator","id":10377391,"avatar_url":"https://avatars.githubusercontent.com/u/10377391?v=3","gravatar_id":"","url":"https://api.github.com/users/The-Penultimate-Defenestrator","html_url":"https://github.com/The-Penultimate-Defenestrator","followers_url":"https://api.github.com/users/The-Penultimate-Defenestrator/followers","following_url":"https://api.github.com/users/The-Penultimate-Defenestrator/following{/other_user}","gists_url":"https://api.github.com/users/The-Penultimate-Defenestrator/gists{/gist_id}","starred_url":"https://api.github.com/users/The-Penultimate-Defenestrator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/The-Penultimate-Defenestrator/subscriptions","organizations_url":"https://api.github.com/users/The-Penultimate-Defenestrator/orgs","repos_url":"https://api.github.com/users/The-Penultimate-Defenestrator/repos","events_url":"https://api.github.com/users/The-Penultimate-Defenestrator/events{/privacy}","received_events_url":"https://api.github.com/users/The-Penultimate-Defenestrator/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/core.sympify","name":"core.sympify","color":"0000FF"},{"url":"https://api.github.com/repos/sympy/sympy/labels/parsing","name":"parsing","color":"0000FF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-03-12T01:30:33Z","updated_at":"2016-03-14T20:03:25Z","closed_at":null,"body":"I think `sympy` shoudl be made safer for untrusted input, as discussed in the comments on [this stackoverflow issue](http://stackoverflow.com/q/35929640/4414003). Since `sympy` uses `eval` under the hood, it's vulnerable to attacks. There's really no reason to allow attribute access, etc, which leads to vulnerabilities like [these](http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html). I'd love a safer sympy that I could really use with foreign input. "},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/196498910","html_url":"https://github.com/sympy/sympy/issues/10805#issuecomment-196498910","issue_url":"https://api.github.com/repos/sympy/sympy/issues/10805","id":196498910,"user":{"login":"asmeurer","id":71486,"avatar_url":"https://avatars.githubusercontent.com/u/71486?v=3","gravatar_id":"","url":"https://api.github.com/users/asmeurer","html_url":"https://github.com/asmeurer","followers_url":"https://api.github.com/users/asmeurer/followers","following_url":"https://api.github.com/users/asmeurer/following{/other_user}","gists_url":"https://api.github.com/users/asmeurer/gists{/gist_id}","starred_url":"https://api.github.com/users/asmeurer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmeurer/subscriptions","organizations_url":"https://api.github.com/users/asmeurer/orgs","repos_url":"https://api.github.com/users/asmeurer/repos","events_url":"https://api.github.com/users/asmeurer/events{/privacy}","received_events_url":"https://api.github.com/users/asmeurer/received_events","type":"User","site_admin":false},"created_at":"2016-03-14T20:03:25Z","updated_at":"2016-03-14T20:03:25Z","body":"I think that's a better way to do it. \r\n\r\nHere's some good docs on the ast nodes https://greentreesnakes.readthedocs.org/en/latest/nodes.html. The main dangerous one is Attribute, but we could also remove some of the others that don't parse to SymPy expressions, just to be safe (like `comprehension`). \r\n\r\nAt a glance, some things that are missing from your whitelist are slices (needed for Indexed), strings (needed to define things like `MatrixSymbol`, but not f-strings--I don't know how they are defined in the 3.6 ast), lambdas (converted to `Lambda`), and Compare (like `a < b`). "}}