Skip to content

Commit e9c2366

Browse files
🔒 [Security Fix] Prevent DOM XSS in git commit URL (#40)
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent 4b969e0 commit e9c2366

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎src/pages/manage/components/commit.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ export const Commit = ({ commit }: { commit?: Commit }) => {
3636
}
3737
}
3838

39+
// Validate URL protocol to prevent XSS
40+
if (url) {
41+
try {
42+
const parsed = new URL(url);
43+
if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
44+
url = '';
45+
}
46+
} catch {
47+
url = '';
48+
}
49+
}
50+
3951
const time = dayjs(+commit.timestamp * 1000);
4052

4153
return (

0 commit comments

Comments
 (0)