Security features GitHub offers around Copilot today
GitHub Copilot has two kinds of security features, and they answer different questions. The first kind controls what Copilot may read and what it may do in a repository. The second kind checks the code, either while it is written or after it reaches a pull request.
Controls on Copilot itself include content exclusion, the setting for suggestions that match public code and the policies an organisation sets. For the cloud agent, GitHub's page on risks and mitigations adds more: only users with write access can start it, it can push to a single branch, it cannot approve or merge a pull request, and its access to the internet is restricted. These limit what the tool can reach. They do not judge whether the generated code is safe.
Checks of the code come in several layers. This is how GitHub's own pages describe them:
| Feature | When it runs | What it does |
|---|---|---|
| Filters on suggestions | As suggestions appear | Filters block insecure code patterns or notify the user about them. They target the most common vulnerable patterns, including hardcoded credentials, SQL injections and path injections (questions section of the Copilot page). |
| Copilot code review | On pull requests, when requested or automatically | Reviews a pull request, identifies issues and suggests fixes you can apply. Not included in the free plan (code review documentation). |
| Checks in the cloud agent | When the agent writes code | The agent analyses its new code with CodeQL, secret scanning and a check of new dependencies against GitHub's advisory database, and tries to fix what it finds (risks and mitigations). |
| Copilot Autofix | On code scanning alerts | Generates fix suggestions for CodeQL alerts on pull requests and on the default branch. It does not require a Copilot subscription (Autofix documentation). |
The last row depends on something else. Autofix proposes fixes for alerts, so code scanning has to be running and producing alerts first.
Code review by Copilot: what it checks
According to the code review documentation, Copilot reviews code in any language. Its quickest review level gives targeted feedback on common issues such as bugs, security vulnerabilities and style inconsistencies. The review is a general code review that includes security. It is not described as a security scan.
GitHub's application card for Copilot agents explains how it works. The code changes are combined with other context, including the title and body of the pull request and any custom instructions, and that prompt is sent to a large language model.
The documentation also states where the review stops:
- It runs only when asked, by default. Copilot reviews a pull request when it is assigned as a reviewer. You can turn on automatic review for your own pull requests in your settings, and a repository administrator or organisation owner can make the review automatic with a ruleset (configuration steps).
- It does not count as an approval, by default. Copilot's reviews do not count toward the required approvals of a pull request unless that is enabled in settings.
- Some files are skipped. Dependency management files such as
package.jsonandGemfile.lock, log files and SVG files are not reviewed. A vulnerable version pinned in a lockfile is outside this review. - Excluded content is skipped. Files covered by content exclusion are not reviewed (content exclusion documentation).
You can request a review by hand or let a ruleset do it. With a ruleset, the options look like this:
[x] Automatically request Copilot code review
[x] Review new pushes
[ ] Review draft pull requestsWhat a model-based review can and cannot be relied on for
A model reads code the way a person does. That makes it useful for questions that need context: does this change do what the pull request says, does this function trust a value it should not, is the fix consistent with the code around it. It also explains what it found in plain language, which a rule identifier does not.
The same property sets the limits. GitHub's documentation is direct about them:
- It can miss issues. The application card says Copilot may not identify all of the problems in code, especially where changes are large or complex. The code review documentation says Copilot is not certain to spot every problem in a pull request.
- It can report issues that are not there. The same card says the review may highlight problems that do not exist, and that its comments should be carefully reviewed.
- Its fixes need checking. The Autofix documentation says the feature uses a generative model that is non-deterministic, and that a suggested fix may fail to remediate the vulnerability or may introduce a new one. It also says the system does not know which dependency versions are supported or secure.
- It does not replace a person. GitHub's stated best practice is to use Copilot code review to supplement human reviews, not to replace them.
The filters on suggestions have a stated scope too. The questions section of the Copilot page says they target the most common vulnerable patterns, and that public code may contain insecure patterns which Copilot can reproduce. Its advice is to keep using testing, code scanning and security testing on code that Copilot suggests.
There is also a general point that applies to any author and any reviewer. A reviewer built on the same kind of model as the author tends to share the author's blind spots. A check that works in a different way reduces that risk.
So rely on a model-based review to find problems early and to explain them. Do not use an empty review as proof that a release is clean, and do not use it as the control an auditor will ask you to repeat.
Where an independent scanner fits
GitHub's own design already pairs the model with rule-based tools. The cloud agent runs CodeQL, secret scanning and a dependency check on the code it writes, and Autofix starts from a code scanning alert, not from the model's opinion. The lesson is the same for any team: let the model write and explain, and let a fixed set of rules decide whether the result passes.
A rule-based scanner adds three things a model review does not:
- Repeatability. The same rule on the same code gives the same result, so a finding that disappears has been fixed, not overlooked.
- Systematic coverage. Static application security testing (SAST) traces data flows through the whole project against a fixed rule set, and software composition analysis checks every dependency against known vulnerabilities. That includes the dependency files Copilot code review skips.
- A gate and a record. A scan can fail a pipeline, and its report is evidence for a team lead or an auditor.
An independent scanner is a second opinion, not a replacement for the checks GitHub runs. It uses its own rules, it is not tied to one code host or one coding assistant, and it gives the same answer whichever agent wrote the code.
The scanner does not have to wait for CI. An agent that can call an API can keep the scan inside its own loop: write, scan, read the findings, fix, scan again. With DerScanner the agent reads the API description at docs.derscanner.com and connects by itself, which takes three minutes. The steps are on the page about connecting a coding agent to DerScanner. DerScanner runs in the cloud, on-premise or in a network with no internet access.
One detail matters for Copilot's cloud agent. GitHub restricts its access to the internet, and its documentation says cloud sandboxes honour the firewall allowlists of the repository and the organisation. Check that the address of your scanner is allowed before you ask the agent to call it.
Checklist: Copilot and repository settings
These settings come from the GitHub pages linked in each item.
- Exclude sensitive files. Content exclusion makes Copilot ignore the files you list. It is documented for the Business and Enterprise plans and can be set by repository administrators, organisation owners and enterprise owners. The documentation states that it is not a filesystem security boundary and not a substitute for other access controls, so keep secrets out of the repository as well.
- Decide on suggestions that match public code. With the setting on block, most Copilot products check a suggestion against public code on GitHub and hide it when it matches (policy documentation). Members with a seat from an organisation inherit the setting. The application card notes that the cloud agent may still generate matching code with the setting on block. This is a licensing control, not a vulnerability check.
- Set organisation policies. The policies section of the organisation's Copilot settings controls privacy and the availability of features. A policy fixed at enterprise level cannot be overridden by the organisation (organisation policies).
- Make code review automatic. Add a branch ruleset that requests a Copilot review on every pull request, and choose whether it reviews new pushes (configuration steps).
- Leave the agent's checks on. The cloud agent's CodeQL, secret scanning and dependency checks can be disabled one by one. According to the risks and mitigations page, they need no extra security licence, so there is little reason to turn them off.
- Write the rules down. Copilot code review reads custom instructions from the repository. Put the security rules of the project there.
# Security rules for this repo
- Every route under /admin checks the admin role before any database read.
- Build SQL with parameters, never with string formatting.
- Read credentials from the secret manager, never from source files.
- After each change, run the security scan, fix the findings and scan again.Checklist: review habits
- Read the diff yourself for anything that touches authentication, authorization, payments or personal data. GitHub's documentation says Copilot can produce code that contains security vulnerabilities, and tells you to review and test the output before using it in production.
- Treat a pull request from the cloud agent like one from a new contributor. GitHub requires a human to review and merge it, and by default workflows do not run until its code has been reviewed.
- Check every suggested fix before you accept it. The documentation for Autofix asks you to confirm that the change fixes the vulnerability, that CI still passes and that any added or updated dependency is secure.
- Give the agent an independent scanner and one standing instruction: scan after each change, fix the findings, scan again.
- Keep a SAST and dependency scan in CI as the gate. Do not let the model that wrote the code be its sole reviewer.
- When a finding is suppressed, record who decided and why. A person makes that call, not the agent.
If your team also uses Anthropic's agent, see the guide to the Claude Code security review. For the risks this checklist is meant to catch, see vibe coding security risks. For a full team process, from the agent loop to release, see how to secure AI-generated code.
