Files
codeql/python/ql/src/Security/CWE-798/HardcodedCredentials.py
Rasmus Wriedt Larsen 7afe3972d8 Revert "Merge pull request #5171 from RasmusWL/restructure-queries"
This reverts commit 8caafb3710, reversing
changes made to ec79094957.
2021-02-17 16:32:53 +01:00

20 lines
615 B
Python

import hashlib
import binascii
def process_request(request):
password = request.GET["password"]
# BAD: Inbound authentication made by comparison to string literal
if password == "myPa55word":
redirect("login")
hashed_password = load_from_config('hashed_password', CONFIG_FILE)
salt = load_from_config('salt', CONFIG_FILE)
#GOOD: Inbound authentication made by comparing to a hash password from a config file.
dk = hashlib.pbkdf2_hmac('sha256', password, salt, 100000)
hashed_input = binascii.hexlify(dk)
if hashed_input == hashed_password:
redirect("login")