AAK-TASKS-002: MCP tasks persist credentials past completion
- Severity
- HIGH
- Category
- MCP Configuration (
mcp-config) - Scanner
agent_audit_kit/scanners/mcp_tasks.py- Auto-fixable
- No.
- SARIF name
TasksCredentialPersistence
What it detects
A task record retains API keys / OAuth tokens after the task reaches a terminal state (completed/failed/cancelled). Long-lived credentials in persistent state are an obvious exfil target.
How to fix
Zeroize credential fields when the task transitions to a terminal state. Keep only what a post-mortem actually needs.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-TASKS-002
Limitations
Looks for self.credential, self.credentials, self.api_key, self.token, self.secret or self.password assigned in a file with a task class and one of the words completed, failed, cancelled, done, finished or terminal (matched inside longer words too), and clears the finding when any self.<name> = None, del self.<name>, clear_secret(, zeroize( or zero_ize( appears in the file. A different attribute name (self.access_token) is not matched, and a clearing statement that never runs on the terminal transition, such as a reset() nothing calls, still counts.
References
- OWASP MCP Top 10: MCP01:2025 (Token Mismanagement & Secret Exposure)
- OWASP Agentic Top 10: ASI03 (Identity and Privilege Abuse)
- Adversa AI MCP Top 25 (AAK-defined ids): ADV-TASKS-02
All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-TASKS-002.md: the page then shows that text, with the registry reference appended under it.