Back to skill

Security audit

Doc Publisher

Security checks for vulnerabilities and agentic risk

Overview

The skill mostly matches its WeChat publishing purpose, but it includes unsafe account-level scripts, hardcoded credential-like values, and cross-skill credential handling that users should review before installing.

Review and fix the bundled scripts before installing. Replace all credential-shaped examples with placeholders, rotate any real exposed WeChat secret, avoid running the draft-clearing utilities unless you add confirmation and backups, remove sibling .env access, and sanitize Markdown/HTML before previewing or publishing untrusted documents.

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

T09 · Insecure Skill Coding Practices

Error
Location
scripts/upload-cover.js:8
Finding

Hardcoded WeChat Application Credentials

Content
View full analysis
{ const req = https.get(`https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=${APPID}&secret=${SECRET}`, res => { let data = ''; res.on('data', chunk => data += chunk); res.on('end', () => { try { const result = JSON.parse(data); resolve(result.access_token); } catch (e) { reject(e); } }); }); req.on('error', reject); }); } ``` ### Technical Analysis The script embeds a WeChat AppID and application secret directly in source code. Anyone with access to the package can recover these values without needing access to the intended deployment environment. The script uses the credential to request an access token from the official WeChat API. If the embedded credential remains valid and the calling IP is authorized by the account configuration, the resulting token can be used to invoke API operations allowed to that WeChat application. Because the script executes `main()` automatically, invoking the file attempts to authenticate using the embedded account rather than requiring an explicitly configured user account. The script also prints the first 20 characters of the returned token at lines 86-87, unnecessarily exposing part of a bearer credential in terminal logs. ### Attack Path 1. An attacker obtains a copy of the Skill package or source repository. 2. The attacker extracts the embedded AppID and secret from `scripts/upload-cover.js`. 3. The attacker submits them to the WeChat token endpoint from an authorized network location. 4. If the credentials are valid, WeChat returns an access token. 5. The ...[truncated 610 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scripts/clear-all-drafts.js:6
Finding

Account-Wide Draft Deletion Without Confirmation or Ownership Checks

Content
View full analysis
setTimeout(r, 2000)); } ``` ### Technical Analysis Both scripts enumerate drafts from the configured WeChat account and delete every returned item. They do not: - Request interactive confirmation. - Provide a dry-run mode. - Verify that a draft was created by this Skill. - Restrict deletion to locally recorded draft IDs. - Export or back up content before deletion. - Offer rollback or recovery. - Require an explicit destructive-operation flag. `clear-and-publish.js` makes account-wide deletion ...[truncated 1211 chars]
Remediation
View remediation

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/clear-drafts.js:7
Finding

Credential Loading From a Sibling Skill Violates Isolation Boundaries

