GitHub Copilot

Verified against GitHub Copilot Autofix · 2026-06-20

Turn a Copilot Autofix suggestion into a verified fix, not a rubber stamp

A review prompt for a GitHub code-scanning alert with a Copilot Autofix suggestion that forces you to verify the fix actually closes the vulnerability, not just silences the scanner.

GitHub Copilot AutofixGitHub code scanning (CodeQL)

The prompt

Ready to copy — highlighted parts are example details you can swap.

A GitHub code scanning alert flagged SQL injection: user-provided value flows into a database query without sanitization (rule js/sql-injection) and Copilot Autofix suggested a fix. Do not accept the suggestion yet — verify it first.

AUTOFIX SUGGESTION
Wraps the raw value in the database driver's escape() helper before interpolating it into the query string.

AFFECTED CODE
The searchUsers(query) function in lib/db/users.ts, pasted below, which builds a raw SQL string from the query parameter.

Answer, in order:
1. State the exact exploit this alert is warning about — a concrete input or request an attacker could send, not a restatement of the alert's category name.
2. Confirm whether the suggested fix actually closes that specific exploit path, or only makes the pattern the scanner matches on disappear, for example by suppressing the symptom rather than validating the input.
3. Name any other place in this file or nearby files with the same vulnerable pattern that this specific alert did not flag, since a vulnerable pattern that appears once is usually copy-pasted elsewhere too.
4. State what a passing test for this fix would need to assert — that the malicious input from step 1 is now rejected or safely handled, not just that the code still compiles.

Only recommend accepting the Autofix suggestion if your answer to question 2 is yes.
Customize the highlighted detailsoptional — the prompt above already works

Why this works

GitHub's Copilot Autofix generates a suggested code change directly on a code-scanning alert, and its one-click accept path is deliberately fast, which is also its risk — a fast accept can silence the specific pattern CodeQL's query matched without closing the actual exploit path, especially for alerts where several different code shapes trigger the same finding and the generated fix addresses only the literal flagged line. Requiring the exploit to be stated as a concrete input, not the alert's category name such as SQL injection, forces a check against the real attack rather than the label attached to it. Asking whether the fix closes that path or only removes the pattern the scanner keys on directly targets Autofix's known failure mode of pattern-level rather than vulnerability-level remediation — an escape() call added in the wrong place can satisfy the scanner while leaving a second, differently-shaped injection point untouched. The instruction to search nearby code for the same unflagged pattern matters because vulnerable code is rarely written once — a copy-pasted query-building helper tends to exist at more than one call site, and static analysis does not always catch every one, particularly through indirection. Gating acceptance on a yes answer to the verification question turns Autofix suggested it into a decision a human actually made, rather than a suggestion that shipped because it was easier to accept than to check.

What you get back

1. Exploit: a query parameter like ' OR '1'='1 sent to the search endpoint would return every user row instead of a filtered match, or worse with a stacked query depending on the driver. 2. The Autofix escape() call does close this specific path — confirmed by tracing that the escaped value can no longer terminate the quoted string. 3. buildOrderClause() in the same file interpolates a sort-column parameter into the query with no escaping at all — not flagged by this alert, but the same class of risk. 4. Test should assert that searchUsers("' OR '1'='1") returns zero or an error, not the full user table.

Verified against

GitHub Copilot Autofix GA, 2026 · 2026-06-20

Changelog

  • 2026-06-20 Initial publish, verified against GitHub Copilot Autofix GA.

Need this built into your business?

If a prompt isn't enough — custom software, built and maintained for you — that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All GitHub Copilot prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY