StackHawk + GitHub Copilot: Secure Code from The Start

A young man with short hair smiles widely. The image is in black and white and framed by a light blue hexagon, representing a focus on Shift-Left Security in CI/CD practices. Matt Tanner   |   Apr 17, 2026

Two dark squares on a green gradient background; the left square features a stylized bird logo, and the right square shows the GitHub Copilot logo with text, connected by a thin white line.

Updated November 2026

This GitHub Copilot security guide shows how to add runtime security checks to your development workflow with StackHawk's dynamic application security testing (DAST).

For setup steps, go to Getting Started with StackHawk and GitHub Copilot below. The walkthrough covers installing StackHawk's agent skills, authenticating the scanner, and asking Copilot to scan, fix, and verify your running application.

What is GitHub Copilot and How Does It Generate Code?

GitHub Copilot is an AI-powered coding assistant developed by GitHub and backed by models from OpenAI, Anthropic, and others. What started as an inline autocomplete tool has evolved into an agentic development platform that lives inside your editor and across the GitHub platform itself. Microsoft reported 50 million Copilot users in its July 2026 earnings call.

How GitHub Copilot Works

GitHub Copilot supports multiple large language models. Paid plans let you choose from models by OpenAI, Anthropic, Google, and others, while Copilot Free uses auto model selection. Its main capabilities are:

Agent Mode (In-Editor): Launched in February 2025, Copilot's agent mode acts as an autonomous peer programmer directly within your IDE. Rather than just suggesting code completions, it can analyze your codebase, read relevant files, propose multi-file edits, and run terminal commands in a self-correcting loop. It monitors compile errors, lint output, and test results, automatically iterating until the task is resolved. Agent mode is available in VS Code, Visual Studio, JetBrains, Eclipse, and Xcode.

Copilot Cloud Agent (Background/Cloud): Announced at Microsoft Build 2025 as the Copilot coding agent and now generally available, the cloud agent is a separate, GitHub-hosted autonomous developer that works entirely in the background. You assign it a GitHub issue (or delegate a task from Copilot Chat), and it spins up an ephemeral development environment powered by GitHub Actions. From there, it explores your code, implements changes, runs tests and linters, pushes commits to a draft pull request, and requests your review when done. If your repository requires pull request approvals, approval from the developer who triggered the agent won't count toward the required number, so at least one other reviewer must sign off before merging.

Planning Mode: Added in late 2025, planning mode lets you review and approve a transparent, traceable plan before the agent starts making changes. This makes agentic workflows more predictable and reviewable, especially for large or collaborative tasks.

Codebase Indexing and AGENTS.md: Copilot indexes your repository to understand project structure, dependencies, and naming conventions. You can further guide its behavior with AGENTS.md files that contain project-specific instructions: coding standards, architectural rules, and preferred patterns. Copilot also loads agent skills, folders of instructions and scripts for specialized tasks, from .github/skills/ in your repository, which is how tools like StackHawk teach it to run security scans.

IDE-Native Integration: Copilot lives directly inside VS Code, JetBrains, Visual Studio, and other editors, integrating with your existing workflow. It also connects to GitHub's broader platform, including Issues, Pull Requests, Actions, and the GitHub CLI.

MCP and Extensibility: With Model Context Protocol (MCP) support, Copilot can interface with external tools and services through a growing ecosystem of MCP servers discoverable via the GitHub MCP Registry. This extends Copilot's capabilities to databases, monitoring platforms, security scanners, and more, all without leaving your editor.

The Pros and Cons of AI-Assisted Development

Generated code can contain security vulnerabilities even when it compiles and appears to meet the requested behavior.

Optimization for Functionality Over Security: AI models are trained to generate working code that solves the stated problem. When developers ask for "quick" or "minimal" solutions, security considerations often take a backseat to getting something functional out the door.

Pattern Replication Without Context: AI learns from vast datasets of existing code, including code that contains security vulnerabilities. Without specific security guidance, Copilot can replicate insecure patterns found in its training data. Review generated changes for inherited insecure patterns; the repository context does not establish that a suggestion is safe.