Content
View full analysis
{ const parts = line.split('='); if (parts[0] && parts[1]) process.env[parts[0].trim()] = parts[1].trim(); }); } } } loadEnv(); ``` ### Technical Analysis The Skill searches outside its own project directory for another Skill’s `.env` file and copies values into the current process environment. This behavior violates least-privilege and project-isolation expectations. The loop processes both files rather than stopping after the local configuration is found. Therefore, values from the sibling `wechat-publisher/.env` can silently overwrite variables loaded from this Skill’s own `.env`. The parser also overwrites any pre-existing process environment variable with values read from these files. This can cause upload or deletion operations to run against an account different from the one the user intended. The user-facing documentation describes configuration under this Skill’s own `.env` and does not disclose sibling credential discovery. ### Attack Path 1. A sibling `wechat-publisher` directory contains a valid `.env` file. 2. The user configures this Skill for one account or relies on inherited environment variables. 3. The user runs `clear-drafts.js` or `upload-cover-image.js`. 4. The script reads both `.env` files. 5. The sibling file’s values overwrite the intended WeChat credentials. 6. The subsequent d ...[truncated 733 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
src/markdown-to-wechat.js:12
Finding

Unescaped Markdown Produces Injectable HTML and Unsafe Local Previews

Content
View full analysis
$1'); // 行内代码 text = text.replace(/`([^`]+)`/g, '$1'); // 链接:只保留 http/https,移除锚点链接 text = text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, linkText, url) => { if (url.startsWith('http://') || url.startsWith('https://')) { return '' + linkText + ''; } return linkText; }); return text; } ``` From `examples/check-wechat-format.js`: ```javascript const previewHtml = ` 微信公众号预览 body { background: #f5f5f5; padding: 20px; } .container { max-width: 677px; margin: 0 auto; background: white; padding: 20px; } .info { background: #e3f2fd; padding: 15px; margin-bottom: 20px; border-radius: 6px; }

📱 微信公众号预览

请在手机模式下查看效果(按 F12 切换设备模拟器)

文档:${path.basename(filePath)}

${html}
`; fs.writeFileSync(previewPath, previewHtml, 'utf8'); ``` ### Technical Analysis `parseInline()` applies Markdown substitutions without first escaping attacker-controlled text. Raw HTML in ordinary paragraphs, headings, list items, table cells, link labels, and quotations can therefore remain active in the generated output. The URL validation only checks whether a s ...[truncated 1766 chars]
Remediation
View remediation
` elements, event-handler attributes, malformed links, SVG payloads, and encoded protocol bypasses. 9. Treat WeChat sanitization only as defense in depth rather than the primary control. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/upload-cover-image.js:110
Finding

Recursive Image Discovery Silently Uploads the First Discovered File

Content
View full analysis
Remediation
View remediation
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • 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 (93)

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · readme.md (reported line 21)May include surrounding context.

md
**步骤 1:复制配置文件**
`ash
cd skills/doc-publisher
copy .env.example .env
`

**步骤 2:获取公众号信息**

Ssd 3

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The README includes values formatted as actual WeChat APPID and SECRET credentials and instructs users to place them in a .env file. If these are real, they expose account access; even if they are examples, using realistic-looking secrets in documentation trains unsafe handling of credentials and can cause accidental misuse.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

This line shows a credential-like WECHAT_SECRET value inside documentation, which can expose sensitive authentication material if real and encourages insecure secret handling if copied verbatim. In the context of a publishing skill that authenticates to an external account, exposed secrets can enable unauthorized publication or account abuse.

Content

Scanner excerpt · readme.md (reported line 37)May include surrounding context.

md
**步骤 3:编辑 .env 文件**

用记事本打开 .env 文件,填入你的信息:
`env
WECHAT_APPID=wxebff9eadface1489
WECHAT_SECRET=44c10204ceb1bfb3f7ac09675497654

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The script deletes every draft returned by the API with no confirmation, dry-run mode, filtering, or backup step. In an agent or automation context, this is dangerous because an accidental invocation, wrong account context, or misuse can irreversibly destroy content at scale before publishing a single article.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 12)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 19)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/clear-drafts.js (reported line 9)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/clear-drafts.js (reported line 10)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/upload-cover-image.js (reported line 9)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/upload-cover-image.js (reported line 10)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/upload-cover-image.js (reported line 175)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · scripts/upload-cover.js (reported line 96)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · src/wechat-api.js (reported line 14)May include surrounding context.

js
// 加载环境变量
function loadEnv() {
  const envPaths = [
    path.join(__dirname, '..', '.env'),
    path.join(__dirname, '..', '..', 'wechat-publisher', '.env')
  ];

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

The script obtains an access token and logs the first 20 characters to stdout. Even partial token disclosure is sensitive because logs may be persisted, shared, or scraped, and exposing token fragments materially lowers the effort required for misuse or correlation with other leaked data.

Content

Scanner excerpt · scripts/upload-cover.js (reported line 84)May include surrounding context.

js
console.log('📄 封面文件:', coverPath);
  
  // 获取 Token
  console.log('🔑 获取 Access Token...');
  const token = await getAccessToken();
  console.log('   Token:', token.substring(0, 20) + '...');

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · readme.md (reported line 1)May include surrounding context.

md
---
name: doc-publisher
description: 文档系列发布工具 - 将本地 Markdown 文档自动转换为微信公众号文章并发布
postInstall: |

Hidden Instructions

High
Category
Prompt Injection
Confidence
60% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · skill.md (reported line 1)May include surrounding context.

md
---
name: doc-publisher
description: 文档系列发布工具 - 将本地 Markdown 文档自动转换为微信公众号文章并发布
postInstall: |

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

At this location the documentation presents concrete secret values inside an .env example, which can lead users to mirror unsafe patterns and mishandle real credentials. Even if the shown values are samples, embedding credential-shaped strings without a warning materially increases the chance of accidental disclosure and poor secret hygiene.

Content

Scanner excerpt · skill.md (reported line 202)May include surrounding context.

| THUMB_MEDIA_ID | 素材管理 → 图片 → 上传后获取 media_id | | QRCODE_URL | 设置与开发 → 公众号二维码 → 复制图片链接 |

3. 编辑 .env 文件

用记事本打开 .env 文件,填入你的信息:

env

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · skill.md (reported line 317)May include surrounding context.

md
2. **预览方法** - 使用 `check-wechat-format.js` 在浏览器模拟手机效果

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 14)May include surrounding context.

js
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 16)May include surrounding context.

js
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 20)May include surrounding context.

js
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 39)May include surrounding context.

js
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · examples/publish-any.js (reported line 132)May include surrounding context.

js
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · readme.md (reported line 35)May include surrounding context.

md
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · readme.md (reported line 93)May include surrounding context.

md
const fs = require('fs');

/**
 * 加载 .env 配置
 */
function loadEnv() {
  const envPath = path.join(__dirname, '..', '.env');