T09 · Insecure Skill Coding Practices
- Location
dist/fetch-content.js:7- Finding
Unrestricted Browser Navigation Enables Server-Side Request Forgery
- Content
View full analysis
Vulnerability Details
File Location:
dist/index.js:44-53; request execution occurs atdist/fetch-content.js:7-10
Vulnerability Type: Server-Side Request Forgery (SSRF) through unvalidated browser navigation
Risk Level: HighVulnerable Code
dist/index.js:44-53:js if (action === "add_article") { const exists = db.article.some(k => k.url === url); if (exists) { console.log("该 URL 已存在,跳过重复添加"); } else { const browser = await getBrowser(); const content = await fetchUrlContent(browser, url); db.article.push({dist/fetch-content.js:7-10:js export async function fetchUrlContent(browser, url) { const page = await browser.newPage(); try { await page.goto(url, { waitUntil: "domcontentloaded" });Technical Analysis
The
add_articleaction acceptsprocess.argv[3]as a URL and passes it tofetchUrlContent. That function supplies the value directly to Puppeteer'spage.goto()without validating the URL scheme, hostname, resolved IP address, port, or redirect targets.Although
SKILL.mdinstructs the Agent to invoke this command only formp.weixin.qq.com, this policy is not enforced by the executable. Consequently, any caller able to control the command argument can direct the browser to loopback addresses, private-network services, link-local resources, cloud metadata services, or attacker-controlled redirectors.The response is reduced to text from
#activity-nameor.rich_media_title, limiting direct response disclosure. However, navigation itself can still reach protected services, trigger state-changing GET endpoints, and disclose selected internal page content through the title stored in the local article database.Attack Path
- An attacker supplies a loopback, private-network, link-local, metadata-service, or redirecting URL as the
add_articleargument. - The CLI reads th ...[truncated 1207 chars]
- An attacker supplies a loopback, private-network, link-local, metadata-service, or redirecting URL as the
- Remediation
View remediation
Remediation Suggestions
- Parse every supplied value with
new URL()and reject malformed URLs. - Permit only the
https:scheme unless another scheme is explicitly required. - Enforce the intended hostname in code, using an exact match for
mp.weixin.qq.comor a narrowly defined allowlist. Do not rely solely on Agent instructions. - Resolve the hostname before navigation and reject every loopback, private, link-local, multicast, unspecified, and reserved IPv4 or IPv6 address.
- Revalidate each redirect target because an allowed public URL may redirect to a prohibited destination.
- Prevent DNS-rebinding attacks by coupling validated resolution with the actual connection or by enforcing browser egress controls at the network layer.
- Restrict browser network access to explicitly approved destinations as defense in depth.
- Add automated tests covering localhost, RFC 1918 ranges, IPv6 loopback, link-local addresses, alternative IP representations, malicious redirects, and DNS rebinding scenarios.
- Parse every supplied value with
