0
코드 부분이 저장된 XSS에 취약합니다. 아래는 코드입니다.Asp.net에서 저장된 교차 사이트 스크립팅 취약점을 해결하는 방법 C#
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDeleting="GridView1_OnRowDeleting" OnPageIndexChanging="GridView1_PageIndexChanging" Width ="1000px" class="grid">
<Columns>
<asp:TemplateField HeaderText="User Name">
<ItemTemplate>
<asp:Label ID="lbl_Name" runat="server" Text='<%#Eval("Uname") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txt_Name" runat="server" Text='<%#Eval("Uname") %>'></asp:TextBox> //this is the line vulnerable to XSS
</EditItemTemplate>
</asp:TemplateField> </columns>
</asp:GridView>
코드 오전 XSS에 익숙하지
DataTable dt = new DataTable();
try
{
SqlConnection con = new SqlConnection(conn);
con.Open();
SqlDataAdapter adapt = new SqlDataAdapter("Select Uid,Uname,Utype,Uemail,ClientName,ProjectName,Ulog from usrtable where ClientName='" + clientname + "' and Utype='Admin' or ClientName='" + clientname + "'and Utype='Normal'", con);
**adapt.Fill(dt);**//this is again vulnerable
con.Close();
}
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
뒤에. 나는 많은 문서들을 조사했다. 데이터를 인코딩하도록 요청합니다. 하지만 제 경우에는 어떻게해야합니까? GV에는 많은 라벨과 텍스트 상자가 항목 템플릿으로 있습니다. 이를 사용하여 테이블 행을 갱신하십시오.
에 태그 아래에 확인하십시오. – Webbanditten
나는 편집했다. 소스 코드를 확인하십시오. – Aswini