T09 · Insecure Skill Coding Practices
- Location
scripts/playlet_bili_daily.py:245- Finding
Stored HTML Injection Through Unescaped API Response Fields
- Content
View full analysis
0: metrics_parts.append(f'🔗 {format_number(raw_shares)}') if raw_likes > 0: metrics_parts.append(f'👍 {format_number(raw_likes)}') if raw_comments > 0: metrics_parts.append(f'💬 {format_number(raw_comments)}') metrics_html = ''.join(metrics_parts) cover_html = "" if cover: cover_html = f'' # B站链接生成:使用BV号拼接B站视频链接 if photo_id: # photoId是BV号格式(如BV1onEQ6sEiL) url = f"https://www.bilibili.com/video/{photo_id}" title_html = f'{title}' else: title_html = f'{title}' articles_html += f'''
{cover_html}''' ``` The resulting markup is written directly to an HTML file: ```python with open(html_file, 'w', encoding='utf-8') as f: f.write(html_content) return html_file ``` The generated file is then opened automatically: ```python webbrowser.open(f"file://{html_file}") ``` ### Tech ...[truncated 2949 chars]{title_html}{author} {metrics_html}- Remediation
View remediation
``` 6. Remove automatic browser opening or require explicit user confirmation before opening the generated report. 7. When using `target="_blank"`, add `rel="noopener noreferrer"` to prevent opened pages from controlling the report tab. 8. Add regression tests for malicious values in every API-controlled field, including quote-breaking payloads, event-handler injection, script elements, malformed URLs, and unexpected identifier formats. ]]>
