Back to skill

Security audit

Hook Examples

Security checks for vulnerabilities and agentic risk

Overview

This is a documentation-only hook example skill; its audit-log sample needs privacy caution, but the artifact does not install or run hidden behavior.

Use this as hook API reference material. If implementing the audit-log example, log only an allowlisted subset, redact secrets and personal data, avoid raw session identifiers, and restrict log retention and access.

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
SKILL.md:24
Finding

Unredacted Tool Parameters and Session Identifiers Written to Logs

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 24–33
Vulnerability Type: Sensitive information exposure through logging
Risk Level: Medium

Vulnerable Code

javascript
api.registerHook("before_tool_call", async ({ event, ctx }) => {
  const log = {
    time: new Date().toISOString(),
    tool: event.tool.name,
    params: event.tool.params,
    session: ctx.sessionKey
  };
  // Write to log file
  console.log("[TOOL_AUDIT]", JSON.stringify(log));
  return {}; // Don't block, continue execution
});

Technical Analysis

The documented hook serializes the complete event.tool.params object and ctx.sessionKey without redaction, minimization, or access controls. Tool parameters may contain API keys, authentication tokens, private prompts, personal information, file contents, command arguments, or other confidential values.

If this example is incorporated into an operational plugin, all such data will be sent to the runtime's standard logging channel. Depending on deployment configuration, those logs may be retained on disk or forwarded to centralized monitoring systems, increasing both the number of parties with access and the duration of exposure.

The project contains documentation rather than an executable implementation, so the weakness becomes directly exploitable only if the example is adopted or deployed. No external transmission endpoint or intentional exfiltration mechanism was found in the reviewed project.

Attack Path

  1. An operator implements or copies the documented before_tool_call hook.
  2. A user or agent invokes a tool with a secret or private value in event.tool.params.
  3. The hook captures the entire parameter object and the associated session identifier.
  4. JSON.stringify(log) serializes these values without redaction.
  5. console.log writes them to the configured runtime logging pipeline.
  6. A user, administrator, support operator, compro ...[truncated 805 chars]
Remediation
View remediation

Remediation Suggestions

  • Do not log complete tool parameter objects by default.
  • Use an explicit allowlist containing only non-sensitive fields required for auditing, such as the tool name, timestamp, and a generated correlation identifier.
  • Recursively redact keys commonly associated with secrets, including password, token, secret, authorization, cookie, apiKey, and private-key fields.
  • Omit ctx.sessionKey or replace it with a keyed, non-reversible pseudonymous identifier.
  • Truncate values and reject binary data or large payloads before serialization.
  • Configure restrictive access controls, encryption, retention limits, and deletion policies for audit logs.
  • Ensure centralized log collectors and monitoring integrations receive only sanitized records.
  • Add automated tests that submit representative credentials and verify that neither exact values nor reversible encodings appear in logs.
  • Clearly label the example as illustrative and unsafe for production until redaction and log-access controls are implemented.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (1)

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
91% confidence
Finding

The audit-log example captures raw tool parameters and a session identifier, which can expose sensitive user inputs, credentials, file paths, or other operational secrets if logs are retained, forwarded, or viewed by unauthorized parties. In this hook context, the example is especially relevant because it is presented as copyable sample code and does not include redaction, minimization, access controls, or any warning about logging sensitive data.

Content

No source excerpt is available for this finding.