7

我在我的一个网站上不断收到这样的错误。它往往在一天中随机发生,在我不希望网站上有用户的夜间时段。

它总是来自不同的IP地址

System.Web.HttpException:无效的视图状态。在 System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) 在 System.Web.UI.Page.DecryptString(String s)

或者

System.Security.Cryptography.CryptographicException:填充无效且无法删除。在 System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast) 在 System.Security.Cryptography.RijndaelManagedTransform.TransformFinalBlock(Byte[ ] inputBuffer, Int32 inputOffset, Int32 inputCount) at System.Security.Cryptography.CryptoStream.FlushFinalBlock() at System.Web.Configuration.MachineKeySection.EncryptOrDecryptData(Boolean fEncrypt, Byte[] buf, Byte[] 修饰符, Int32 start, Int32 长度, IVType ivType, Boolean useValidationSymAlgo) 在 System.Web.UI.Page.DecryptStringWithIV(String s, IVType ivType) 在 System.Web.UI.Page.DecryptString(String s)

它们发生在此页面中:

 ScriptResource.axd?d=VVe1O4rzLSI9hB5nRzBXZxUYTQz6ylDTL9djGR

该站点使用 Ajax 并在 .NET 3 上运行。

这是有人试图入侵该网站吗?网站上的 html 是否有错误?

有任何想法吗?

4

1 回答 1

5

我相信这个错误是由你的 ViewState 使用过期的 ViewStateUserKey 解密引起的。

删除这些错误是一个两步过程:

  1. 确保您拥有特定于站点的验证密钥。您可以使用多种在线资源为您生成一个,例如这个
  2. 确保页面的 ViewStateUserKey 始终一致。从 MSDN 文档:

设置 ViewStateUserKey 属性可以帮助您防止恶意用户对您的应用程序进行攻击。它允许您为各个用户的视图状态变量分配一个标识符,这样他们就不能使用该变量来生成攻击。您可以将此属性设置为任何字符串值,例如用户的会话 ID 或用户的认证名称。

您可以通过自己设置来做到这一点(可能在您的 Page 或基本 Page 的 Init 事件中):

if (Session["ViewStateUserKey"] == null)
{
    Session["ViewStateUserKey"] = new Guid().ToString();
}    
this.Page.ViewStateUserKey = Session["ViewStateUserKey"].ToString();

不,我不认为你被黑客入侵了。

于 2009-06-01T11:55:14.930 回答