AI-powered security analysis for GitHub Copilot CLI that identifies vulnerabilities in code changes and scans dependencies for known security issues.
Ported from gemini-cli-extensions/security to work with GitHub Copilot CLI.
- AI-powered security analysis: Leverages advanced AI capabilities to provide intelligent and context-aware security analysis
- Focused analysis: Analyzes code changes within pull requests to identify and address vulnerabilities early
- Comprehensive vulnerability detection: Scans for secrets, injection flaws, access control issues, insecure data handling, authentication problems, LLM safety issues, and privacy violations
- Dependency scanning: Identifies known vulnerabilities in project dependencies using OSV-Scanner
- Integrated with Copilot CLI: Seamlessly integrates as a custom agent and skills for GitHub Copilot CLI
- Expandable scope: Extensible architecture for future vulnerability detection enhancements
- GitHub Copilot CLI v0.0.360 or newer
- Node.js 18 or newer
- Git (for code analysis)
- OSV-Scanner (optional, for dependency scanning)
For dependency scanning functionality:
macOS/Linux:
brew install osv-scannerWindows:
winget install Google.OSVScannerOr download from OSV-Scanner releases.
-
Clone this repository:
git clone https://github.com/YOUR_USERNAME/copilot-cli-security.git cd copilot-cli-security -
Install dependencies:
npm install
-
Build the MCP server:
npm run build
-
Install the agent in Copilot CLI:
Copy the agent directory to your Copilot CLI agents location:
# macOS/Linux mkdir -p ~/.copilot/agents cp -r agent ~/.copilot/agents/security # Windows (PowerShell) New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.copilot\agents" Copy-Item -Recurse agent "$env:USERPROFILE\.copilot\agents\security"
-
Install the skills:
Copy the skills to your Copilot CLI skills directory:
# macOS/Linux mkdir -p ~/.copilot/skills cp -r .copilot/skills/* ~/.copilot/skills/ # Windows (PowerShell) New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.copilot\skills" Copy-Item -Recurse .copilot\skills\* "$env:USERPROFILE\.copilot\skills\"
-
Update the agent.json path:
Edit
~/.copilot/agents/security/agent.jsonand update the MCP server command path to point to your installation:{ "mcpServers": { "copilot-security-mcp": { "type": "local", "command": "node", "args": ["/ABSOLUTE/PATH/TO/copilot-cli-security/dist/index.js"] } } }
The security extension can be used in several ways within GitHub Copilot CLI:
Switch to the security agent for comprehensive analysis:
copilot
> /agent security
> Analyze my code changes for security vulnerabilitiesInvoke the security analysis skill directly:
copilot
> Use the security-analyze skill to check for vulnerabilities in my recent changesOr for dependency scanning:
copilot
> Use the security-scan-deps skill to scan for vulnerable dependenciesFrom any conversation, delegate security analysis:
copilot
> /delegate security Analyze the changes in src/api/ for security issuesBy default, the security analysis examines git diff against the default branch. You can customize:
> Analyze all source code in the src/ directory for security vulnerabilities
> Check for security issues in files changed in the last 3 commits
> Scan main.py for hardcoded secretsTo scan your project's dependencies for known vulnerabilities:
copilot
> /agent security
> Scan my project dependencies for vulnerabilitiesThe agent will:
- Locate relevant lock files (package-lock.json, Gemfile.lock, go.mod, etc.)
- Run OSV-Scanner to check against OSV.dev vulnerability database
- Prioritize findings by severity
- Provide remediation guidance
- Hardcoded secrets: API keys, private keys, passwords, connection strings embedded in source code
- IDOR: Endpoints accessing resources without ownership verification
- Missing authorization checks: Sensitive operations without proper authorization
- Privilege escalation: User-modifiable role/permission fields
- Path traversal/LFI: Unsafe file path construction from user input
- Weak cryptographic algorithms: DES, Triple DES, RC4, ECB mode
- Logging sensitive information: Passwords, PII, API keys, session tokens in logs
- PII handling violations: Improper storage/transmission of personally identifiable information
- Insecure deserialization: Unsafe deserialization of untrusted data
- Cross-site scripting (XSS): Unsanitized user input rendered in HTML
- SQL injection (SQLi): Raw user input in database queries
- Command injection: User input in system commands
- Server-side request forgery (SSRF): Unvalidated user-provided URLs
- Server-side template injection (SSTI): User input embedded in templates
- Authentication bypass: Improper session validation
- Weak session tokens: Predictable tokens, insufficient entropy
- Insecure password reset: Predictable reset tokens, token leakage
- Insecure prompt handling: Prompt injection vulnerabilities
- Improper output handling: Unsafe use of LLM-generated content (XSS, SQLi, eval)
- Insecure plugin/tool usage: Overly permissive tools, unsafe data flows
- PII exposure: Sensitive data flowing to external services, logs, analytics without proper protection
The extension consists of three main components:
-
MCP Server (
src/index.ts): Provides security-specific tools to Copilot CLIfind_line_numbers: Locates exact line numbers of vulnerable codeget_audit_scope: Retrieves git diff for analysisrun_poc: Executes proof-of-concept code to verify vulnerabilities
-
Security Agent (
agent/): Custom agent with security expertise- Implements SAST vulnerability analysis procedures
- Uses MCP tools to analyze code systematically
- Generates detailed security reports
-
Skills (
.copilot/skills/): Reusable security analysis workflowssecurity-analyze: Code vulnerability analysissecurity-scan-deps: Dependency vulnerability scanning
npm run buildnpm run watchnpm testThe original Gemini security extension achieved:
- 90% precision: Of all identified vulnerabilities, 90% were actual security risks
- 93% recall: Successfully identified 93% of known vulnerabilities
Results based on the OpenSSF CVE Benchmark.
- This is a first-pass analysis, not a complete security audit
- Use in combination with other security tools and manual code review
- The extension is designed for analyzing code changes, not entire codebases
- Dependency scanning requires OSV-Scanner to be installed separately
Contributions are welcome! Please feel free to submit issues or pull requests.
Apache License 2.0 - See LICENSE for details.
Ported from gemini-cli-extensions/security by Google.