T09 · Insecure Skill Coding Practices
- Location
scripts/publish-node.mjs:130- Finding
Arbitrary Local File Read and Network Disclosure Through Article Image Paths
- Content
View full analysis
]*src=["']([^"']+)["'][^>]*>/gi)]; let processed = html; for (const match of srcMatches) { const src = match[1]; if (/^https?:\/\//i.test(src) || src.startsWith("data:")) { continue; } const imagePath = path.isAbsolute(src) ? src : path.resolve(baseDir, src); const uploaded = await uploadImage(config, accessToken, imagePath, false); if (uploaded.url) { processed = processed.replaceAll(`src="${src}"`, `src="${uploaded.url}"`); processed = processed.replaceAll(`src='${src}'`, `src='${uploaded.url}'`); } } return processed; } ``` Python implementation: ```python async def process_content_images(self, access_token: str, content: str, content_dir: Path) -> str: processed = content matches = re.findall(r']*src=["\']([^"\']+)["\'][^>]*>', content, flags=re.IGNORECASE) for src in matches: if src.startswith(("http://", "https://", "data:")): continue image_path = Path(src) if not image_path.is_absolute(): image_path = (content_dir / src).resolve() uploaded = await self.upload_image(access_token, str(image_path), is_thumb=False) if uploaded.get("url"): processed = processed.replace(f'src="{src}"', f'src="{uploaded["url"]}"') processed = processed.replace(f"src='{src}'", f"src='{uploaded['url']}'") return processed ``` ### Technical Analysis Both publishers treat every non-HTTP and non-`data:` image source as a local filesystem path. Absolute paths are accepted directly, while relative paths are resolved withou ...[truncated 1819 chars]- Remediation
View remediation
