Back to skill

Security audit

Cuihua Error Handler

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its error-handling purpose, but it needs review because its generated code can log sensitive inputs and its agent instructions are too broad for payment/auth code changes.

Install only if generated code will be reviewed before use. Avoid letting it automatically modify payment, authentication, or database code; invoke it with exact paths/functions, and require generated handlers to redact or omit raw args, request bodies, headers, tokens, secrets, and payment fields before logging.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 ยท Insecure Skill Coding Practices

Warning
Location
error-handler.js:240
Finding
Generated Error Handlers Log Complete Function Arguments## Vulnerability Details **File Location**: `error-handler.js`, lines 240โ€“272 **Vulnerability Type**: Sensitive data exposure through unsafe logging **Risk Level**: Medium ### Complete Code Snippet ```javascript generateAsyncErrorHandling(name, body, risk) { const errorClass = risk === 'critical' ? 'CriticalError' : risk === 'high' ? 'SecurityError' : risk === 'medium' ? 'DataError' : 'AppError'; return `async function ${name}(...args) { try { // Original logic ${body.trim().split('\n').map(line => ' ' + line).join('\n')} } catch (error) { // Network/timeout errors if (error.name === 'AbortError') { logger.error('${name} timeout', { args }); throw new ${errorClass}('Request timeout', { cause: error }); } if (error.message.includes('fetch failed')) { logger.error('${name} network error', { args, error: error.message }); throw new ${errorClass}('Network error', { cause: error }); } // Re-throw known errors if (error instanceof ${errorClass}) { logger.error('${name} failed', { args, error: error.message }); throw error; } // Unexpected errors logger.error('${name} unexpected error', { args, error }); throw new ${errorClass}('Internal error', { cause: error }); } }`; } generateSyncErrorHandling(name, body, risk) { return `function ${name}(...args) { try { // Original logic ${body.trim().split('\n').map(line => ' ' + line).join('\n')} } catch (error) { logger.error('${name} failed', { args, error: error.message }); throw new Error(\`${name} error: \${error.message}\`, { cause: error }); } }`; } ``` ### Technical Analysis Both generated wrappers capture function parameters through `...args` and write the complete argument array to structured logs whenever an exception occ ...[truncated 2544 chars]
Remediation
## Remediation Suggestions 1. Remove complete argument logging from both templates: ```javascript logger.error('${name} failed', { errorType: error.name, errorCode: error.code }); ``` 2. Use an explicit allowlist of diagnostic fields. Log stable operation names, correlation IDs, non-sensitive resource identifiers, and normalized error codes instead of arbitrary parameters. 3. If object logging is required, apply recursive redaction before values reach the logger. At minimum, redact case-insensitive keys such as: - `password` - `token` - `accessToken` - `refreshToken` - `authorization` - `cookie` - `secret` - `apiKey` - `cardToken` - `creditCard` - `cvv` 4. Do not log raw request objects, headers, database records, payment payloads, or error objects that may contain sensitive response data. Extract only approved properties. 5. Add depth, length, and collection-size limits to any sanitizer to prevent excessive or cyclic objects from reaching the logging backend. 6. Change generated examples in `SKILL.md` to model data-minimizing logging practices, and document that credentials, payment data, and PII must never be logged. 7. Add automated tests that generate wrappers for authentication and payment functions and assert that secrets cannot appear in the resulting log metadata.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (7)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The skill claims to be an AI-powered assistant that automatically analyzes and transforms code, but the file only contains descriptive markdown and illustrative snippets rather than executable skill logic or enforceable behavior. This mismatch is dangerous because users or orchestrators may trust the skill to perform code modifications or resilience analysis it cannot actually do, creating false assurance around production safety and error handling coverage.

Vague Triggers

Medium
Confidence
93% confidence
Finding
The README suggests broad natural-language invocations like 'Check error handling coverage in src/' and 'Add error handling to processPayment function' without defining scope boundaries, allowed file targets, or confirmation requirements. In agentic environments, ambiguous triggers can cause the skill to analyze or modify more code than intended, increasing the risk of unintended code changes, excessive access, or unsafe autonomous edits.

Lp3

Medium
Category
MCP Least Privilege
Confidence
93% confidence
Finding
The skill advertises behavior that would require access to code, environment context, and potentially networked resources, but it does not declare any explicit tool scope or allowed-tools boundaries. In agent ecosystems, missing scope declarations can lead to overbroad tool access or ambiguous runtime permissions, increasing the risk of unintended file, env, or network exposure when the skill is invoked.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The invocation phrases are broad and underspecified, such as analyzing entire directories or modifying named components without clear inclusion, exclusion, or approval boundaries. In an agent setting, vague triggers can cause the system to inspect or modify more files than intended, potentially touching sensitive code paths, secrets-containing files, or production-critical components.

External Transmission

Medium
Category
Data Exfiltration
Content
async _fetch(city) {
    const response = await retryWithBackoff(
      () => fetch(`https://api.weather.com/v1/${city}`),
      {
        maxRetries: 3,
        shouldRetry: (error) => {
Confidence
50% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Missing User Warnings

Medium
Confidence
85% confidence
Finding
This code performs network and payment-related operations by fetching order data and charging a card token, but there is no user-facing warning, confirmation, or explanatory comment/docstring describing that sensitive payment data will be used. For code files, safety-relevant network or sensitive operations should have some visible disclosure unless clearly documented as part of the skill's stated purpose, which is not established here.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The function reads a sensitive environment variable (`process.env.JWT_SECRET`) to verify tokens, but there is no user-facing log, warning, or documentation comment indicating credential access. Access to sensitive environment variables is explicitly in scope for missing-warning findings on code files when no disclosure is present.

Static analysis

Detected: suspicious.env_credential_access

Environment variable access combined with network send.

Critical
Code
suspicious.env_credential_access
Location
test-code.js:15