T09 · Insecure Skill Coding Practices
- Location
assets/dashboard-template.html:299- Finding
Unescaped User Data Can Be Injected into Executable HTML and JavaScript Contexts
- Content
View full analysis
家庭财务全景分析
__SCENARIO_DESCRIPTION__
__DATE_TAG__``` ```javascript function renderTab0() { document.getElementById('tab0').innerHTML = `基准数据:__BASE_DATA_DESCRIPTION__``` The model specification also places user-derived strings directly inside JavaScript string literals: ```javascript const stockAccounts = [ { name: '__NAME__', valueInOrigCurrency: __VALUE__, currency: 'HKD' }, // ... multiple accounts are allowed ]; const futureEquity = [ { date: '__DATE__', shares: __N__, pricePerShare: __PRICE__, currency: 'HKD', label: '__LABEL__' }, ]; ``` ### Technical Analysis The Skill instructs the Agent to replace placeholders with actual user data, but it does not define contextual escaping, serialization, or validation requirements. Several placeholders are inserted directly into HTML, template literals assigned to `innerHTML`, or quoted JavaScript values. These contexts require different defenses: - HTML text requires HTML entity encoding. - JavaScript strings require safe serialization rather than quote replacement. - Template literals must account for backticks and `${...}` interpolation. - Values assigned through `innerHTML` must not contain attacker-controlled markup. For example, a crafted scenario description such as: ```html``` would become active markup if substituted verbatim into `__SCENARIO_DESCRIPTION__`. A crafted account name containing a quote or template-literal delimiter could also terminate its intended ...[truncated 1451 chars]
- Remediation
View remediation
``` 9. Replace inline `onclick` handlers with `addEventListener` so that a stricter CSP can be enforced. 10. Add automated tests containing quotes, backticks, `${...}`, closing tags, and event-handler payloads to verify that all supplied strings are rendered only as text. ]]>
