Is GitHub Copilot Code Secure? What the Research Actually Found
Is code suggested by GitHub Copilot secure?
Often, but not reliably. NYU researchers prompted Copilot with 89 security-relevant scenarios and found roughly 40% of the 1,689 programs it produced contained vulnerabilities. Separately, Stanford found developers using an AI assistant wrote less secure code than those without one — and were more confident it was secure. That confidence gap is the more dangerous finding.
GitHub Copilot is an inline code-completion assistant that suggests as you type. Copilot completes at the cursor inside existing files, so its output arrives in small increments that are individually easy to accept without much thought.
What tends to go wrong in GitHub Copilot code
These are patterns we look for in code produced this way — not flaws in GitHub Copilot itself. Each names the check that finds it.
Insecure completions in security-relevant contexts
The NYU study prompted Copilot with scenarios drawn from MITRE's Top 25 weakness list and found roughly 40% of the resulting programs vulnerable. The completions were not obviously wrong — they were plausible code that satisfied the prompt while missing the security property the situation required.
Detected by: SQL string concatenation
Confidence that outruns correctness
Stanford's user study found participants with an AI assistant wrote significantly less secure code and were simultaneously more likely to believe their code was secure. This is why Copilot-assisted code often gets less review rather than more: it feels finished.
Detected by: Unvalidated request input
Training-data patterns that are years out of date
Completions reflect patterns common in public code, and a great deal of public code demonstrates approaches that were acceptable when written and are not now. Deprecated crypto choices and superseded authentication patterns arrive looking idiomatic.
Detected by: Disabled HTTPS / insecure HTTP
Credentials completed from surrounding context
Where a file already contains a configuration block, Copilot will helpfully complete the next entry — including plausible-looking key assignments. A placeholder that reads like a real key is easy to leave in place and hard to spot in review.
Detected by: Hardcoded JWT or Bearer token
Auditing a GitHub Copilot project: the short list
Treat every completion in an auth, crypto or query path as a draft requiring deliberate review
Grep for string-built SQL and shell commands across files where completions were accepted
Verify that input validation exists server-side, not only in the form
Check crypto and hashing choices against current guidance rather than assuming a suggestion is current
Run a secrets scan over the full history before any repository becomes public
Scan your GitHub Copilot project
Every check named above runs automatically. Free on public repositories, no signup, results in under three minutes — with the file and line for each finding.
In NYU's study, roughly 40% of the 1,689 programs Copilot generated across 89 security-relevant scenarios contained vulnerabilities. That figure describes deliberately security-focused prompts rather than everyday coding, so it is not a rate for all Copilot output — but it does establish that security-sensitive completions need review.
Does Copilot make developers worse at security?
Stanford's study found participants with access to an AI assistant wrote significantly less secure code than those without, and were more likely to believe their code was secure. The productivity gain is real; so is the confidence gap, and the second one is what removes the review the first one makes necessary.
Should we stop using Copilot?
No. The evidence supports reviewing AI-assisted code more carefully, not abandoning the tooling. The practical response is to treat completions in security-relevant paths as drafts and to run automated checks over what was accepted, since those paths are where the measured failure rate concentrates.