Asp.net 消息:检测到CSRF攻击

Asp.net 消息:检测到CSRF攻击,asp.net,.net,amazon-ec2,cdn,kentico,Asp.net,.net,Amazon Ec2,Cdn,Kentico,我正在努力解决这个问题 我有两个cdn url abc.com指向elb1,def.com指向elb2 elb elb1和elb2都指向相同的ec2实例,即负载平衡DEC2-A和ec2-B 我可以登录到从abc.com导航的服务器 但我无法登录到从def.com导航的服务器 def.com登录时出现以下错误 因为两个dns都指向相同的EC2。Web.config文件是相同的 Message: CSRF attack detected. Exception type: CMS.Protectio

我正在努力解决这个问题

我有两个cdn url abc.com指向elb1,def.com指向elb2

elb elb1和elb2都指向相同的ec2实例,即负载平衡DEC2-A和ec2-B

我可以登录到从abc.com导航的服务器 但我无法登录到从def.com导航的服务器

def.com登录时出现以下错误

因为两个dns都指向相同的EC2。Web.config文件是相同的

Message: CSRF attack detected.

Exception type: CMS.Protection.Web.UI.CsrfException
Stack trace: 
at CMS.Protection.Web.UI.CsrfProtection.ThrowCsrfException(Exception innerException)
at CMS.Protection.Web.UI.CsrfProtection.OnPostMapRequestHandlerExecute(Object sender, EventArgs eventArgs)
at CMS.Base.AbstractHandler.CallEventHandler[TArgs](EventHandler`1 h, TArgs e)
at CMS.Base.AbstractHandler.Raise[TArgs](String partName, List`1 list, TArgs e, Boolean important)
at CMS.Base.SimpleHandler`2.RaiseExecute(TArgs e)
at CMS.Base.SimpleHandler`2.RaiseExecute(TArgs e)
at CMS.Base.SimpleHandler`2.StartEvent(TArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Message: Error occurred during a cryptographic operation.

Exception type: System.Security.Cryptography.CryptographicException
Stack trace: 
at System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.HomogenizeErrors(Func`2 func, Byte[] input)
at CMS.Protection.Web.UI.CsrfProtection.OnPostMapRequestHandlerExecute(Object sender, EventArgs eventArgs)

Neshi是正确的,您需要确保页面上的post请求来自同一个源,否则您几乎可以完成跨站点脚本的定义

总体设置相当复杂,但是您仍然需要确保CSRF cookie中的安全令牌与CMSPage加载时生成的令牌相同,我不确定这些重定向和加载传输是否能够做到这一点,并保持会话足够的粘性

一般说明载于:

我生成了固定的机器密钥,并在两个ec2实例中放置了相同的机器密钥。因此,问题已经解决

Kentico中的CSRF保护使用MachineKey.Unprotect方法验证令牌,因此所有服务器都必须使用相同的加密密钥


有关如何实现此行为的更多详细信息,请参阅

看起来您从外部网站发送post请求似乎机器键不匹配。看看这个:你能指定你使用的是什么HF版本吗?它的kentico 10可以让你使用自动生成的加密密钥machineKey吗?在遵循前面注释中链接的文档中描述的步骤后,您能否确认问题仍然存在?是的,它是自动生成的,但根据上面的注释,我再次生成,我在web.config中看到了机器密钥部分