-
Notifications
You must be signed in to change notification settings - Fork 0
🔒 [security fix] Fix DOM-based XSS in error handling #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -474,7 +474,11 @@ async function executeBatchPayload() { | |||||||||||||||
| } | ||||||||||||||||
| } catch (error) { | ||||||||||||||||
| console.error("Critical Sync Failure:", error); | ||||||||||||||||
| DOM.syncStatus.innerHTML = `<span style="color:#ff453a">⚠️ Sync Failed. Error: ${error.code || 'Network'}</span>`; | ||||||||||||||||
| DOM.syncStatus.textContent = ''; | ||||||||||||||||
| const errorSpan = document.createElement('span'); | ||||||||||||||||
| errorSpan.style.color = '#ff453a'; | ||||||||||||||||
| errorSpan.textContent = `⚠️ Sync Failed. Error: ${error.code || 'Network'}`; | ||||||||||||||||
| DOM.syncStatus.appendChild(errorSpan); | ||||||||||||||||
|
Comment on lines
+477
to
+481
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this correctly fixes the XSS vulnerability, the implementation can be simplified. Instead of clearing the container and appending a new styled
Suggested change
|
||||||||||||||||
| // Potential fallback: Save to localStorage for later recovery | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
error.code || 'Network'will replace valid falsy codes (e.g.,0or an empty string) with'Network'. Prefer nullish coalescing (error.code ?? 'Network') to only fall back whencodeisnull/undefinedso the displayed error remains accurate.