Why label x = txtName.Text; comes under XSS attack and what is the prevention here?

前端 未结 2 920
广开言路
广开言路 2021-02-10 13:04

I have the following code:

label x = txtName.Text; 

When the security team analyzed the dll they said it was possible to perform an XSS attack

2条回答
  •  我寻月下人不归
    2021-02-10 13:23

    I don't think label x = txtName.Text; is valid C#. I assume you meant x.Text = txtName.Text; where x is the ID of a Label.

    This is a problem because what if I entered in the Textbox? My input could be rendered to the page and executed as script. That simple of an example may not work, but there are many tricks to getting XSS to work.

    You can fix this by encoding the input before displaying on the page, and I would recommend Microsoft AntiXSS for that task. I also agree with the comment that you should ask your security team how to fix it.

提交回复
热议问题