python - Authenticating on Web.py - will this code be unsafe for production? -
i making simple web-app requires login admin page. came across incantation on web.py site (http://webpy.org/cookbook/userauth) :
import hashlib import web def post(self): = web.input() authdb = sqlite3.connect('users.db') pwdhash = hashlib.md5(i.password).hexdigest() check = authdb.execute('select * users username=? , password=?', (i.username, pwdhash)) if check: session.loggedin = true session.username = i.username raise web.seeother('/results') else: return render.base("those login details don't work.")
however page gives ominous warning: "do not use code on real site - illustration.". wondering if there major holes in this, i'm unfamiliar web-programming wanted make sure using code wont unwittingly make app open trivial attack vectors?
many thanks
the possible problem can think of here, if somehow possible exploit md5 collisions, i.e. 2 different strings can generate same md5 hash - in case potentially log in password not correct, generates same md5 hash.
changing better hashing algorithm such sha-1 (or else available in hashlib) close potential security problem.
as far know, difficult exploit md5 collision problem gain access. so, broken, , quoting security guru bruce schneier wikipedia article:
[he] wrote of attack "[w]e knew md5 broken hash function" , "no 1 should using md5 anymore."
Comments
Post a Comment