如何解决如何避免 Winforms c# 中的 Reflected_xss_all_clients 漏洞
目前,我正在为一个 Winforms 项目工作。
当我通过 CheckMarx 扫描我的 Winforms 应用程序时,我发现了多个 Reflected_xss_all_clients
漏洞。
我知道 Winforms 中没有脚本。 XSS
是一种网络威胁,但在扫描过程中可能会有一些方法来修复这些威胁。
private void UpdatePreviewValue()
{
try
{
// Set the preview value
if (txtFieldValue.Text != string.Empty)
{
// Show the preview value
lblPreview.Text = "(" + txtFieldValue.Text + ")";
}
else
{
// Show that there is no field value
lblPreview.Text = Properties.Resources.Std_Txt_Fld_NoFieldValue;
}
}
catch (Exception ex)
{
frmErrorHandler.ShowDataError(Properties.ErrorStrings.ErrorTitle_SrcFldCtlInteger_UpdatePreviewValue,DataErrorImageConstants.Exclamation,ex);
}
}
在上面的代码部分,行lblPreview.Text = "(" + txtFieldValue.Text + ")";
抛出了Reflected_xss_all_clients
漏洞。
/// <summary>
/// Method to copy an existing node for moving inside a grid
/// </summary>
/// <param name="rowTocopy">GridRow to copy</param>
/// <returns>GridRow</returns>
private GridRow copyGridRow(GridRow rowTocopy)
{
GridRow newRow = gridCategories.NewRow();
newRow.Tag = rowTocopy.Tag;
newRow.Cells[0].Text = rowTocopy.Cells[0].Text;
newRow.Cells[0].Image = rowTocopy.Cells[0].Image;
newRow.Cells[1].Text = rowTocopy.Cells[1].Text;
if (rowTocopy.HasRows)
{
foreach (GridRow nestedRow in rowTocopy.nestedRows)
{
newRow.nestedRows.Add(copyGridRow(nestedRow));
}
}
return newRow;
}
在上面的代码部分中,行 newRow.Cells[0].Text = rowTocopy.Cells[0].Text;
和 newRow.Cells[1].Text = rowTocopy.Cells[1].Text;
抛出了 Reflected_xss_all_clients
漏洞。
/// <summary>
/// Method used to add a new discrete value to the listview
/// </summary>
private void AdddiscreteValue()
{
// check we have an entry to add
if (txtdiscreteValue.Text != "")
{
SetdiscreteValue(txtdiscreteValue.Text,true,null,false);
}
}
在上面的代码部分,SetdiscreteValue(txtdiscreteValue.Text,false);
行抛出了 txtdiscreteValue.Text
的 Reflected_xss_all_clients 漏洞
如果可能,请提出任何补救方法。
解决方法
Checkmarx 将跟随字符串从输入到使用。有时它会将一个未填充的变量标识为 XSS 传输到前端。
至于我,我总是忽略 Checkmarx 报告的 XSS。也许您可以在使用字符串变量之前使用填充函数。像这样
txtFieldValue.Text=cleanXSS(txtFieldValue.Text)
至于cleanXSS(),google之后可以找到很多例子。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。