| type | skill |
| name | Security Audit |
| description | Security review checklist for code and infrastructure |
| skillSlug | security-audit |
| phases | ["R","V"] |
| generated | "2026-03-18T00:00:00.000Z" |
| status | filled |
| scaffoldVersion | 2.0.0 |
Security Audit
Security review checklist specific to the @dotcontext/cli CLI tool and MCP server.
When to Use
- Reviewing code that handles API keys or credentials
- Adding a new AI provider integration
- Changing the MCP server's file access or path resolution
- Modifying the export/sync service that writes files
- Evaluating dependencies for vulnerabilities
- Before a release (especially major or minor versions)
Threat Model
The @dotcontext/cli tool has a specific threat surface:
| Asset | Risk | Location |
|---|
| AI provider API keys | Exposure via logs, config files, or provider helpers | src/services/ai/providerFactory.ts, env vars |
| File system access | Path traversal, reading outside repo boundaries | src/services/mcp/gateway/explore.ts, readFileTool.ts |
| MCP server stdio | Command injection via tool parameters | src/services/mcp/mcpServer.ts |
| Generated scaffold content | Inclusion of secrets in .context/ output | src/services/ai/tools/, src/services/autoFill/, src/generators/ |
| User repository content | Unintended exposure via exported context | src/services/export/, src/services/sync/ |
| Dependencies | Supply chain vulnerabilities | package.json |
Security Checklist
API Key Handling
File System Security
MCP Server Security
Content Sanitization
The contentSanitizer.ts utility filters generated content:
Dependency Security
Export/Sync Security
Git Integration
Audit Procedure
Quick Audit (Before PR Merge)
- Search for hardcoded strings that look like keys:
- Patterns:
/[A-Za-z0-9]{32,}/, /sk-[a-zA-Z0-9]+/, /AKIA[A-Z0-9]{16}/
- Check that new file I/O uses
path.resolve() or path.join()
- Verify no
console.log() in MCP server code paths
- Check that error responses do not leak internal paths
Full Audit (Before Release)
- Run
npm audit and address any high/critical findings
- Review all files in
src/services/mcp/gateway/ for input validation
- Check
src/utils/contentSanitizer.ts for completeness of sanitization patterns
- Review
src/services/ai/providerFactory.ts and any prompt/default helpers for key handling
- Verify
.gitignore includes .env, *.pem, credentials*
- Check that scaffold output in
.context/ does not contain repo-external paths
- Review
src/services/ai/tools/ for file access boundaries
- Test with a repo containing sensitive-looking strings to verify sanitization
Vulnerability Response
If a security issue is found:
- Do not commit details to public branches
- Fix in a private branch or direct commit
- Update
contentSanitizer.ts if the issue involves generated content
- Update Zod schemas if the issue involves input validation
- Add a test case that verifies the fix
- Document in CHANGELOG under
### Security