AI security

Why your AI copilot doesn't understand OWASP

, 4 min read

Ask an AI assistant to explain the OWASP Top 10 and you'll get a good answer. Ask it to write an API endpoint and you may get code that breaks the first item on that list. The two tasks are different. Explaining a risk is recall. Avoiding it means knowing your own system's rules: who owns which record, which input crosses a trust boundary, what should happen when something fails. The assistant doesn't have that context unless you give it.

The 2025 edition of the OWASP Top 10 gives a useful map of where the gap shows.

A01: Broken Access Control

Still number one. Here is a typical generated endpoint:

@app.route("/api/users/<int:user_id>/data")
@login_required
def get_user_data(user_id):
    data = db.session.get(UserData, user_id)
    return jsonify(data.to_dict())

It checks that someone is logged in. It never checks that the logged-in user is user_id. Any user can read anyone's data by changing a number in the URL. That's an insecure direct object reference, the textbook broken-access-control bug. The assistant can't know your ownership rules, and most example code it learned from doesn't have any.

The fix is a two-line check that only you can write, because only you know the rule:

    if user_id != current_user.id and not current_user.is_admin:
        abort(404)

SSRF was merged into this category in 2025. It shows up when assistants write "fetch this URL for me" helpers with no allowlist.

A02: Security Misconfiguration

Generated configuration tends to copy development defaults:

app.config["DEBUG"] = True
app.config["SECRET_KEY"] = "development-key"
CORS(app, resources={r"/*": {"origins": "*"}})

Debug mode on, a guessable signing key and CORS open to every origin. All three are fine on a laptop and a finding in production.

A03: Software Supply Chain Failures

Assistants suggest packages from memory. The versions may be years old, and the names may not exist. Research published at USENIX Security 2025 found hallucinated package names in at least 5.2% of commercial-model outputs and 21.7% of open-source-model outputs. Attackers can register those names. Check every new dependency an assistant introduces before you install it.

A04: Cryptographic Failures

Ask for "hash the password" and you may get MD5 or SHA-256 with no salt. Both are fast hashes built for integrity checks, not password storage. OWASP's password storage guidance points to slow, salted algorithms such as Argon2id, scrypt or bcrypt.

A05: Injection

String-built SQL is still common in generated code, especially in less mainstream languages and frameworks. Veracode's 2025 test of more than 100 models found that they failed to defend against cross-site scripting in 86% of relevant samples.

A06: Insecure Design

This category is about decisions made before code exists: threat models, trust boundaries, abuse cases. An assistant working one function at a time can't see those. It will build the insecure design you describe as faithfully as the secure one.

A07 to A10: the quiet failures

  • Authentication failures: generated login flows usually skip rate limiting, lockout and MFA hooks.
  • Integrity failures: examples that curl | sh an installer, or load serialised objects from untrusted input.
  • Logging and alerting failures: assistants rarely add security event logging unless asked.
  • Mishandling of exceptional conditions (new in 2025): except: pass, errors returned with stack traces, and checks that are skipped when a lookup fails.

What works

You can't teach an assistant your threat model one prompt at a time. But you can make the system around it catch what it misses:

  1. Put your rules in context. Most assistants accept project-level instructions. Write down the rules the code must follow: parameterised queries only, every handler checks ownership, secrets only from the environment. It doesn't guarantee anything, but it narrows the defaults.
  2. Scan every pull request. SAST with an OWASP-focused ruleset, secret scanning and dependency review. Fail the build on high-confidence findings.
  3. Test authorisation directly. Scanners are weak at A01. Write tests that log in as user A and ask for user B's data, and expect a refusal.
  4. Review with the right question. Don't ask "does it work?" Ask "where does untrusted input go, and who is allowed to do this?"
# A quick local check before you push
semgrep scan --config p/owasp-top-ten --error .

The OWASP list has changed little at the top over the years because the same mistakes keep happening. Assistants learned from code full of those mistakes. The gate in front of production has to be the part that knows better.

Sources

Start with a $500 audit.

See exactly where you stand. Actionable findings in a week.

The full report and debrief call. Delivery in 5–7 business days.