Skip to content

Commit 4191d28

Browse files
author
Jessica Wang
committed
cloudstack 3.0 UI - XSS - detailView in Edit mode - fix it to show original value instead of HTML-encoding value.
1 parent 504e90b commit 4191d28

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

‎ui/scripts/ui/utils.js‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
};
5757

5858
/**
59-
* Sanitize user input -- shortcut _s
59+
* Sanitize user input (HTML Encoding) -- shortcut _s
6060
*
6161
* Strip unwanted characters from user-based input
6262
*/
@@ -76,12 +76,25 @@
7676
else if(typeof(value) == null || typeof(value) == "undefined") {
7777
return '';
7878
}
79-
79+
8080
var sanitized = value
8181
.replace(/&/g, "&")
8282
.replace(/</g, "&lt;")
8383
.replace(/>/g, "&gt;");
8484

8585
return sanitized;
8686
};
87+
88+
/**
89+
* Reverse sanitization (HTML Decoding)
90+
*/
91+
cloudStack.sanitizeReverse = function(value) {
92+
var reversedValue = value
93+
.replace(/&amp;/g, "&")
94+
.replace(/&lt;/g, "<")
95+
.replace(/&gt;/g, ">");
96+
97+
return reversedValue;
98+
};
99+
87100
})(jQuery, cloudStack);

‎ui/scripts/ui/widgets/detailView.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@
391391
// Turn into form field
392392
var selectData = $value.data('detail-view-editable-select');
393393
var isBoolean = $value.data('detail-view-editable-boolean');
394-
var data = !isBoolean ? $value.html() : $value.data('detail-view-boolean-value');
394+
var data = !isBoolean ? cloudStack.sanitizeReverse($value.html()) : $value.data('detail-view-boolean-value');
395395

396396
$value.html('');
397397

0 commit comments

Comments
 (0)