T09 · Insecure Skill Coding Practices
- Location
scripts/course-autoplay.user.js:168- Finding
Overbroad Userscript Scope and Unsafe Automatic Confirmation Clicking
- Content
View full analysis
btn.textContent.trim() === '确定' || btn.textContent.trim() === '确定 ') .find(btn => { // 确保按钮在可见的弹窗内,而不是课程列表中 const rect = btn.getBoundingClientRect(); const isCentered = rect.top > window.innerHeight * 0.2 && rect.top < window.innerHeight * 0.8; return isCentered; }); if (confirmBtn) { logInfo('检测到通用弹窗,自动关闭'); confirmBtn.click(); return true; } ``` The console version contains substantially the same fallback: ```javascript // 策略 3: 通用 - 查找屏幕中央的"确定"按钮(避免误点课程列表) const centeredConfirmBtn = allButtons .filter(btn => btn.textContent.trim() === '确定' || btn.textContent.trim() === '确定 ') .find(btn => { const rect = btn.getBoundingClientRect(); const isCentered = rect.top > window.innerHeight * 0.2 && rect.top < window.innerHeight * 0.8; return isCentered; }); if (centeredConfirmBtn) { centeredConfirmBtn.click(); log('✅ 已关闭弹窗 (通用)'); return true; } ``` The bookmarklet applies even weaker validation because it accepts any matching page element whose text contains the confirmation label: ```javascript function handleDialog(){ const c ...[truncated 2864 chars]- Remediation
View remediation
