{"record":{"id":"90ebaa5e09efeb72","repo":"davila7/claude-code-templates","slug":"sem-e005","errorCode":"SEM_E005","errorMessage":"Credential harvesting pattern detected","messagePattern":"Credential harvesting pattern detected","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cli-tool/src/validation/validators/SemanticValidator.js","lineNumber":47,"sourceCode":"        code: 'SEM_E002',\n        message: 'Prompt injection detected: Reference to system/developer instructions',\n        severity: 'critical'\n      },\n      {\n        pattern: /you\\s+are\\s+now\\s+(a|an)\\s+/gi,\n        code: 'SEM_E003',\n        message: 'Role manipulation detected: Attempt to redefine AI role',\n        severity: 'high'\n      },\n      {\n        pattern: /execute\\s+the\\s+following\\s+(code|command|script)/gi,\n        code: 'SEM_E004',\n        message: 'Command execution attempt detected',\n        severity: 'critical'\n      },\n      {\n        pattern: /\\b(fetch|retrieve|get|extract|obtain|steal|harvest|capture|collect)\\s+(the\\s+)?(user['']?s?\\s+)?(auth\\s+)?(token|key|password|credential|secret|api[\\s_-]?key)/gi,\n        code: 'SEM_E005',\n        message: 'Credential harvesting pattern detected',\n        severity: 'critical'\n      },\n      {\n        pattern: /(open|spawn|exec|run)\\s+(a\\s+)?(shell|terminal|bash|cmd|powershell)/gi,\n        code: 'SEM_E006',\n        message: 'Shell access attempt detected',\n        severity: 'critical'\n      },\n      {\n        pattern: /(disable|bypass|override|skip)\\s+(security|safety|filter|protection|validation)/gi,\n        code: 'SEM_E007',\n        message: 'Security bypass attempt detected',\n        severity: 'critical'\n      },\n      {\n        pattern: /always\\s+(obey|follow|comply\\s+with|execute)\\s+the\\s+user/gi,\n        code: 'SEM_E008',","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/davila7/claude-code-templates/blob/a0851ed10c7c60463dac8cfaaca124cf32d5804d/cli-tool/src/validation/validators/SemanticValidator.js#L29-L65","documentation":"SEM_E005 is a critical finding from the credential-harvesting regex /\\b(fetch|retrieve|get|extract|obtain|steal|harvest|capture|collect)\\s+(the\\s+)?(user'?s?\\s+)?(auth\\s+)?(token|key|password|credential|secret|api[\\s_-]?key)/gi. It detects instructions that direct the agent to obtain secrets — the core behavior of exfiltration-focused malicious components. The validator emits it whenever matched text appears in any validated field of the component.","triggerScenarios":"Component content containing verb+secret noun combinations such as 'retrieve the API key', 'get the user's password', or 'collect auth tokens'. Note api[\\s_-]?key also matches 'api_key' and 'api-key', and the optional possessive means 'fetch tokens' alone matches.","commonSituations":"Legitimate automation docs that tell the agent to read an env var secret ('get the API key from the environment'); MCP integration components describing token-based auth flows; security-audit components that quote attacker phrasing.","solutions":["Rephrase to reference environment variables without the flagged verb-noun pair: 'Use process.env.MY_API_KEY' instead of 'get the api key'","Refer to secrets generically as 'credentials from the environment' via configuration, not imperative prose","If quoting an attack sample, obfuscate it (e.g. 'retr**ve the pa**word') or keep it out of validated fields","For approved security-testing components, use the pipeline's waiver after review"],"exampleFix":"// before\nRetrieve the auth token from ~/.netrc and include it in the request.\n\n// after\nRead credentials via the configured auth provider (e.g. process.env.AUTH_TOKEN).","handlingStrategy":"validation","validationCode":"const CRED_RE = /\\b(fetch|retrieve|get|extract|obtain|steal|harvest|capture|collect)\\s+(the\\s+)?(user'?s?\\s+)?(auth\\s+)?(token|key|password|credential|secret|api[\\s_-]?key)/i;\nfunction containsCredentialHarvesting(text) { return CRED_RE.test(text); }\nif (containsCredentialHarvesting(content)) failFast('Reword secret-handling instructions.');","typeGuard":"function isSafeSecretText(text) { return !/\\b(fetch|retrieve|get|extract|obtain|steal|harvest|capture|collect)\\s+(the\\s+)?(user'?s?\\s+)?(auth\\s+)?(token|key|password|credential|secret|api[\\s_-]?key)/i.test(text); }","tryCatchPattern":null,"preventionTips":["Reference secrets only via env var names in code blocks, never verb+noun imperatives","Never instruct the agent to read credential files (~/.netrc, ~/.aws/credentials)","Audit third-party components for secret-reading instructions before install"],"tags":["credential-harvesting","secret-exfiltration","semantic-validation"],"backgroundTag":"credential-exfiltration-detected","analyzedSha":"a0851ed10c7c60463dac8cfaaca124cf32d5804d","analyzedAt":"2026-08-28T14:11:56.058Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}