Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan

Finding Security Vulnerabilities

MediumCoding00:00
Practice interviewer
In session
5 left
00:00

Your question is Finding Security Vulnerabilities. Take a moment with it on the right.

Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).

You need to log in / sign up to chat or submit.

Problem

Tide is a business banking platform, and your team owns the payments API that small-business customers use to move money between accounts. A colleague opened a pull request adding a funds-transfer endpoint, and you have been asked to review it before it reaches production.

import hashlib
import logging

API_KEY = "sk_live_4f9a1c2b8e7d3f0a9c1b2e3d4f5a6b7c"

app_logger = logging.getLogger("tide.payments")


@app.route("/api/accounts/<account_id>/transfer", methods=["POST"])
def transfer_funds(account_id):
    data = request.get_json()
    recipient = data["recipient_sort_code"]
    amount = data["amount"]
    card_number = data.get("card_number")

    app_logger.info(f"Transfer request: account={account_id} card={card_number} amount={amount}")

    query = "SELECT balance FROM accounts WHERE id = '" + account_id + "'"
    result = db.execute(query)
    balance = result[0]["balance"]

    if amount > balance:
        return {"error": "insufficient funds"}, 400

    db.execute("UPDATE accounts SET balance = balance - %s WHERE id = %s" % (amount, account_id))
    db.execute("INSERT INTO transfers (account_id, recipient, amount) VALUES (%s, %s, %s)",
               (account_id, recipient, amount))

    return {"status": "completed"}, 200


def hash_password(password):
    return hashlib.md5(password.encode()).hexdigest()

Can you identify the potential security vulnerabilities in this snippet? Explain each risk and what you would change to close it.