Repository navigation
Conversation
AjaxEditableLabel.onError placed a validation error message into the
single-quoted JavaScript string window.status='...' through
JavaScriptUtils.escapeQuotes, which escapes ' and " but leaves the
backslash untouched. A message that carries a backslash in front of a
quote therefore closes the string and runs whatever follows. Validation
messages routinely echo the value the user submitted through the
${input} variable, so those characters are attacker controlled, which
makes this a cross-site scripting hole.
AjaxListPanel.append builds the same kind of single-quoted script string
(Wicket.DOM.add(..., '...')) with the same backslash-unsafe helper.
Both now use escapeQuotesAndBackslash, the helper that also doubles the
backslash and is already used for the single-quoted script strings in
Link, ExternalLink and PopupSettings. Messages and tags that contain no
backslash render exactly as before, so an application sees no change
unless its text relied on the backslash passing through unescaped.
Can you please add a test based on this example? |
Adds a case where the submitted value \';alert(1)// reaches the
validation message through the ${input} variable, the way an
application's own message bundle would echo it. Without
escapeQuotesAndBackslash the generated window.status='...' string is
closed by the input; with it the quote stays inside the string.
|
Added With plain |
|
Hi @fr-manvi, please report issues like this to security@apache.org |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1668 +/- ##
============================================
+ Coverage 61.96% 61.99% +0.03%
- Complexity 11285 11291 +6
============================================
Files 1250 1250
Lines 48437 48437
Branches 6796 6796
============================================
+ Hits 30014 30030 +16
+ Misses 15729 15711 -18
- Partials 2694 2696 +2 🚀 New features to boost your workflow:
|
AjaxEditableLabel.onErrorwrites a validation error message into the single-quoted script stringwindow.status='...'withJavaScriptUtils.escapeQuotes, which escapes'and"but not the backslash:\';alert(1)//) closes that string and runs the rest, and validation messages echo the submitted value through${input}, so those characters are attacker controlled: an XSS on an edit-in-place fieldAjaxListPanel.appendbuilds the same single-quotedWicket.DOM.add(..., '...')string with the same helperescapeQuotesAndBackslash, which doubles the backslash too and is whatLink,ExternalLinkandPopupSettingsalready use for single-quoted script stringsAdded
AjaxEditableLabelErrorMessageEscapeTest: it drives the label into edit mode, submits a value that fails validation with a message beginning\', and asserts the generatedwindow.statusscript keeps the quote inside the string. It fails before the change and passes after.