Lack of Security Awareness: Generated code needs review and testing; a plausible suggestion may be incorrect or insecure.

Implicit Trust in Generated Code: The sophistication of AI-generated code can create a false sense of security. A peer-reviewed 2021 study of Copilot's early technical preview found that roughly 40% of the programs it generated were vulnerable, across scenarios built around high-risk CWE categories from MITRE's Top 25 list. Copilot's models have changed a lot since, so read that as a warning sign, not a current rate. GitHub has added an AI-based vulnerability prevention system targeting common patterns like hardcoded credentials (CWE-798) and SQL injection (CWE-89), but coverage is not yet across the board.

Supply Chain Attack Vectors: Copilot's reliance on configuration files introduces new attack surfaces. In March 2025, Pillar Security disclosed the "Rules File Backdoor" attack, demonstrating how hidden Unicode characters in rule and configuration files can inject malicious instructions that manipulate Copilot's code generation. The result: vulnerable output that bypasses typical code reviews. Because these configuration files are shared across projects and survive forking, a single compromised file can affect downstream dependencies at scale. A separate flaw, CVE-2025-53773, was a command injection vulnerability in GitHub Copilot and Visual Studio that allowed an unauthorized attacker to execute code locally, a reminder that the agent's own tooling is attack surface too.

Why AI-Generated Code Creates New Security Challenges

A generated endpoint can return the expected result while omitting an access check or exposing details in an error response. Functional behavior alone does not show that the implementation is secure. State security requirements explicitly, then test whether the generated implementation satisfies them.

Common Security Issues in AI-Generated Code

Check generated endpoints and configuration for these failure modes:

Missing Input Validation: Check that input is handled safely at database queries, HTML output, and other sensitive operations. The OWASP Top 10 consistently ranks injection as one of the most critical web application security risks.

Weak Authentication Implementation: Review authentication and session handling, then test protected routes with valid and invalid credentials.

Inadequate Error Handling: Check error responses for information disclosure. Stack traces, database errors, and internal paths get leaked to potential attackers.

Insecure Defaults: Review CORS settings, debug modes, and permissions against the application's intended access policy.

Omitted Security Headers: Check web applications for security headers like Content-Security-Policy, X-Frame-Options, Strict-Transport-Security, and others that form the baseline of web application security.

Secret Leakage: Review generated code for hardcoded credentials, default passwords, and placeholder values before accepting it. Keep real secrets in your secrets manager or runtime configuration, and run secret scanning before changes reach version control. A plausible-looking key or password in a suggestion should never be treated as a safe production credential.

Include security requirements in prompts and verify them through code review and runtime tests. These checks also apply to code written by people.

What Copilot's Built-In Security Controls Cover (and Don't)

GitHub ships several controls that reduce risky output before it reaches your repo. The GitHub Copilot security filter came first: in 2023, GitHub added an AI-based vulnerability prevention system that blocks insecure coding patterns in real time, targeting hardcoded credentials, SQL injection, and path injection. Content and code safety filters also check the prompts and responses the agent handles. On top of that:

  • Content filtering: scans prompts and responses and blocks harmful or insecure content before you see it.
  • Public code matching: detects suggestions that match public code and, depending on your settings, blocks them or shows the source repository and license. The cloud agent and Copilot CLI can still return matches when Block is set. The cloud agent lists these matches in its session logs.
  • Content exclusion: on Copilot Business and Enterprise, admins can make Copilot ignore specific files. It isn't supported in Edit and Agent modes of Copilot Chat in VS Code and other editors yet, so don't rely on it for agent workflows.
  • Cloud agent checks: by default, the cloud agent runs CodeQL, secret scanning, and a dependency check against the GitHub Advisory Database on its own changes, and gets a second opinion from Copilot code review.
  • Copilot Autofix: with GitHub Code Security, part of GitHub Advanced Security, you get generated fixes for code scanning alerts.

Every one of these works on code, prompts, or files, and none of them sends a request to your running app. A broken access check, a missing server-set header, or an auth flow that fails under real traffic can still get through. Inline suggestions have the context of the code being written, which can leave broader design and architecture problems outside their view.

