Copilot Mistakes: Security, Licensing and Hallucinated APIs
Copilot mistakes involving secrets, unsafe SQL, licensing questions and invented APIs, with a practical review gate for each risk.
Learn the concept, work through an example, and check the result.
Core idea
A plausible suggestion can create a real vulnerability.
Test → inspect
Decide → commit
The direct answer
Treat a suggestion as an untrusted proposal.
Copilot mistakes can look plausible until the developer checks data flow and the installed API.
A generated snippet can contain an unsafe query, invent an API, reproduce an unsuitable pattern or encourage a dependency you cannot approve. The right response is a verification workflow: identify the claim, check it against the installed code and official documentation, test the behavior and follow repository security policy.
Course pricing follows the overview. GitHub’s responsible-use guidance and the OWASP Top 10 provide authoritative context for security review.
Course access
Choose your next step in GitHub Copilot.
Review the current course options and access details here.
Heycademy Courses · Coming Soon
GitHub Copilot & AI Coding Productivity
We’re preparing an interactive learning experience with practical exercises, skill assessments and personalized learning to help you build confidence and master new skills.
We’re putting the finishing touches on this course. Please check back for updates.
Topic in practice
Copilot mistakes in a real decision.
A query built by string concatenation needs a parameterized interface. A suggested method absent from the installed package needs documentation and a test before use.
As you work through the case, identify the next action, the evidence required and what remains uncertain. The GitHub documentation provides background for checking the decision.
Mistake 1
Keep secrets out of prompts and logs.
A proposed error handler prints the full request headers for debugging. That can expose authorization tokens. Replace the log with allowlisted diagnostic fields, test error paths and review log retention. If a real credential may have been exposed, follow the organization’s incident process and rotate or revoke it as directed.
Mistake 2
Check input at dangerous sinks.
const sql = "SELECT * FROM users WHERE name = '" + input + "'";This concatenation allows input to alter the query. Use the database driver’s parameterized query interface and test both normal and hostile input. Do not accept a claim that escaping by hand makes arbitrary SQL concatenation safe. Review the actual driver API for your installed version.
Keep building this skill
Turn the example into a skill you can use.
Return to the course options whenever you are ready.
Mistake 3
Verify plausible but nonexistent APIs.
An assistant proposes client.guaranteedSafeQuery(), but the method is absent from your installed package. Check the lockfile, versioned official documentation and type definitions; then run a small test. A confident explanation is not proof that a method exists.
Mistake 4
Review provenance and policy questions.
If a suggestion appears unusually similar to known code or adds a dependency, follow the repository’s license and attribution process. Check package metadata, permitted licenses and any applicable organization guidance. Do not infer that all generated output has a single legal status. GitHub documents product settings and responsible-use considerations; use current documentation for the specific feature.
Five-point review gate
Make the decision traceable.
| Question | Action |
|---|---|
| Secret or private data? | Remove, contain and follow policy. |
| Untrusted input at sink? | Use supported safe API and test. |
| API actually exists? | Check installed version and docs. |
| Dependency or license concern? | Review policy and provenance. |
| Diff explained and tested? | Record evidence before merge. |
The testing lesson turns these checks into a repeatable review.
Risk walkthrough
Trace data from input to output.
A support endpoint accepts a search term. A suggestion builds a SQL string from that term and logs the complete request on error. That creates two review questions: can the input alter the SQL statement, and could the log contain a token or personal information? The repair is to use the driver’s parameterized query interface, avoid logging sensitive headers and test both normal and adversarial input with safe fixtures.
Now inspect the dependency used for the query. Confirm its installed version and documented parameter syntax. If the assistant named an unknown helper, do not invent a wrapper around the claim merely to make the snippet compile. Record the source used to verify the API and the security checks run. These steps are practical review evidence, not a guarantee against every vulnerability.
FAQ
Questions about this skill.
Is AI-generated code automatically secure?
No. Apply the same security and review gates as other code.
Can I rely on a suggested API name?
Verify it against the installed version and official documentation.
What if a secret was pasted into a prompt?
Follow the organization’s incident process promptly.
Continue with the course
Build reliable AI-assisted coding skills.
Review the course options and choose your next learning step.