
NXuan636559 (Community Member) asked a question.
I have coded like that in asp.net webform
Session.Remove("linkdoc");
var strWebDavJs = HttpUtility.JavaScriptStringEncode(strWebDav);
var generateLinkDialogJs = HttpUtility.JavaScriptStringEncode(((_settingPageInPopup != null) ? _settingPageInPopup.GenerateLinkDialog : true).ToString());
var isShowSuccussfulOrFailedJs = HttpUtility.JavaScriptStringEncode(IsShowSuccussfulOrFailed);
var isDocOrDestCheckedJs = HttpUtility.JavaScriptStringEncode((rdoDocumentInfile.Checked || IsDestinationFileChecked()) ? "true" : "");
var safeScript = string.Format(
"CloseAndSendLinkToParent(\"{0}\", \"{1}\", \"{2}\", \"{3}\");",
strWebDavJs,
generateLinkDialogJs,
isShowSuccussfulOrFailedJs,
isDocOrDestCheckedJs
);
ltLinkDoc.Text = "<script>$(window).bind(\"load\", function(){ setTimeout(function() { " + safeScript + " }, 100); });</script>";
BUT veracode pointed that the code in line: ltLinkDoc.Text = "$(window).bind("load", function(){ setTimeout(function() { " + safeScript + " }, 100); });"; has problem with XSS CWE 80.
In my code, I already encode all necessary things.
Can you help me for this? Why veracode said that my code has problem XSS CWE 80 and how I fix the problem?
Thank you very much for your support.
Yours.
Nghia
.png)
Hi @NXuan636559 (Community Member) -
We probably need more information here. While it looks like you're handling escaping/encoding the data, it would be better to discuss the implementation a bit further via consultation call or via Support ticket. It's possible that it has to do with $(window) but hard to tell without looking at a scan.