Back to skill

Security audit

Follow-up Engine (CRM Automation)

Security checks for vulnerabilities and agentic risk

Overview

This skill needs review because it can run scheduled sales automation that writes customer data into a CRM, and the implementation has weak safeguards around record matching, logging, and local file writes.

Install only if you intend to let this skill run scheduled B2B follow-up workflows against OKKI CRM. Before enabling live sync or cron, require exact CRM identity matching, reject draft-controlled internal fields such as filepath, mask customer emails in logs, define log retention, and document whether any send, archive, or notification action is actually permitted. Keep it in dry-run mode until those controls are verified.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
scripts/okki-integration.js:369
Finding
Draft-Controlled Arbitrary File Overwrite During Synchronization<![CDATA[ ## Vulnerability Details **File Location**: `scripts/okki-integration.js:369-400` **Vulnerability Type**: Untrusted property overwrite leading to arbitrary file write **Risk Level**: High ### Vulnerable Code ```js const filepath = path.join(CONFIG.draftsDir, file); try { const draft = JSON.parse(fs.readFileSync(filepath, 'utf8')); // Only process drafts whose status is draft if (draft.status === 'draft') { drafts.push({ filepath, ...draft }); } } catch (e) { log(`Failed to read draft file ${file}: ${e.message}`, 'WARN'); } ``` ```js function updateDraftStatus(draft, newStatus, okkiTrailId = null) { const updatedDraft = { ...draft, status: newStatus, updated_at: new Date().toISOString() }; if (okkiTrailId) { updatedDraft.okki_trail_id = okkiTrailId; } fs.writeFileSync(draft.filepath, JSON.stringify(updatedDraft, null, 2), 'utf8'); log(`Draft status updated: ${draft.draft_id} → ${newStatus}`); } ``` ### Technical Analysis The application calculates a trusted `filepath` from a filename found inside the drafts directory. It then merges that path with attacker-controlled JSON using: ```js { filepath, ...draft } ``` JavaScript object spread applies later properties last. Consequently, a `filepath` property inside the parsed JSON document overrides the trusted path. After a CRM trail is created successfully, `updateDraftStatus()` passes the resulting attacker-controlled `draft.filepath` directly to `fs.writeFileSync()`. There is no canonicalization, directory-containment check, schema validation, or rejection of unexpected properties. This creates a write-what-where condition in which the content is constrained to the serialized draft object, but the destination can be any path writable by the Node.js process. ### Attack Path 1. Obtain the ability to create or modify a file under the project's `drafts` directory. 2. Create a file whose name begins with `draft-` and ends with `.json`. 3. Set its `status` ...[truncated 1138 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Ensure the trusted path is applied after all untrusted properties: ```js drafts.push({ ...draft, filepath }); ``` 2. Prefer not to store an internal filesystem path on the draft object. Pass the trusted path as a separate function argument: ```js updateDraftStatus(filepath, draft, 'synced', trailId); ``` 3. Reject input documents containing internal fields such as `filepath`. 4. Validate drafts against a strict schema with: - Required properties and expected types. - Enumerated status and stage values. - Length limits. - `additionalProperties: false`. 5. Canonicalize and verify every write destination: ```js const base = path.resolve(CONFIG.draftsDir); const target = path.resolve(filepath); if (!target.startsWith(base + path.sep)) { throw new Error('Draft path escapes the drafts directory'); } ``` 6. Use atomic writes through a securely created temporary file followed by `rename()`. 7. Run the integration under a dedicated, least-privileged account that cannot modify executable code, credentials, startup files, or unrelated application data. 8. Add a regression test containing a malicious JSON `filepath` property and verify that no file outside `draftsDir` is modified. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/okki-integration.js:188
Finding
Ambiguous Customer Matching Can Write Follow-Up Data to the Wrong CRM Record<![CDATA[ ## Vulnerability Details **File Location**: `scripts/okki-integration.js:188-275` **Vulnerability Type**: Insecure direct CRM record selection and insufficient identity verification **Risk Level**: Medium ### Vulnerable Code ```js // Partial domain match if (result.data.length > 0) { return { company_id: result.data[0].company_id || result.data[0].id, name: result.data[0].name, match_type: 'domain_partial', confidence: 0.7 }; } ``` ```js // Partial name match return { company_id: result.data[0].company_id || result.data[0].id, name: result.data[0].name, match_type: 'name_partial', confidence: 0.7 }; ``` ```js async function matchCustomer(draft) { // If draft already has an OKKI company ID, use it directly if (draft.okki_company_id) { log(`Using existing OKKI customer ID: ${draft.okki_company_id}`); return { company_id: draft.okki_company_id, name: draft.customer_name, match_type: 'existing_id', confidence: 1.0 }; } // Try matching by email domain if (draft.customer_email) { const domain = extractDomain(draft.customer_email); if (domain && !isPublicDomain(domain)) { const domainResult = await searchCustomerByDomain(domain); if (domainResult) { return domainResult; } } } // Try matching by customer name if (draft.customer_name) { const nameResult = await searchCustomerByName(draft.customer_name); if (nameResult) { return nameResult; } } return null; } ``` The selected identifier is subsequently used to create a trail: ```js const result = await execOkkiCli([ 'trail', 'add', '--company', companyId, '--content', content, '--type', CONFIG.TRAIL_TYPE.FOLLOW_UP.toString() ]); ``` ### Technical Analysis When no exact domain or company-name match exists, the integration automatically accepts the first search result and assigns it a confidence value of `0.7`. That confidence value is informational only; no ...[truncated 2062 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Prohibit automatic writes based on partial matches. Require an exact, normalized domain or verified immutable customer identifier. 2. If a partial match is the only available result: - Mark the draft as requiring review. - Display all candidates. - Require explicit human selection before creating a trail. 3. Treat `okki_company_id` as untrusted input. Retrieve the company by ID and verify its domain, email, or another authoritative identifier against the draft. 4. Reject ambiguous searches that return multiple plausible candidates. 5. Enforce a server-side authorization check to confirm that the authenticated operator may modify the selected company. 6. Do not include customer email addresses in a CRM trail unless operationally necessary. Where possible, store references to existing structured CRM fields instead. 7. Record the evidence used for each match and maintain an audit log of manual approvals. 8. Add tests for: - Multiple companies with similar names. - Search results without exact matches. - Maliciously supplied company IDs. - Domain aliases and subsidiaries. ]]>

T09 · Insecure Skill Coding Practices

Note
Location
scripts/okki-integration.js:447
Finding
Unredacted Customer Personal Data Is Written to Logs and Dry-Run Output<![CDATA[ ## Vulnerability Details **File Location**: `scripts/okki-integration.js:447-485` **Additional Location**: `scripts/follow-up-scheduler.js:326` **Vulnerability Type**: Plaintext sensitive-data exposure through logging **Risk Level**: Low ### Vulnerable Code From the scheduler's dry-run path: ```js if (dryRun) { log(`[DRY-RUN] Will generate draft: ${draft.draft_id}`); log(` Customer: ${customer.name} (${customer.email})`); log(` Subject: ${draft.subject}`); log(` Template: ${template.template_id}`); } ``` From the integration processing path: ```js for (const draft of drafts) { log(`Processing draft: ${draft.draft_id}`); log(` Customer: ${draft.customer_name} (${draft.customer_email || 'No email'})`); log(` Stage: ${draft.stage}`); log(` Template: ${draft.template_id}`); ``` The failure result also retains customer identity fields: ```js results.details.push({ draft_id: draft.draft_id, status: 'failed', reason: 'customer_not_found', customer_name: draft.customer_name, customer_email: draft.customer_email }); ``` The shared logger writes every message to a persistent file: ```js function log(message, level = 'INFO') { const timestamp = new Date().toISOString(); const logLine = `[${timestamp}] [${level}] ${message}`; console.log(logLine); const logFile = path.join( CONFIG.logsDir, `okki-integration-${new Date().toISOString().split('T')[0]}.log` ); fs.appendFileSync(logFile, logLine + '\n'); } ``` ### Technical Analysis Customer names and full email addresses are written to console output and persistent daily log files. Dry-run mode does not prevent the disclosure; it only prevents CRM mutation. The returned JSON result may also contain full customer names and email addresses on matching failures. Callers such as cron jobs or test scripts may redirect that output to additional files, expanding the number of copies and the retention scope. This behavior contradicts the skill documentation, ...[truncated 1374 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove customer email addresses and other unnecessary personal data from routine logs. 2. Apply deterministic masking when an identifier is required for troubleshooting: ```js function maskEmail(email) { if (!email || !email.includes('@')) return '(redacted)'; const [, domain] = email.split('@'); return `***@${domain}`; } ``` 3. Use internal customer or draft identifiers instead of names and email addresses. 4. Redact sensitive fields from returned result objects before printing them as JSON. 5. Create log files with restrictive permissions, such as mode `0o600`, and ensure the log directory is accessible only to the service account. 6. Implement log rotation, a defined retention period, and secure deletion procedures. 7. Avoid predictable shared files under `/tmp`. Use `mktemp` or an equivalent securely created temporary file when tests must capture output. 8. Review exception messages and external CLI stderr before logging them because they may contain additional customer or authentication data. 9. Add automated tests that fail if complete email addresses appear in logs or dry-run output. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • 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 (29)

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding
The code chunk is narrowly an OKKI synchronization utility. It loads already-created draft files, deduplicates them, looks up matching companies in OKKI, creates follow-up trail entries, updates local draft status, and logs results. The declared description claims a broader automated follow-up scheduling and execution engine that generates personalized follow-up email drafts based on customer stage, last contact date, and strategy, with configurable CRM integration. None of the generation or scheduling behavior appears in this code chunk, and the CRM integration is not configurable here—it is explicitly tied to OKKI via a Python CLI. While syncing follow-up records to a CRM is consistent with part of the description, the actual code materially underdelivers on the declared primary capabilities and is more specialized than described.

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
*/30 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/follow-up-scheduler.js --mode auto >> /tmp/follow-up-scheduler.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
0 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/okki-integration.js --sync >> /tmp/okki-integration.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
0 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/okki-integration.js --sync >> /tmp/okki-integration.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
0 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/okki-integration.js --sync >> /tmp/okki-integration.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
0 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/okki-integration.js --sync >> /tmp/okki-integration.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
0 * * * * cd $WORKSPACE/skills/follow-up-engine && node scripts/okki-integration.js --sync >> /tmp/okki-integration.log 2>&1
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Intent-Code Divergence

Medium
Confidence
87% confidence
Finding
The README asserts a strong safety guarantee ('严禁自动发送') while other parts of the workflow describe automatic first replies being triggered and only an approval gate before sending. This kind of contradictory documentation can mislead operators into over-trusting the skill's behavior, increasing the chance of unintended outbound customer communication if implementation or review controls are weaker than implied.

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill references environment variables and scheduled execution but does not declare any explicit tool scope or permissions boundary. This makes the skill's operational capabilities implicit, increasing the risk of over-privileged execution, accidental secret exposure, or unsafe runtime assumptions when integrated into an agent platform.

Natural-Language Policy Violations

Medium
Confidence
90% confidence
Finding
The title and core description include Chinese text while the manifest metadata is in English, but the document does not state that the skill is region-specific or provide any user opt-in for language preference. This can violate language/locale policy by implicitly forcing a specific language for part of the user-facing skill documentation.

Description-Behavior Mismatch

Medium
Confidence
95% confidence
Finding
The manifest claims the skill is for follow-up scheduling and draft generation, but this configuration also enables a direct sending path via `send_reminder`. That expands the trust boundary from assistive drafting to externally visible action, increasing the risk of unauthorized customer contact, spam, or policy bypass if the send path is triggered without clear user consent and enforcement controls.

Description-Behavior Mismatch

Medium
Confidence
92% confidence
Finding
The lost-stage workflow performs `archive_and_notify`, which introduces side effects beyond the stated purpose of scheduling follow-ups and drafting emails. Undisclosed notification and archival behavior can affect records handling, trigger messages to internal channels, and create privacy or workflow integrity issues if users did not expect this automation.

Natural-Language Policy Violations

Medium
Confidence
76% confidence
Finding
The manifest fixes business hours to the Asia/Shanghai timezone, which imposes a specific locale assumption. Because the file does not document user choice, opt-in, or a region-specific justification, this may violate the language/locale policy for skills expected to operate across users or regions.

Missing User Warnings

Medium
Confidence
90% confidence
Finding
`auto_draft_enabled` combined with configured direct-send behavior means the skill can automate customer follow-up actions without any visible warning in the manifest. Even if approval is required for some sends, users may misunderstand the degree of automation, leading to unintended outbound communications, compliance issues, or reputational harm.

Natural-Language Policy Violations

Medium
Confidence
91% confidence
Finding
This JSON contains user-facing natural-language content in multiple places, including Chinese values such as stage names and suggested actions alongside English email subjects and intents. Because the file does not state that the skill is limited to a specific locale or that language is selected based on user preference, it risks violating a language/locale policy by producing communications in a fixed or inconsistent language without opt-in.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The manifest describes a follow-up engine for scheduling reminders, generating follow-up drafts, and syncing follow-up records with CRM systems. This file instead defines a comprehensive customer lifecycle state machine covering quotation, sample shipping, negotiation, payment, closed-won, and archival/lost handling, which is broader sales process automation rather than just follow-up execution.

Context-Inappropriate Capability

Medium
Confidence
89% confidence
Finding
The stated purpose is automated outbound sales follow-ups and CRM sync, but this config reacts to logistics tracking events, finance payment events, and archival review flows. Those capabilities imply cross-functional operational workflow handling beyond what is obviously required to schedule follow-ups or draft emails.

Natural-Language Policy Violations

Medium
Confidence
95% confidence
Finding
This code embeds its natural-language description and operational messages entirely in Chinese, including the declared feature summary and many runtime logs. Under the policy, forcing a specific language without user opt-in is a locale/language policy violation unless the constraint is explicitly justified or configurable.

Missing User Warnings

Medium
Confidence
87% confidence
Finding
The code sends follow-up content containing customer name, email, stage, and subject to an external OKKI system via the CLI/API. Although the file comments describe the integration purpose, there is no confirmation prompt or explicit user-facing disclosure at the point of transmission that personal/customer data will be sent externally.

Context-Inappropriate Capability

Medium
Confidence
92% confidence
Finding
The E2E test hard-codes checks for developer-specific filesystem paths outside the skill directory, including a local OKKI CLI path and another skill workspace. This creates environment-coupled behavior that can leak host layout details in logs, fail unpredictably on other machines, and establishes undeclared trust/dependency relationships beyond the follow-up engine’s stated scope.

Static analysis

Detected: suspicious.dangerous_exec

Shell command execution detected (child_process).

Critical
Code
suspicious.dangerous_exec
Location
scripts/okki-integration.js:70