【发布时间】:2021-05-01 09:01:27
【问题描述】:
目前,我正在为一个 Winforms 项目工作。
当我通过 CheckMarx 扫描我的 Winforms 应用程序时,我遇到了多个 Reflected_xss_all_clients 漏洞。
我知道 Winforms 中没有脚本。 XSS 是一种网络威胁,但可能有一些方法可以在扫描期间修复这些威胁。
这是错误代码第 1 节:
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 漏洞。
这是错误代码第 2 部分:
/// <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_clientsvulnerabilities。
这里是第 3 节的错误代码:
/// <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, true, null, false); 行正在为txtDiscreteValue.Text 抛出 Reflected_xss_all_clients 漏洞
如果可能,请提出任何补救方法。
【问题讨论】:
-
我担心 Checkmarx 正在将您的项目视为 WebApp,因为文件的扩展名来自 Web 系列。你有这样的文件吗?
-
忽略它。
-
@baruchiro,我没有这样的文件。除了忽略,还有什么方法可以处理吗?
-
@user14285851 我同意 baruchiro 的观点,您的安全团队应该选择一个 Checkmarx 预设,该预设不包含明显不适用于您的 Winforms 应用程序的 Web 相关漏洞。也可以通过预设管理器checkmarx.atlassian.net/wiki/spaces/KC/pages/49250315/…创建新预设
-
@RomanCanlas 不要 Checkmarx 预设适用于整个解决方案,而不是单个项目?如果我的解决方案同时包含 Web 和 Windows 窗体项目,我是 SOL 吗?
标签: c# winforms security xss checkmarx