Commit 7840901
committed
🔒 fix(dashboard): patch stored XSS in audit log and path traversal in static server
Resolves two CodeQL code-scanning alerts.
js/xss (public/index.html): appendAuditEntry built the audit row via
innerHTML, and the attacker-controlled `entry.source` was concatenated
raw into a class attribute (`sourceClass`) with no escaping. A crafted
`source` could break out of the attribute and inject markup. Rebuild the
row with createElement + textContent so untrusted values can never be
parsed as HTML, and restrict the source-derived CSS class to a safe token.
js/path-injection (server.js): serveStatic relied on a startsWith guard
over a path.join result, which does not decode %2e%2e or collapse encoded
traversal. Decode the URL, strip the query, normalize, resolve against
publicDir, and reject anything escaping the root.
Verified: npm test 25/25; traversal probes (/../server.js, /%2e%2e/server.js,
encoded variants) all 404 while normal assets serve; injected audit payload
renders as inert text with no script execution.1 parent 890679a commit 7840901
2 files changed
Lines changed: 43 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
590 | 590 | | |
591 | 591 | | |
592 | 592 | | |
593 | | - | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
594 | 596 | | |
595 | 597 | | |
596 | 598 | | |
597 | | - | |
598 | | - | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
603 | 599 | | |
604 | 600 | | |
605 | | - | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
606 | 624 | | |
607 | 625 | | |
608 | 626 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
65 | 76 | | |
66 | | - | |
| 77 | + | |
67 | 78 | | |
68 | | - | |
| 79 | + | |
69 | 80 | | |
70 | 81 | | |
71 | | - | |
72 | | - | |
73 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
74 | 86 | | |
75 | 87 | | |
76 | 88 | | |
| |||
0 commit comments