是一个易受sql注入攻击的复选框



我正在c#中开发一个带有复选框的应用程序。基本上,屏幕上有一个用户列表,每个用户名旁边的复选框用于指示是否要为该用户执行操作。

protected void btnMoveToAssigned_Click(Object sender, EventArgs e)
    {
        List<int> idsToAssign = new List<int>();
        foreach (GridViewRow row in gvUnassigned.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox checkbox = row.FindControl("cbToAssign") as CheckBox;
                if (checkbox.Checked)
                {
                    int id;
                    if (Int32.TryParse(gvUnassigned.DataKeys[row.RowIndex].Value.ToString(), out id))
                    {
                        idsToAssign.Add(id);
                    }
                }
            }
        }

我构建了一个userId列表,并将其传递给以下方法:

  public static bool AddApplicationCommandUsers(ORMPortalDataContext dc, ApplicationCommand applicationCOmmand, List<int> userIds)
    {
        List<security_command_xref_Linq> userApplicationCommandList = new List<security_command_xref_Linq>();
        foreach (int userId in userIds)
        {
            security_command_xref_Linq scxL = new security_command_xref_Linq();
            scxL.userID = userId;
            scxL.command = applicationCOmmand.CommandAbbr;
           // scxL.Creator = ApplicationUser.GetCurrentUser().Id;
           // scxL.Created = DateTime.Now;
            userApplicationCommandList.Add(scxL);
        }
        dc.security_command_xref_Linqs.InsertAllOnSubmit(userApplicationCommandList);
        try
        {
            dc.SubmitChanges();
            return true;
        }

我让Burp Suite扫描了一下,结果是:

ctl00%24MainContent%24ctrlManageCommandUsers%24ctrrApplicationCommandUsersAssignment%24gUnassigned%24ctl32%24cbToAssign参数似乎容易受到SQL注入攻击。这个有效载荷,(select*from(select(sleep(20))a)在ctl00%24MainContent%24ctrlManageCommandUsers%24ctrrApplicationCommandUsersAssignment%24gUnassigned%24ctl32%24cbToAssign参数该应用程序花费了22062毫秒以上的时间响应请求,而原始请求的响应时间为62毫秒请求,表明注入的SQL命令导致了时间延迟。

我看不出cbToAssign怎么会有漏洞。谢谢你的回答。

流氓客户端可能只是在发送POST请求,而实际上并没有使用普通的web浏览器发送恶意数据;因此,值可能容易受到攻击,特别是如果您只是按原样使用该值来构建SQL字符串。

最新更新