T09 · Insecure Skill Coding Practices
- Location
package/src/index.ts:56- Finding
Raw Exception Stack Trace Disclosure
- Content
View full analysis
Vulnerability Details
File Location:
package/src/index.ts:56-61
Vulnerability Type: Information disclosure through verbose error handling
Risk Level: LowVulnerable Code
ts } catch (error: any) { return { success: false, message: `执行失败:${error.message}`, error: error.stack, }; }The same behavior is present in the generated runtime artifact at
package/dist/index.js:56-62.Technical Analysis
The top-level
execute()exception handler returns both the raw exception message and complete stack trace to the caller. Stack traces commonly contain absolute filesystem paths, package and module names, function names, line numbers, and details about the runtime environment.An unauthenticated or otherwise untrusted caller who can submit skill input may be able to trigger an exception through malformed execution context, unexpected data types, SDK behavior, or another runtime failure. Returning
error.stackcrosses the trust boundary between internal diagnostics and user-visible output.No direct API-token disclosure was demonstrated in the reviewed code. Exploitability also depends on whether the host platform exposes the
errorfield to callers.Attack Path
- An attacker invokes the skill with malformed context or input designed to trigger an uncaught exception.
- The exception propagates to the top-level
catchblock inexecute(). - The handler copies
error.messageinto the public message anderror.stackinto the returned result. - If the hosting platform exposes the result, the attacker receives internal filesystem, dependency, and implementation details.
- The disclosed information can support reconnaissance and the development of more targeted follow-up attacks.
Impact Assessment
The direct impact is limited to information disclosure. An attacker may learn deployment paths, runtime structure, dependency names, and internal call flow. This issue does not independently provide code ex ...[truncated 220 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not include
error.stackor raw SDK exception details in skill results returned to callers. - Return a generic, user-safe error such as “The operation failed. Please try again or contact support.”
- Record detailed diagnostics only in a restricted server-side logging system.
- Sanitize logs to prevent API tokens, email content, recipient addresses, or other sensitive values from being recorded.
- Associate public failures with a random correlation identifier so administrators can locate the corresponding internal log entry.
- Normalize unknown thrown values before handling them instead of assuming every value has
messageandstackproperties. - Apply the fix to the TypeScript source and rebuild
dist/index.jsso the distributed runtime artifact no longer exposes stack traces.
A safer implementation would be:
ts } catch (error: unknown) { const incidentId = crypto.randomUUID(); // Send sanitized diagnostics to a restricted internal logger. logger.error({ incidentId, error }, 'Sendflare skill execution failed'); return { success: false, message: `The operation failed. Reference: ${incidentId}`, }; }- Do not include
