部分类 Checkmarx 漏洞中的“仅客户端验证” - 修复

问题描述

通过 Checkmarx 工具扫描代码库,我得到“仅客户端验证”漏洞,在使用部分类的任何地方都会引发这一点。

第 1 点:

Imports System.Data
Imports System.Data.sqlClient
Imports System.Security.Cryptography
Partial Class Frm_ChangePwd               //Checkmarx points to this line as vulnerability
    Inherits System.Web.UI.Page

第 2 点:

Imports System.Data
Imports System.Data.sqlClient
Imports System.Security.Cryptography
Partial Class Frm_changepassword        //Checkmarx points to this line as vulnerability
    Inherits System.Web.UI.Page

Checkmarx 还给出了这个细节“没有找到服务器端验证[代码文件路径]\Frm_changepassword.aspx.vb 文件,仅使用客户端验证是不够的,因为它很容易绕过”

Checkmarx 会在使用分部类时提出这个问题,但我无法理解我到底应该做什么来纠正这一点。

解决方法

出现这一发现是因为 Checkmarx 在您的代码中没有看到任何服务器端验证器。具体来说,它查找 Page.IsValid 属性。我建议使用此属性添加验证检查:

Page.Validate()

If Page.IsValid = True Then
....

Else
....
End If