The "Security by Afterthought" Problem

Review the following workflow risks:

  • Developers focus on getting working code quickly
  • AI responds to immediate functional requirements rather than holistic security needs
  • Security requirements are often implicit rather than explicit in development requests
  • The rapid pace of AI-powered development can bypass traditional security review processes
  • Copilot's cloud agent can autonomously implement changes across multiple files, push commits, and open PRs, compounding security issues before a human ever reviews the code

Add security checks before merging agent-generated changes, while the implementation is still available for review.

Why DAST is Critical for AI-Generated Code

Dynamic Application Security Testing (DAST) tests the behavior of AI-generated code in a running application. Unlike static analysis tools that examine source code at rest, DAST tests your running application to identify vulnerabilities that only manifest during execution. For teams building with AI tools, this approach fills gaps that other testing methods can't.

The Unique Value of DAST for AI Code

Runtime Vulnerability Detection: DAST identifies security issues that emerge when AI-generated code interacts with real data, user inputs, and system resources. These are scenarios that static analysis simply cannot fully replicate.

Black-Box Testing Approach: DAST doesn't need to understand the code structure or how the AI generated it. It evaluates security from an attacker's perspective, testing how the application actually behaves under malicious conditions.

API-First Testing: Modern applications are API-driven, and generated endpoints need the same authorization and input-handling tests as other code. DAST tools like StackHawk are purpose-built to test APIs, so you can find exploitable issues in AI-generated endpoints before they ship.

Validation of Security Controls: DAST can verify whether the security measures the AI implemented, like authentication, input validation, and rate limiting, actually work as intended in the running application.

Developer Workflow Integration: DAST tools can integrate directly into the same IDE and CI/CD workflows that Copilot uses, providing findings within the development workflow.

Why AI-Generated Code Needs More Than Code Review

Reviewing a generated diff does not exercise the application with real requests. Runtime tests add that check alongside code review and static analysis, including interactions with authentication and connected services. Build those checks into the workflow before merge:

Speed of Development: Run security checks before merging generated changes, so findings are available during review.

Volume of Generated Code: Automate repeatable tests and review the resulting findings alongside the generated diff.

Subtle Logic Flaws: AI-generated code may contain subtle security logic flaws that are difficult to catch in code review but become apparent when testing the running application.

Integration Vulnerabilities: Security issues often emerge at the integration points between AI-generated components and existing systems, exactly the kind of thing DAST is designed to catch.

Autonomous Workflow Validation: With the Copilot cloud agent able to autonomously implement features, push commits, and open pull requests via GitHub Actions, security testing needs to happen automatically as part of that pipeline. The agent's PRs still need human review before merging; DAST adds an automated check of the running application alongside that review.

How StackHawk Fits into AI Development Workflows

StackHawk tests running applications from local development and CI/CD workflows, including those using AI coding tools.

Built for Developers, Not Security Teams

StackHawk is designed for the developers writing and shipping the code. It provides findings in terms developers can act on: which endpoint is vulnerable, what the attack vector is, and how to reproduce it.

API Testing Across Protocols

StackHawk tests REST, SOAP, GraphQL, and gRPC APIs, exactly the types of services AI tools generate. When Copilot scaffolds a new API endpoint, StackHawk can test it against known attack patterns before it ever reaches production.

CI/CD Pipeline Integration

StackHawk runs inside your CI/CD pipelines, so security tests can run on every pull request, including the ones the Copilot cloud agent opens. This is especially important for teams using the Copilot cloud agent, where autonomous commits and PRs can introduce vulnerabilities without a developer actively writing the code. One catch: GitHub Actions workflows don't run on the agent's pull requests until someone with write access clicks Approve and run workflows, unless you configure the agent to run them without approval. The workflow also needs the app running so HawkScan has something to test.

Feedback During Development, Not After Deployment

StackHawk provides feedback during development so you can catch and fix AI-generated vulnerabilities before they ever reach production.

CLI-First Design

StackHawk's CLI-first approach fits naturally alongside GitHub Copilot's IDE-native workflow. You can trigger a security scan from the same terminal where you're running your dev server, making security testing part of the development loop rather than a separate process.

