Eval - Security Risks

Security Risks

Special care must be taken when using eval with data from an untrusted source. For instance, assuming that the get_data function gets data from the Internet, this Python code is insecure:

session = False data = get_data foo = eval(data)

An attacker could supply the program with the string "session.update(authenticated=True)" as data, which would update the session dictionary to set an authenticated key to be True. To remedy this, all data which will be used with eval must be escaped, or it must be run without access to potentially harmful functions.

Read more about this topic:  Eval

Famous quotes containing the words security and/or risks:

    Happiness is peace after strife, the overcoming of difficulties, the feeling of security and well-being. The only really happy folk are married women and single men.
    —H.L. (Henry Lewis)

    There are risks which are not acceptable: the destruction of humanity is one of them.
    Friedrich Dürrenmatt (1921–1990)