T09 · Insecure Skill Coding Practices
- Location
assets/index.html:947- Finding
DOM-Based Cross-Site Scripting Through the Divination Question
- Content
View full analysis
${info.upper.name}${info.lower.name===info.upper.name?'为'+info.upper.nature:''}卦${q?`「${q}」`:''} ...`; ``` The offline and request-error paths contain another unsafe HTML sink: ```javascript if(!apiKey){ loading.style.display='none'; out.innerHTML=offlineFallback(info,question); return; } ``` ```javascript out.innerHTML=`✦ ${err.message}\n\n` +offlineFallback(info,question); ``` `offlineFallback()` includes the untrusted question in its returned string: ```javascript function offlineFallback(info,question){ const q=question?`仙家所问「${question}」,`:''; ... return `这位仙家,${q}六爻落定如下:\n${ys}\n\n` ... } ``` ### Technical Analysis The value from `questionInput` is attacker-controlled. It is embedded into HTML strings and parsed using `innerHTML`, so the browser treats injected tags and event-handler attributes as executable markup rather than plain text. The password input type used for the API key only masks its visual display. JavaScript running in the page can still access its value through the DOM. Consequently, successful script injection can read the configured API key, endpoint, model, question, and generated divination state. The page already demonstrates the safe alternative ...[truncated 1612 chars]- Remediation
View remediation