Agent Skills for Copilot

StackHawk also ships agent skills that teach Copilot to run DAST itself. One install of the wingman plugin adds four skills:

  • HawkScan: configures, runs, and interprets scans, then fixes and verifies.
  • StackHawk API: pulls findings, scan history, and triage status from the platform.
  • Data Seed: seeds test data so authenticated scans reach real application paths.
  • Optimize: tunes the scan setup (tech flags, scan policy, stackhawk.yml) for your codebase.

With the skills installed, you can ask Copilot to "scan my app running on 127.0.0.1:8767." The agent generates a stackhawk.yml, runs HawkScan against the running app, reads the findings, fixes them in your codebase, and rescans to confirm the fix held. That's the find, fix, verify loop running inside Copilot, all without leaving your editor, and scan requests to the localhost target stay on your machine. Findings and application profiles go to the StackHawk platform, not your source code.

Getting Started with StackHawk and GitHub Copilot

To start testing applications built with AI-powered workflows, you'll need a StackHawk account. If you're using GitHub Copilot or another coding agent, the Wingman plan is $10 per user per month with unlimited apps and 50 scans per user per month. It starts with a 14-day free trial, no credit card required.

StackHawk Agent Skills in Copilot

With StackHawk's agent skills, Copilot configures the scan, runs it against your running app, proposes fixes, and rescans to verify them. Set up the Copilot plugin, authenticate the scanner, and verify that the skills are available before your first scan.

Step 1: Install the Wingman Plugin

In a terminal, add StackHawk's plugin marketplace to Copilot and install the wingman plugin:

copilot plugin marketplace add stackhawk/agent-skills-marketplace
copilot plugin install wingman@stackhawk

Wingman bundles the HawkScan, StackHawk API, Data Seed, and Optimize skills under ~/.copilot/installed-plugins/. In our VS Code session, the CLI install succeeded but the four skills were not all loaded in the workspace. We copied the four directories from ~/.copilot/installed-plugins/stackhawk/wingman/copilot-skills/ into the demo’s .github/skills/ directory, then verified them in Copilot. This uses the official skills without changing existing plugins.

Step 2: Install the hawk CLI and Sign In

The skills require hawk CLI v6.0.0 or later, a self-contained binary with no separate Java install. On macOS:

brew tap stackhawk/cli && brew trust stackhawk/cli && brew install hawk

On Linux or Windows, use the binary or MSI from the StackHawk downloads page. If the CLI already has valid access, verify it with hawk op status and reuse it, as we did here. For a new setup, authenticate with:

hawk init --browser

This new-setup command opens a browser approval flow and provisions an API key. Our walkthrough reused existing CLI authentication, so we did not create a key or repeat that flow. Never include keys or authentication tokens in screenshots or prompts.

Copilot’s setup check confirms that the CLI, Wingman skills, and existing authentication are ready for the scan.

Copilot setup check confirming the hawk CLI, the Wingman skills and existing StackHawk authentication are ready

Step 3: Verify the Skills Are Available

In our VS Code version, open Copilot’s Open Customizations menu, then Skills (the documentation calls this Configure Skills). Confirm that hawkscan, stackhawk-api, stackhawk-data-seed and stackhawk-optimize are loaded. You can also ask Copilot directly:

What StackHawk skills do you have?

The answer should mention the StackHawk skills. Confirm that the agent actually reads the HawkScan skill when it starts the task.

The workspace’s Skills view shows all four official StackHawk skills loaded and available to Copilot.

VS Code Copilot Skills view listing the hawkscan, stackhawk-api, stackhawk-data-seed and stackhawk-optimize skills

Step 4: Start Securing Your Code

Start your app and switch Copilot Chat to Agent mode. In the prompt below, replace the local URL with your test app’s address and port. Ask Copilot to check that the scan reaches valid test records before changing any code:

Use the StackHawk skills to scan my isolated app at http://127.0.0.1:8767. Explain the setup, check that seeded API examples work, and show the findings before changing code.

