socket.recvfrom_into function in Modules/ socketmodule.c in Python 2.5 before 2.7.7, 3.x before 3.3.4, and 3.4.x before 3.4rc1 allows remote attackers to execute arbitrary code via a crafted string. Publish Date : 2014-02-28 CVE-2014-1912
self.user and self.user.failed_login_attempts > 4 def validate(self): self.user = _datastore.get_user(self.email.data) if not self.user: return False if not self.show_captcha(): del self._fields['captcha'] result = super().validate() if not result: self.user.failed_login_attempts += 1 else: self.user.failed_login_attempts = 0 _datastore.put(self.user) _datastore.commit() return result Attack protection Flask-Security
version="1.0"?> <notifications> <messages>disabled </messages> <call>enabled </call> </notifications> ''' tree = etree.fromstring(user_xml) for setting in tree.xpath('/notifications /*'): if setting.text not in ('enabled', 'disabled'): raise ValueError( "Incorrect value '{}'".format(value) ) . . .
'''<?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY passwd SYSTEM "file: ///etc/passwd">]> <notifications> <messages>&passwd; </messages> <call>enabled </call> </notifications> ''' tree = etree.fromstring(user_xml) for setting in tree.xpath('/notifications /*'): if setting.text not in ('enabled', 'disabled'): raise ValueError( "Incorrect value ‘{}’".format(value) ) . . .
'''<?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY passwd SYSTEM "file: ///etc/passwd">]> <notifications> <messages>&passwd; </messages> <call>enabled </call> </notifications> ''' tree = etree.fromstring(user_xml) for setting in tree.xpath('/notifications /*'): if setting.text not in ('enabled', 'disabled'): raise ValueError( "Incorrect value ‘{}’".format(value) ) . . . Traceback (most recent call last): File «pycon_example.py", line 53, in <module> "Incorrect value '{}'".format(setting.text) ValueError: Incorrect value ' ## # User Database # # Note that this file is consulted directly only when the system is running # in single-user mode. At other times this information is provided by # Open Directory. # # See the opendirectoryd(8) man page for additional information about # Open Directory. ## nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false root:*:0:0:System Administrator:/var/root:/bin/sh daemon:*:1:1:System Services:/var/root:/usr/bin/false
'''<?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY passwd SYSTEM "file: ///etc/passwd">]> <notifications> <messages>&passwd; </messages> <call>enabled </call> </notifications> ''' tree = etree.fromstring( user_xml, parser=etree.XMLParser(resolve_entities=False) ) for setting in tree.xpath('/notifications /*'): if setting.text not in ('enabled', 'disabled'): raise ValueError( "Incorrect value '{}'".format(value)
'''<?xml version="1.0"?> <!DOCTYPE root [ <!ENTITY passwd SYSTEM "file: ///etc/passwd">]> <notifications> <messages>&passwd; </messages> <call>enabled </call> </notifications> ''' tree = etree.fromstring(user_xml) for setting in tree.xpath('/notifications /*'): if setting.text not in ('enabled', 'disabled'): raise ValueError( "Incorrect value ‘{}’".format(value) ) . . . Traceback (most recent call last): File "pycon_example.py", line 53, in <module> "Incorrect value '{}'".format(setting.text) ValueError: Incorrect value 'None'
to call yaml.load with any data received from an untrusted source! yaml.load is as powerful as pickle.load and so may call any Python function. Check the yaml.safe_load function though.
= yaml.safe_load(user_input) yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/name:yaml.__version__' in "<unicode string>", line 1, column 6: key: !!python/name:yaml.__version__