correcting the XSS test, commenting two failing patterns, to be reviewed by @rugk

This commit is contained in:
El RIDO 2017-11-22 07:03:29 +01:00
parent 233bd65b00
commit 2d00202b42
No known key found for this signature in database
GPG Key ID: 0F5C940A6BD81F92
4 changed files with 18 additions and 7 deletions

View File

@ -12,6 +12,7 @@
*/ */
/** global: Base64 */ /** global: Base64 */
/** global: DOMPurify */
/** global: FileReader */ /** global: FileReader */
/** global: RawDeflate */ /** global: RawDeflate */
/** global: history */ /** global: history */
@ -1777,7 +1778,6 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
}); });
// let showdown convert the HTML and sanitize HTML *afterwards*! // let showdown convert the HTML and sanitize HTML *afterwards*!
$plainText.html( $plainText.html(
/** global: DOMPurify */
DOMPurify.sanitize(converter.makeHtml(text), {SAFE_FOR_JQUERY: true}) DOMPurify.sanitize(converter.makeHtml(text), {SAFE_FOR_JQUERY: true})
); );
// add table classes from bootstrap css // add table classes from bootstrap css
@ -1800,6 +1800,16 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// convert URLs to clickable links // convert URLs to clickable links
Helper.urls2links($plainText); Helper.urls2links($plainText);
Helper.urls2links($prettyPrint); Helper.urls2links($prettyPrint);
$plainText.html(
DOMPurify.sanitize(
$plainText.html(), {SAFE_FOR_JQUERY: true}
)
);
$prettyPrint.html(
DOMPurify.sanitize(
$prettyPrint.html(), {SAFE_FOR_JQUERY: true}
)
);
$prettyPrint.css('white-space', 'pre-wrap'); $prettyPrint.css('white-space', 'pre-wrap');
$prettyPrint.css('word-break', 'normal'); $prettyPrint.css('word-break', 'normal');

View File

@ -1451,8 +1451,9 @@ describe('PasteViewer', function () {
// https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
jsc.elements([ jsc.elements([
'<PLAINTEXT>', '<PLAINTEXT>',
'\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";', // @TODO these two pass, but aren't evaluated in this context - do they need to be sanitized, too?
'alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--', // '\';alert(String.fromCharCode(88,83,83))//\';alert(String.fromCharCode(88,83,83))//";',
// 'alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--',
'></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>', '></SCRIPT>">\'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT>',
'\'\';!--"<XSS>=&{()}', '\'\';!--"<XSS>=&{()}',
'<SCRIPT SRC=http://example.com/xss.js></SCRIPT>', '<SCRIPT SRC=http://example.com/xss.js></SCRIPT>',
@ -1466,7 +1467,7 @@ describe('PasteViewer', function () {
'<a onmouseover=alert(document.cookie)>xxs link</a>', '<a onmouseover=alert(document.cookie)>xxs link</a>',
'<IMG """><SCRIPT>alert("XSS")</SCRIPT>">', '<IMG """><SCRIPT>alert("XSS")</SCRIPT>">',
'<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>' '<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>'
// the list goes on… // @TODO the list goes on…
]), ]),
'string', 'string',
function (format, prefix, xss, suffix) { function (format, prefix, xss, suffix) {
@ -1482,7 +1483,7 @@ describe('PasteViewer', function () {
$.PrivateBin.PasteViewer.setFormat(format); $.PrivateBin.PasteViewer.setFormat(format);
$.PrivateBin.PasteViewer.setText(text); $.PrivateBin.PasteViewer.setText(text);
$.PrivateBin.PasteViewer.run(); $.PrivateBin.PasteViewer.run();
var result = $('body').html().indexOf(xss) !== -1; var result = $('body').html().indexOf(xss) === -1;
clean(); clean();
return result; return result;
} }

View File

@ -70,7 +70,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-zbiQgBDsSGOdieFoYhNqu7fnj+GpeuQRXQcUSg1U9lP3HlHUY6Lp1w/Hl/LK2y/RGjkoV3MRcjU/BQVGoZxKlw==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-VEBWEPLKeJ5Lv0T67Nal1g4NxeoOf2nlE20rF3uOq8fpBb/bKLR9wPxcl8mTjEiA+GAEQv0s4Fh5iT8wee1Nbw==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->

View File

@ -48,7 +48,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-zbiQgBDsSGOdieFoYhNqu7fnj+GpeuQRXQcUSg1U9lP3HlHUY6Lp1w/Hl/LK2y/RGjkoV3MRcjU/BQVGoZxKlw==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-VEBWEPLKeJ5Lv0T67Nal1g4NxeoOf2nlE20rF3uOq8fpBb/bKLR9wPxcl8mTjEiA+GAEQv0s4Fh5iT8wee1Nbw==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->