Our isolated demo used Express and an in-memory SQLite database. Copilot read the HawkScan skill, generated stackhawk.yml and checked the running API. Its first scan missed SQL injection because generated IDs did not match the seeded records. After configuring valid GET examples, a fresh baseline found High-severity SQL injection at GET /users/3-2, four Medium CSP findings and one Low error-disclosure finding. Check coverage before treating a scan result as meaningful.

Copilot summarizes the baseline findings before making changes. The PASS label reflects the configured threshold, not an absence of findings.

Copilot summarizing HawkScan baseline findings, including a high-severity SQL injection at /users/3-2

Ask Copilot to fix the reported issues and add regression tests. Review the proposed changes before accepting them, including response and error handling.

Copilot’s changes in server.js replace SQL string concatenation with a parameterized query and validate the user ID before the lookup. Review the diff to see how the input is handled before it reaches the database.

Git diff in server.js replacing SQL string concatenation with a parameterized query and user ID validation

The implemented fix passes all eight regression tests, covering normal requests and malicious input. Copilot’s summary brings the changes and test results together.

Copilot summary of the implemented fixes with all eight regression tests passing

With the fixed app running, verification uses hawk rescan for the baseline’s alerted tests, followed by a fresh hawk scan with the same policy, API operations, and valid examples.

The alerted-test rescan returns zero findings. Its coverage is limited to the baseline’s alerted tests, so it does not replace a complete fresh scan.

Copilot running hawk rescan against the baseline scan, which completes with zero findings

Keep the target and scan policy the same when you verify the fix, so you are comparing the same coverage.

StackHawk scan details for the fresh verification scan, showing the Optimize trial policy and HawkScan 6.4.0

The fresh scan also reports zero findings, with successful responses for all four API operations. It recorded one connection failure, no timeouts, and no HTTP 5xx responses.

Copilot running a fresh hawk scan that reports no findings across all four API operations

Review coverage and scan health as well as the finding count. Zero findings means the scan did not report a problem in the tested inputs and paths, not that every input or vulnerability was tested. This example used HawkScan 6.4.0 and Wingman 2.7.0.

Step 5: Roll It Out to Your Team

For a team-wide rollout, commit the StackHawk skills to .github/skills/ in your repos so everyone who opens the project in Copilot gets the same setup. If your team keeps skills somewhere else, add that directory with the chat.agentSkillsLocations setting in VS Code. To pick up new releases later, run copilot plugin marketplace update and then copilot plugin update wingman@stackhawk.

Want help getting a repository under test in the first place? Our post on the custom Copilot agent for DAST onboarding shows how that agent generates the config for you.

Conclusion

Review Copilot's output and test the running application before release.

Copilot's filters reduce risky suggestions, but they don't test the running app. StackHawk fills that gap by giving Copilot a scanner, so "done" means the feature was tested, fixed, and verified. If your team also uses Cursor, you can run the same workflow in Cursor.

Add StackHawk to Copilot and get find, fix, verify before every PR. Wingman runs inside Copilot, Claude Code, Cursor, Codex, and Antigravity for $10 per user per month. Start a 14-day free trial.

FAQ

Is using GitHub Copilot secure?

Copilot has real guardrails: a vulnerability prevention filter, content filtering, public code matching, and CodeQL and secret scanning on the cloud agent's own changes. You still need to review and validate suggestions before accepting them. Treat Copilot output like other proposed code changes: review it, scan it, and test the running app before it ships.

Does GitHub Copilot expose your code?

GitHub doesn't train AI models on Copilot Business or Copilot Enterprise customer data. Since April 24, 2026, interactions on Copilot Free, Pro, Pro+, and Max may be used for training unless you opt out in your Copilot settings. The cloud agent also runs behind a firewall that restricts its internet access.

Is Copilot safe for confidential data?

On Business and Enterprise plans, your data isn't used for training, and admins can use content exclusion to keep specific files out of Copilot's context. Content exclusion doesn't apply in Agent mode in VS Code and other editors yet. Keep secrets out of the repository entirely, and use secret scanning and push protection as a backstop.

More Hawksome Posts