-
Notifications
You must be signed in to change notification settings - Fork 724
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
[PPP-5370][Update XSS Vulnerabilities] #5758
base: XSS-PPP-5370
Are you sure you want to change the base?
Changes from 2 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 |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
* Change Date: 2028-08-13 | ||
******************************************************************************/ | ||
|
||
define(['common-ui/util/xss'], | ||
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. AFAICT, this file is not referenced anywhere. It appears to demonstrate use of some Google Maps component (GeoCoder) via Pentaho XActions. XActions are essentially deprecated. Unless you can find a reference to it, solving the XSS issue by removing the file. |
||
function(xssUtil) { | ||
|
||
var map; | ||
var redicon; | ||
var yellowicon; | ||
|
@@ -86,7 +89,7 @@ greenicon = icon; | |
|
||
function updateProductMix( content ) { | ||
document.getElementById( 'details-div' ).style.display='block'; | ||
document.getElementById( 'details-cell1' ).innerHTML=content; | ||
xssUtil.setHtml(document.getElementById('details-cell1'), content); | ||
pentahoAction( "steel-wheels", "google", "customer_details.xaction", | ||
new Array( new Array( "customer", currentRecord[7] ) ), | ||
'updateHistory' | ||
|
@@ -95,7 +98,7 @@ greenicon = icon; | |
|
||
function updateHistory( content ) { | ||
document.getElementById( 'details-div' ).style.display='block'; | ||
document.getElementById( 'details-cell2' ).innerHTML=content; | ||
xssUtil.setHtml(document.getElementById('details-cell2'), content); | ||
} | ||
|
||
function showAddress(address, name, custNum, value, selected) { | ||
|
@@ -193,4 +196,4 @@ function showAddress(address, name, custNum, value, selected) { | |
} | ||
|
||
|
||
} | ||
} }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ | |
* Change Date: 2028-08-13 | ||
******************************************************************************/ | ||
|
||
define(['common-ui/util/xss'], | ||
function(xssUtil) { | ||
|
||
function runInBackground( url, target ) | ||
{ | ||
var response = confirm( "Info: Reports that prompt for parameters are not supported with this feature." | ||
|
@@ -20,11 +23,11 @@ function runInBackground( url, target ) | |
url = url + "&background=true"; | ||
if ( target.toLowerCase().indexOf( 'new' ) >= 0 ) | ||
{ | ||
var targetWin = window.open( url ); | ||
var targetWin = window.open(xssUtil.sanitizeHtml(url), 'noopener,noreferrer'); | ||
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. This file is not prepared to be a RequireJS module, and, as such, you should use the global version of the XSS utility library, available under However, the library does not currently offer any mechanism to validate URLs. AFAIR (but please confirm!), URL protection against XSS consists of ensuring that the URL does not have a I am not sure what's the best source to base our implementation of, in this regard. Some pointers: 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. Regarding this, I think we might be able to use DOMPurify to this effect. In the DOMPlurify playground page, https://cure53.de/purify, try out the following sample Dirty HTML: <a href='
javas cript:alert(1)'>I am a dolphin!</a>
<a href='http://www.google.com'>I am a dolphin!</a> It cleans it as: <a>I am a dolphin!</a>
<a href="http://www.google.com">I am a dolphin!</a> As such, we should be able to implement 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. Or, we can just base our implementation on their own, from:
Which seems like somewhat concise regexp code that we can mimic. 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. Another aspect which must be considered is whether the suggested |
||
} | ||
else | ||
{ | ||
window.location = url; | ||
window.location = xssUtil.sanitizeHtml(url); | ||
} | ||
} | ||
return undefined; // forces current page to remain unchanged when target=new | ||
|
@@ -113,4 +116,4 @@ function showShareDialog( event, solution, path, filename ) | |
var position = UIUtil.getScrollCoords( { left: event.clientX, top: event.clientY } ); | ||
shareDialog.setPosition( { left: position.left+ "px", top: position.top + "px" } ); | ||
shareDialog.show(); | ||
} | ||
} }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
|
||
// used in getParameters and doClearIgnoreFields to ignore specific hidden fields | ||
|
||
define(['common-ui/util/xss'], | ||
function(xssUtil) { | ||
|
||
var pentaho_ignoreFields = new Array(); | ||
var pentaho_ignoreIndexOfFields = new Array(); | ||
var pentaho_optionalParams = new Array(); | ||
|
@@ -360,7 +363,7 @@ function executeAction (target, submitUrl) { | |
// convert characters from entities like ı to display characters (HTML) | ||
function convertHtmlEntitiesToCharacters(theStr) { | ||
var newDiv = document.createElement(newDiv); | ||
newDiv.innerHTML = theStr; | ||
xssUtil.setHtml(newDiv, theStr); | ||
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. In this file, which is not prepared to be a RequireJS module, you should use the global version of the method: |
||
return newDiv.innerHTML; | ||
} | ||
|
||
|
@@ -488,3 +491,4 @@ function closeMantleTab(){ | |
alert("error closing tab: "+e); | ||
} | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,9 @@ modified BSD license. For more information on Dojo licensing, see: | |
http://dojotoolkit.org/community/licensing.shtml | ||
*/ | ||
|
||
define(['common-ui/util/xss'], | ||
function(xssUtil) { | ||
|
||
dojo.provide("dojo.html.util"); | ||
dojo.require("dojo.html.layout"); | ||
|
||
|
@@ -210,7 +213,7 @@ dojo.html.createNodesFromText = function(/* string */txt, /* boolean? */trim){ | |
txt = "<table>" + txt + "</table>"; | ||
tableType = "section"; | ||
} | ||
tn.innerHTML = txt; | ||
xssUtil.setHtml(tn, txt); | ||
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. In this file, which is not prepared to be a RequireJS module, you should use the global version of the method: |
||
if(tn["normalize"]){ | ||
tn.normalize(); | ||
} | ||
|
@@ -481,4 +484,4 @@ dojo.html.scrollIntoView = function(/* HTMLElement */node){ | |
parent.scrollTop -= (parent.scrollTop - node.offsetTop); | ||
} | ||
} | ||
} | ||
} }); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,9 @@ over a cell (to make it easier to determine what cell you're over). Added commen | |
in the style sheet, to make it more clear what the different style elements are for. | ||
*/ | ||
|
||
define(['common-ui/util/xss'], | ||
function(xssUtil) { | ||
|
||
var datePickerDivID = "datepicker"; | ||
var iFrameDivID = "datepickeriframe"; | ||
|
||
|
@@ -294,8 +297,8 @@ function refreshDatePicker(dateFieldName, year, month, day) | |
|
||
// and finally, close the table | ||
html += xTABLE; | ||
document.getElementById(datePickerDivID).innerHTML = html; | ||
|
||
xssUtil.setHtml(document.getElementById(datePickerDivID), html); | ||
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. This file is not prepared to be a RequireJS module, and, as such, you should use the global version of the XSS utility library, available under As you can see in the code above, there are multiple instances of event handler attributes (e.g. The arguments The argument Then, in this same line, mark the setting of unsafe HTML using Note that method |
||
// add an "iFrame shim" to allow the datepicker to display above selection lists | ||
adjustiFrame(); | ||
} | ||
|
@@ -530,4 +533,6 @@ function isValidName(name){ | |
function reservedCharListForDisplay( separatorString ) { | ||
//ToDo: Fix this | ||
return "/ \ :"; | ||
} | ||
} | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,9 @@ | |
|
||
/* CCP Functions */ | ||
|
||
define(['common-ui/util/xss'], | ||
function(xssUtil) { | ||
|
||
var CCP = CCP || {}; | ||
|
||
/* Utility function to get a method from a different window / frame */ | ||
|
@@ -50,7 +53,9 @@ CCP.liveChat = function(){ | |
pucOpenTab( name, title, url ); | ||
} | ||
else { | ||
window.open( url ); | ||
/* noopener and noreferrer: These attributes mitigate the risk of tabnabbing and | ||
prevent the new page from accessing the original window’s properties. */ | ||
window.open(xssUtil.sanitizeHtml(url),'noopener,noreferrer'); | ||
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. This file is not prepared to be a RequireJS module, and, as such, you should use the global version of the XSS utility library, available under Please, use the new method suggested above, |
||
} | ||
} | ||
|
||
|
@@ -68,3 +73,4 @@ CCP.getForumFeed = function(divId){ | |
error: function() { throw new Error("jQuery RSS: url don't link to RSS-Feed") } | ||
}); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,9 @@ | |
define([ | ||
"common-ui/util/ContextProvider", | ||
"common-ui/util/BootstrappedTabLoader", | ||
"common-ui/util/HandlebarsCompiler" | ||
], function (ContextProvider, BootstrappedTabLoader, HandlebarsCompiler) { | ||
"common-ui/util/HandlebarsCompiler", | ||
"common-ui/util/xss" | ||
], function (ContextProvider, BootstrappedTabLoader, HandlebarsCompiler, xssUtil) { | ||
|
||
var brightCoveVideoTemplate = | ||
'<iframe src="https://players.brightcove.net/4680021553001/default_default/index.html?videoId={{videoId}}&autoplay=true"' + | ||
|
@@ -206,7 +207,9 @@ define([ | |
|
||
launchLink.unbind("click"); | ||
launchLink.bind("click", function () { | ||
window.open(href, "_blank"); | ||
/* noopener and noreferrer: These attributes mitigate the risk of tabnabbing and | ||
prevent the new page from accessing the original window’s properties. */ | ||
window.open(xssUtil.sanitizeHtml(href), "_blank", 'noopener,noreferrer'); | ||
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. Please, use the new method suggested above, |
||
}); | ||
} | ||
|
||
|
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.
In this file, which is not prepared to be a RequireJS module, you should use the global version of the method:
pho.util.xss.setHtml(., .)
(and undo the proposed RequireJS modifications).