Skip to content
← All tasks

What does an AI need to know to review code for security?

A security review by an AI is only as good as the instructions it gets: it needs to know what to review, what the system is built with, what is out of scope and what a useful finding looks like. Only review systems that belong to you or that you've been asked to review.

By Updated

What does the AI need to know from you?

  1. What is the system, and what is it built with?

    Language, framework and database determine which vulnerabilities are even possible.

  2. What's in scope, and what isn't?

    Sign-in and file upload yes, hosting no: without a scope, the AI checks a bit of everything and nothing thoroughly.

  3. Which standard is it checked against?

    A well-known list of common vulnerabilities, for example the OWASP Top 10, gives the review structure and makes it comparable.

  4. What should a finding look like?

    Location, severity, explanation and fix. Without this, you get running text in which you have to find the spot yourself.

  5. What must the AI not do?

    Run nothing, make nothing up, suggest nothing against other people's systems. A limit in the prompt is more reliable than hoping it goes without saying.

What does that look like as a finished prompt?

Example

This is how the conversation could go. The example is written by hand, following the rules Finn uses for his questions, and doesn't come from a real conversation.

The idea
I want to have the web app I built myself checked for security holes.
The question
What is the app built with? What's in scope: just the code, the sign-in, the file upload? What should a finding look like? Do you have a standard, such as a well-known list of common vulnerabilities?
The reply
Node.js with Express and PostgreSQL. Check sign-in, sessions and file upload. Findings with severity and fix, against the OWASP Top 10.

The finished prompt

You are an experienced application security reviewer. Review the source code of my own web application for security vulnerabilities.

System: Node.js with Express and PostgreSQL. I'll paste the code below: [code or file excerpts].
Scope: sign-in, session management and file upload. Out of scope: hosting, network and dependencies.
Standard: the OWASP Top 10. Only report findings you can back up in the pasted code, and give the location.
Result: a list ordered by severity (high, medium, low). For each finding: location, what is wrong, how it could be exploited (one sentence) and how I fix it.
Limits: Do not run anything. Do not make up vulnerabilities; if the code doesn't show enough on a point, write "cannot be checked with this code".

When don't you need this?

An AI review doesn't replace testing by professionals or an audit that someone requires of you. It's a second opinion on code you pasted in yourself.

For a single question about one function, such as whether a database query takes input without checking it, the question and the code straight in the AI are enough.