CSC/ECE 517 Fall 2012/ch1 1w28 mv

From Expertiza_Wiki
Revision as of 00:28, 15 September 2012 by Vgupta6 (talk | contribs)
Jump to navigation Jump to search

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: http://en.wikipedia.org/wiki/Python_(programming_language) session['authenticated'] = False data = get_data() foo = eval(data) </source>

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.