NXuan636559 (Community Member) asked a question.

How to fix CWE 80 Veracode for ltLinkDoc.Text in asp.net

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


  • SamHouston (Veracode)

    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. 

    Expand Post

Topics (4)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.