Skip to content

Fix: XSS via unescaped innerHTML in translation history/favorites - #7

Merged
albert-mueller merged 1 commit into
mainfrom
fix/xss-translate-history
Aug 7, 2026
Merged

Fix: XSS via unescaped innerHTML in translation history/favorites#7
albert-mueller merged 1 commit into
mainfrom
fix/xss-translate-history

Conversation

@albert-mueller

Copy link
Copy Markdown
Owner

Problem

createHistoryItem() and createFavoriteItem() in others/translate/app.js insert item.sourceText and item.translation directly into innerHTML without escaping. Both fields are user-controlled (typed input / translation output) and persisted to localStorage, then re-rendered on every visit to the History/Favorites panels. Text like <img src=x onerror=alert(1)> typed into the translator executes as script when the history entry is later rendered (stored XSS, CWE-79).

Fix

Added an escapeHtml() helper and applied it to both fields in both functions, matching the textContent-based pattern already used safely elsewhere in this file (synonyms, dictionary, grammar, context panels).

Scope

Single file, others/translate/app.js. No behavior change besides escaping.

@albert-mueller
albert-mueller merged commit e2de31f into main Aug 7, 2026
2 checks passed
@albert-mueller
albert-mueller deleted the fix/xss-translate-history branch August 7, 2026 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant