Hi ,We have developed a gwt application. We foundDOM based cross site scripting issue in our .nocahe.js file. Here is the part of the code mentioned in .js file which is vulnerable. Can any body help me in finding , which type of java code will generate this code? Is there any way to do reverse engineering--r = h(l.location.href)function h(a) {return d >= 0 ? a.substring(0, d + 1) : Mr = h(l.location.href)if (y()) {document.write(lc + r + uc)
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/CX2-nuHcMr0J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
// If the user renamed their script tag, we'll use a fancier method to find
// it. Note that this will not work in the Late Loading case due to the
// document.write call.
if (!thisScript) {
// Put in a marker script element which should be the first script tag after
// the tag we're looking for. To find it, we start at the marker and walk
// backwards until we find a script.
var markerId = "__gwt_marker___MODULE_NAME__";
var markerScript;
$doc.write('<script id="' + markerId + '"></script>');
markerScript = $doc.getElementById(markerId);
thisScript = markerScript && markerScript.previousSibling;
while (thisScript && thisScript.tagName != 'SCRIPT') {
thisScript = thisScript.previousSibling;
}
}
I know exactly what is happening here. The variable "r" has everything that is present in the browser address bar. So a hacker can inject some html in the URL like this http://domain.com/<script></script>. When variable "r" is written to document using document.write(lc + r + uc) the script injected gets written into the HTML document. This is a perfect example of dom based cross site scripting issue. i think GWT has to provide developers a way to avoid this kind of vulnerabilities.
Thomas,I am using GWT 2.0.3 and this is being generated in the *.nocache.js.
Is there any solution to this ? This clearly seems like an XSS vulnerability to me. Have you fixed this in the later version ? If yes then which one ?
function getDirectoryOfFile(path){
var hashIndex = path.lastIndexOf('#');
if (hashIndex == -1) {
hashIndex = path.length;
}
var queryIndex = path.indexOf('?');
if (queryIndex == -1) {
queryIndex = path.length;
}
var slashIndex = path.lastIndexOf('/', Math.min(queryIndex, hashIndex));
return slashIndex >= 0?path.substring(0, slashIndex + 1):'';
}
The “path” parameter to this function comes from document.location.href attribute.
This function is basically finding the last index of “/” in the browser address bar ignoring what is there after “?” and “#”.
From what I know DOM based XSS can occur by injecting scripts after “?” or “#” like this
Server can sanitize this script because the value of the name attribute is sent to the server
http://domain.com/index.html?name=<script>MALICIOUS_CODE</script>
OR
Server cannot sanitize this script because the fragment after “#” is never sent to the server and runs on the browser itself
http://domain.com/index.html#name=<script>MALICIOUS_CODE</script>
nochache.js also has the following code
base = getDirectoryOfFile(document.location.href);
document.write('<script language="javascript" src="' + base + 'scripts/xyz.js"><\/script>');
Our security analysis tool complains that this is an XSS issue since base is not a compile time constant.
--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/WKcB-pDtfgA/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to google-web-tool...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-we...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.