Back to plugin

Security audit

WeChat

Security checks for vulnerabilities and agentic risk

Overview

ClawScan marked this plugin suspicious because it reports access-control and media-handling weaknesses that could expose the agent or gateway to unpaired messages, internal network requests, or resource exhaustion.

Consider the reported risks before installing, especially if the gateway can reach sensitive internal services or has limited memory. The authorization issue depends on missing or incomplete account-owner and pairing state, and the media risks depend partly on whether an attacker can influence media URLs or responses. The scan was static and did not reproduce an exploit; it also did not establish that separate command, tool, or execution approvals are bypassed.

Vulnerability Patterns
  • 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
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (3)

MCP07

Error
Location
dist/src/messaging/sender-access.js:118
Finding

Empty Sender Authorization State Fails Open ## Remediation Suggestions 1. Remove both empty-list admission mechanisms. An absent authorization list must not automatically authorize the current sender. 2. Route unidentified senders through the host's pairing workflow, or deny dispatch until an owner is explicitly configured. 3. Require explicit owner binding when importing token-only accounts. Do not infer ownership from the first arriving message. 4. Distinguish an intentionally configured public-access policy from missing, unreadable, or migrated authorization state. 5. Add regression tests for both SDK paths covering empty stores, absent owner IDs, token-only accounts, migration failures, valid owners, and unauthorized senders. 6. Keep command-owner and execution-approval checks independent of message admission.

Content
View full analysis

Vulnerability Details

File Location: plugin/dist/src/messaging/sender-access.js:12–18,87–93,118–121
Vulnerability Type: Improper Authorization / Fail-Open Access Control
Risk Level: High, conditional on missing account-owner and pairing state

Vulnerable Code

The authorization store falls back to the saved account owner, then to an empty list:

js
export function readWeixinAllowFromStore(accountId) {
    const fromStore = readFrameworkAllowFromList(accountId);
    if (fromStore.length > 0)
        return fromStore;
    const userId = loadWeixinAccount(accountId)?.userId?.trim();
    return userId ? [userId] : [];
}

The legacy authorization path treats that empty list as permission:

js
const authorization = await legacy.resolveSenderCommandAuthorizationWithRuntime({
    cfg: params.config,
    rawBody: params.rawBody,
    isGroup: false,
    dmPolicy: "pairing",
    configuredAllowFrom: [],
    configuredGroupAllowFrom: [],
    senderId: params.senderId,
    isSenderAllowed: (id, list) => list.length === 0 || list.includes(id),
    readAllowFromStore,
    runtime: params.commands,
});

The newer ingress path explicitly adds the current sender when the store is empty:

