Last active
November 10, 2017 23:31
Star
You must be signed in to star a gist
Example web service with a SQLi that decrypts data that is stored encrypted in the database.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import request, Flask | |
import json | |
from fake_stuff import current_user, db, aes_decrypt | |
secrets = {'fooCorp': 'someKey', 'barCorp': 'otherKey'} | |
app = Flask(__name__) | |
@app.route("/", methods=["GET"]) | |
def index(): | |
# pretend this request was authenticated such that we can lookup the user's company | |
secret = secrets[current_user.company] | |
# yay we've built a SQLi | |
encrypted_results = db.fetch('select qux from foo where bar = %s" % request.args['bar']) | |
# decrypt our quxes | |
data = [aes_decrypt(key=secret, value=x) for x in encrypted_results] | |
return 200, json.dumps(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment