security: Fix XSS vulnerabilities in UI components

- Replace innerHTML with textContent and createElement
- Use safe DOM manipulation methods
- Prevents XSS attacks through user-controlled data
This commit is contained in:
fr4iser
2026-02-28 20:40:00 +01:00
parent f9d125dfd8
commit 5db55fdd70
3 changed files with 76 additions and 34 deletions

View File

@@ -539,14 +539,23 @@ export class PoseDetectionCanvas {
const persons = this.state.lastPoseData?.persons?.length || 0;
const zones = Object.keys(this.state.lastPoseData?.zone_summary || {}).length;
statsEl.innerHTML = `
Connection: ${this.state.connectionState}<br>
Frames: ${this.state.frameCount}<br>
FPS: ${fps.toFixed(1)}<br>
Persons: ${persons}<br>
Zones: ${zones}<br>
Uptime: ${uptime}s
`;
// Use textContent instead of innerHTML to prevent XSS
statsEl.textContent = '';
const lines = [
`Connection: ${this.state.connectionState}`,
`Frames: ${this.state.frameCount}`,
`FPS: ${fps.toFixed(1)}`,
`Persons: ${persons}`,
`Zones: ${zones}`,
`Uptime: ${uptime}s`
];
lines.forEach((line, index) => {
if (index > 0) {
statsEl.appendChild(document.createElement('br'));
}
const textNode = document.createTextNode(line);
statsEl.appendChild(textNode);
});
}
showError(message) {