2

Checkmarx is flagging these lines as Reflected XSS,Lately I have been doing a lot of research on this but couldn't solve this one can someone point me as to why these are major security threats?

public atest(){

pageParams = ApexPages.currentPage().getParameters();

arId=EncodingUtil.urlDecode(pageParams.get(Aid),ENCODING_SCHEME);
2
  • It is not the problem with class. IT is problem on Visualforce page.
    – Ashwani
    Commented Jun 17, 2015 at 11:25
  • This is what I also think, there's problem with the VF page which has been flagged but I just can't figure out why do they flag lines in the class.
    – user13277
    Commented Jun 17, 2015 at 11:26

1 Answer 1

1

For XSS (Cross Site Scripting )Issue About: Cross-site scripting is a vulnerability that occurs when an attacker can insert unauthorized JavaScript, VBScript, HTML, or other active content into a web page viewed by other users.

This issue raised when controllervariable are being used in JavaScript / JQuery .

Example:

Public class mycontroller{

String myval{get;set;}

Public mycontroller(){

Myval=’Hello Page Loaded’;

}

}

//On page

<Script>

Varscriptvar = ‘{!myval}’;

Alert(scriptvar);

</script>

POSSIBLE SOLUTION:

Varscriptvar = ‘{!JSENCODE(myvar)}’;

You must log in to answer this question.