js
const result = await resolveIngress({
    channelId: CHANNEL_ID,
    accountId: params.accountId,
    identity: defineStableChannelIngressIdentity({ key: "weixin-user-id", kind: "stable-id" }),
    subject: { stableId: params.senderId },
    conversation: { kind: "direct", id: params.senderId },
    event: { kind: "message", authMode: "inbound", mayPair: true },
    policy: { dmPolicy: "pairing", groupPolicy: "allowlist" },
    // Legacy command-auth treated an empty pairing store as allowed. Keep that
    // admission for token-only accounts that have no saved user id.
    allowFrom: storeAllowFrom.length === 0 ? [params.senderId] : [],
    readStoreAllowFrom: async () => storeAllowFrom,
    ...(mayAuthorizeCommand
        ? {
            command: {
    
...[truncated 1944 chars]

other

Warning
Location
dist/src/cdn/upload.js:16
Finding

Unrestricted Outbound Media Downloads Permit SSRF and Response Forwarding ## Remediation Suggestions 1. Replace direct `fetch` calls with the host's approved SSRF-safe media downloader, where available. 2. Permit only explicitly supported schemes and reject URLs containing unexpected credentials or malformed host representations. 3. Resolve destinations and reject loopback, private, link-local, unspecified, multicast, and other non-public address ranges, including IPv6 equivalents. 4. Validate every redirect destination. Disable automatic redirects unless the downloader can enforce the same checks at each hop. 5. Prevent DNS rebinding by binding destination validation to the actual connection, or enforce the restriction through a controlled egress proxy. 6. Apply gateway-level egress restrictions so plugin code cannot reach sensitive internal services. 7. Add tests for direct private addresses, hostname-to-private resolution, public-to-private redirects, IPv6, and allowed public downloads.

Content
View full analysis

Vulnerability Details

File Location: plugin/dist/src/cdn/upload.js:16–41; called by the delivery.deliver handler in plugin/dist/src/messaging/process-message.js
Vulnerability Type: Server-Side Request Forgery
Risk Level: Medium, conditional on influencing a delivered media URL

Vulnerable Code

js
export async function downloadRemoteImageToTemp(url, destDir) {
    logger.debug(`downloadRemoteImageToTemp: fetching url=${redactUrl(url)}`);
    let res;
    try {
        res = await fetch(url);
    }
    catch (err) {
        const cause = err.cause ?? err.code ?? "";
        logger.error(`downloadRemoteImageToTemp: fetch network error url=${redactUrl(url)} error=${redactError(err)} hasCause=${Boolean(cause)}`);
        throw err;
    }
    if (!res.ok) {
        const msg = `remote media download failed: status=${res.status} url=${redactUrl(url)}`;
        logger.error(`downloadRemoteImageToTemp: ${msg}`);
        throw new Error(msg);
    }
    const buf = Buffer.from(await res.arrayBuffer());
    logger.debug(`downloadRemoteImageToTemp: downloaded ${buf.length} bytes`);
    await fs.mkdir(destDir, { recursive: true });
    const ext = getExtensionFromContentTypeOrUrl(res.headers.get("content-type"), url);
    const name = tempFileName("weixin-remote", ext);
    const filePath = path.join(destDir, name);
    await fs.writeFile(filePath, buf);
    logger.debug(`downloadRemoteImageToTemp: saved ext=${ext}`);
    return filePath;
}

Technical Analysis

The outbound delivery handler passes HTTP(S) media URLs to this function. The function performs a direct gateway-side fetch without validating the destination hostname, resolved IP address, or redirect targets.

Default redirect handling also allows a public URL to redirect to a private destination. The response is saved as a temporary file, after which the delivery handler uploads and sends it to the conversation recipient.

Consequently, this is not limited to making a blind re ...[truncated 1427 chars]

MCP05

Warning
Location
dist/src/cdn/pic-decrypt.js:16
Finding

Unbounded Media Downloads Occur Before Authorization and Size Enforcement ## Remediation Suggestions 1. Perform sender admission before media downloads, decryption, and transcoding. 2. Replace `arrayBuffer()` with bounded streaming. Count received bytes and cancel the response immediately when the permitted size is exceeded. 3. Reject excessive `Content-Length` values early, but retain the streaming limit because the header may be absent or inaccurate. 4. Apply an abortable deadline covering connection setup and complete body consumption, plus an idle-transfer timeout where supported. 5. Bound media-download concurrency and queue sizes per account and across the gateway. 6. Enforce resource limits before decryption and separate output limits for transcoding. 7. Clean up partial files and release response bodies on every cancellation or failure. 8. Test oversized responses, chunked bodies, misleading length headers, slow responses, unauthorized senders with media, and concurrent downloads.

Content
View full analysis

Vulnerability Details

File Location: plugin/dist/src/cdn/pic-decrypt.js:16–33; plugin/dist/src/media/media-download.js:22–26; plugin/dist/src/messaging/process-message.js:121–155
Vulnerability Type: Uncontrolled Resource Consumption / Denial of Service
Risk Level: Medium

Vulnerable Code

The inbound downloader buffers the entire response without an application-level transfer limit or deadline:

js
async function fetchCdnBytes(url, label) {
    let res;
    try {
        res = await fetch(url);
    }
    catch (err) {
        logger.error(`${label}: fetch network error url=${redactUrl(url)} err=${redactError(err)}`);
        throw err;
    }
    logger.debug(`${label}: response status=${res.status} ok=${res.ok}`);
    if (!res.ok) {
        await discardResponseBody(res, label);
        const msg = `${label}: CDN download failed status=${res.status}`;
        logger.error(msg);
        throw new Error(msg);
    }
    return Buffer.from(await res.arrayBuffer());
}

The inbound image pipeline applies its storage limit only after downloading and, where applicable, decrypting:

js
const buf = aesKeyBase64
    ? await downloadAndDecryptBuffer(img.media.encrypt_query_param ?? "", aesKeyBase64, cdnBaseUrl, `${label} image`, img.media.full_url)
    : await downloadPlainCdnBuffer(img.media.encrypt_query_param ?? "", cdnBaseUrl, `${label} image-plain`, img.media.full_url);
const saved = await saveMedia(buf, undefined, subdir, WEIXIN_MEDIA_MAX_BYTES);

The configured limit is:

js
const WEIXIN_MEDIA_MAX_BYTES = 100 * 1024 * 1024;

An equivalent unbounded response read exists in plugin/dist/src/cdn/upload.js:32 for outbound remote media:

js
const buf = Buffer.from(await res.arrayBuffer());

Technical Analysis

The 100 MiB inbound limit is passed to the media-storage function only after the complete response has already been materialized in memory. It therefore cannot prevent excessive network transfer or the initi ...[truncated 1857 chars]

SkillSpector was not run because this plugin release contains no bundled skills.

Endor dependency reachability

Checked Nov 18, 2026 · 9:19 PM UTC

No reachable vulnerabilities reported

Endor dependency scan completed.