消息:检测到CSRF攻击



我正在尝试解决此问题。

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

指向负载平衡(EC2-A和EC2-B)的EC2实例

ELB(ELB1和ELB2)

我可以登录从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)

CSRF在Kentico中使用MachineKey.unprotect()方法验证令牌,因此所有服务器都必须使用相同的加密密钥。

有关如何实现此行为的更多详细信息,请参见文档。

这对我有用:

在Web.config

的AppSettings中添加以下键
<add key="CMSEnableCsrfProtection" value="false" />

其固定,我生成了机器密钥,然后在两个EC2实例中放置了相同的机器键。因此,这些问题已解决

neshi是正确的,您需要确保页面上的邮政请求来自同一源,否则您几乎可以满足跨站点脚本的定义。

整体设置非常复杂,但是您仍然需要确保CSRF cookie中的安全令牌与CMSpage在LOAD上生成的令牌相同,我不确定这些重定向和负载转移是否能够做到这一点。保持会话足够粘。

一般描述是:https://docs.kentico.com/k10/securing-websites/developing-secure-websites/cross-site-request-forgery-csrf-xsrf-xsrf

最新更新