What Copilot does and where the trust boundary is
Copilot offers inline suggestions, chat, and agents that can make multi-file changes. GitHub's documentation describes the Copilot cloud agent as an asynchronous agent that can create branches, write code and open pull requests in response to assigned issues. Which of these you use decides how much code arrives without you typing it, and therefore how much you need to read.
Copilot does not change your app's trust boundary. Code that ships to the browser is public, and access control has to live in server-side code and database rules. What Copilot changes is the speed at which unreviewed code can reach your main branch. The boundary to guard is the merge.
GitHub's responsible use documentation is explicit. It says suggestions can look valid without being correct, that code may not always be secure, and that you should always review suggestions before accepting them and validate them afterwards. For the cloud agent it says you are ultimately responsible for reviewing and validating what it generates.
The review checklist
| Area | What to verify | How to test on your own project | Pass condition |
|---|---|---|---|
| Agent pull requests | Every pull request from the cloud agent is read by a person before merge. | Open recent merged pull requests authored by Copilot and check for a human review. | Each one has a reviewer who read the diff, with extra care on auth, payments and data access. |
| Workflow runs | CI for agent pull requests runs only after someone looks at the changes. | Open an agent pull request and check whether workflows waited for approval. | Workflow files changed by the agent were read before any run was approved. |
| Push protection | Pushes containing known secret formats are blocked. | Check your account's push protection setting and the repository's secret scanning settings. | Push protection is on for your account and, where your plan allows, for the repository. |
| Content exclusion | Files Copilot should never read are excluded, and you know the limits. | If your plan supports it, open the repository's Copilot settings and read the exclusion list. | Env files and credential paths are listed, and the team knows agent modes may not honour exclusions. |
| Secrets in the repository | No secret sits in source, config or history. | Search the working tree and history with the commands below. | No hits, or every hit has been rotated. |
| Authorisation in generated code | Each endpoint checks the caller and the ownership of the record. | Call each endpoint with no session, then as a second test user with the first user's record id. | Anonymous calls are refused and the second user gets nothing of the first user's. |
| Input handling | Server code validates input and uses parameterised queries. | Search for string-built SQL and send unexpected values with curl. | No query is built by joining user input into a string, and bad input is rejected. |
| Dependencies | Suggested packages exist, are maintained and have no known vulnerabilities. | Read the lockfile diff, check each new package on its registry and run an audit. | Every new package is recognised and the audit shows nothing unaddressed. |
Commands to run on your own repository
These searches look for secret-shaped strings and risky patterns in files and in git history. A completion can copy a key from an open file into another file, so search the whole tree and not only the files you remember editing. Adjust the patterns and the audit command to your stack.
git ls-files | grep -E "\.env|\.pem$|credentials"
grep -rnE "sk_live_|AKIA|BEGIN PRIVATE KEY|service_role" --exclude-dir=node_modules --exclude-dir=.git .
git log --all -p -S"sk_live_" | head -50
grep -rnE "query\(.*\+|query\(`.*\$\{" --include="*.ts" --include="*.js" src
npm auditWhat the cloud agent's safeguards cover
GitHub documents several built-in controls for the cloud agent. It only has access to the repository where it is creating a pull request. It can push only to a single branch, so it cannot push directly to your default branch. Actions workflows triggered by its pull requests require approval from a user with write access before they run. A firewall is enabled by default to limit data leaving its environment. During generation it analyses new code using CodeQL, secret scanning and dependency analysis and attempts to resolve issues.
Those controls limit what the agent can do to your repository. They do not decide whether the feature it built checks permissions correctly. A pull request can pass automated scanning and still return another customer's invoice to anyone who changes an id in the URL. That class of bug is found by reading the diff and by the two-account test.
Turn on push protection
GitHub's documentation describes push protection as blocking pushes that contain secrets before they reach the repository. It says push protection for users is enabled by default and stops you from pushing secrets to public repositories, while push protection for repositories requires GitHub Secret Protection and is disabled by default until an administrator enables it. Confirm both settings on your own account and repository, because a private repository is not covered by the user-level setting.
Push protection detects supported secret formats. It will not notice a hard-coded admin password or a home-made token, so it supports the manual searches above and does not replace them.
Common mistakes with this workflow
- Accepting a long suggestion because the first lines looked right.
- Approving an agent pull request on the strength of green checks without reading the diff.
- Approving workflow runs on a pull request that edits the workflow files, without reading those edits first.
- Keeping a real .env file open in the editor while working, then finding its values in a suggestion elsewhere.
- Installing a suggested package without checking that it exists under that exact name and is maintained.
- Letting chat fix a permissions error by removing the permission check.
- Assuming content exclusion applies everywhere. GitHub's docs list modes where it does not.
Keep it working
Require a human review on the default branch, repeat the searches before each release and keep two test accounts for regression checks. Pass condition: no secret in the tree or its history, every agent pull request has a human reviewer, and the running app refuses anonymous and cross-user requests.
Frequently asked questions
Is code written by GitHub Copilot secure?
Not automatically. GitHub's responsible use documentation says that suggested code may not always be secure and that you should review suggestions before accepting them and validate them afterwards. Treat Copilot output like code from a new contributor and review it to the same standard.
Can GitHub Copilot leak my secrets?
It can reproduce values from files it is given as context, so a key in an open file can end up suggested elsewhere. Keep real secrets out of the repository, use content exclusion where your plan supports it, turn on push protection, and rotate any key that has appeared in a file or commit.
Can the Copilot cloud agent push to my main branch?
GitHub's documentation says it cannot push directly to your default branch. It pushes to a single branch for its pull request. Merging that pull request is a human decision, which is why the review step matters.
Does Copilot's security scanning replace code review?
No. GitHub says the cloud agent analyses new code with CodeQL, secret scanning and dependency analysis, and also says you are ultimately responsible for reviewing and validating its output. Automated analysis does not know your business rules about who may see which record.
Does content exclusion stop Copilot reading my .env file?
Only partly. GitHub's documentation says content exclusion is not supported in Edit and Agent modes of Copilot Chat in editors, and is limited to certain plans. Confirm the current support table and do not rely on exclusion as the only protection for secrets.
Sources
- 1.GitHub docs: Responsible use of Copilot inline suggestions
- 2.GitHub docs: Application card for GitHub Copilot agents
- 3.GitHub docs: Content exclusion for GitHub Copilot
- 4.GitHub docs: Excluding content from GitHub Copilot
- 5.GitHub docs: Push protection
- 6.OWASP Cheat Sheet: Insecure Direct Object Reference Prevention
- 7.OWASP Top 10