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:

    It seems to me that our three basic needs, for food and security and love, are so mixed and mingled and entwined that we cannot straightly think of one without the others. So it happens that when I write of hunger, I am really writing about love and the hunger for it, and warmth and the love of it and the hunger for it ... and then the warmth and richness and fine reality of hunger satisfied ... and it is all one.
    M.F.K. Fisher (b. 1908)

    If the children and youth of a nation are afforded opportunity to develop their capacities to the fullest, if they are given the knowledge to understand the world and the wisdom to change it, then the prospects for the future are bright. In contrast, a society which neglects its children, however well it may function in other respects, risks eventual disorganization and demise.
    Urie Bronfenbrenner (b. 1917)