8 CRUD APIs from GPT‑5.6 Sol Reveal 24 Vulnerabilities—Why No Verification for Password Reset?

The author asked GPT‑5.6 Sol to generate eight Flask CRUD endpoints, ran a security scan that uncovered 24 flaws—including 11 critical issues and a password‑reset function without any verification—then iteratively prompted the model to fix them, highlighting that AI‑written code needs explicit security guidance.

IT Xianyu
IT Xianyu
IT Xianyu
8 CRUD APIs from GPT‑5.6 Sol Reveal 24 Vulnerabilities—Why No Verification for Password Reset?

On a Wednesday afternoon I asked GPT‑5.6 Sol to write a set of user‑management APIs (login, registration, search, order query, file upload, password reset, user list, product deletion) in Flask that could run out of the box. The model produced eight complete endpoints in about 40 minutes, with correct routes, parameters and JSON responses.

Scan results send chills down my spine

Running a security scanner against the generated code yielded the following summary:

Scanned interfaces: 8
Total vulnerabilities: 24
Critical: 11  High: 4  Medium: 6  Low: 3
Secure interfaces: 0/8

Every endpoint contained at least one issue; none were clean.

The most outrageous password‑reset endpoint

Among the 24 problems, the password‑reset logic was the worst. The model wrote code that accepts an email and a new password and directly updates the database without any verification code, old‑password check, or email confirmation link:

@app.route('/reset_password', methods=['POST'])

def reset_password():
    email = request.form['email']
    new_password = request.form['new_password']
    db.execute(f"UPDATE users SET password='{new_password}' WHERE email='{email}'")
    return jsonify({"status": "密码已重置"})

This means anyone who knows a user's email can reset the password to any value and log in, effectively creating a back‑door.

SQL injection dominates

Six of the vulnerabilities were SQL injection flaws, each using a different string‑concatenation technique (plain concatenation, format(), f‑strings). The login endpoint, for example, built the query as:

query = "SELECT * FROM users WHERE username='" + username + "' AND password='" + password + "'"

The search endpoint used an f‑string with a LIKE clause:

query = f"SELECT id, name, price FROM products WHERE name LIKE '%{keyword}%'

None of these queries employed parameterised statements.

One‑click XSS in the search endpoint

The same search endpoint also concatenated product names directly into HTML:

html += f"<p>{row[1]} - ¥{row[2]}</p>"

If a product name contains <script>alert('xss')</script>, the script executes in the browser, creating a reflected XSS vulnerability.

Three rounds of prompting to fix everything

In the first revision I only pointed out the SQL injection issues; the model replaced the queries with parameterised versions but left the password‑reset logic unchanged. After asking explicitly whether the password‑reset endpoint needed a verification step, the model suggested adding an email or SMS code and supplied a corrected snippet. In the third round I requested a full list of security problems and fixes; the model added parameterised queries, password hashing, CSRF protection, file‑type whitelists, authentication middleware and rate‑limiting, covering all 24 reported issues.

AI‑generated code ≠ secure code

While GPT‑5.6 Sol can produce functional code extremely quickly (eight endpoints in 40 minutes versus half a day manually), its default behaviour lacks security awareness. To obtain safe code you must explicitly request security best practices or run a dedicated security review after generation. The experience demonstrates that AI‑assisted development still requires human oversight, especially for security‑critical components.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AI code generationSQL injectionFlasksecurity scanningpassword resetGPT-5.6
IT Xianyu
Written by

IT Xianyu

We share common IT technologies (Java, Web, SQL, etc.) and practical applications of emerging software development techniques. New articles are posted daily. Follow IT Xianyu to stay ahead in tech. The IT Xianyu series is being regularly updated.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.