【问题标题】:Message: CSRF attack detected消息:检测到 CSRF 攻击
【发布时间】:2017-02-16 08:45:48
【问题描述】:

我正在尝试解决这个问题。

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

elb(elb1 和 elb2)都指向负载均衡的相同 ec2 实例(ec2-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)

【问题讨论】:

  • 您似乎是从外部网站发送帖子请求
  • 好像 machineKeys 不匹配。看看这个:docs.kentico.com/k10/configuring-kentico/…你能指定你使用的 HF 版本吗?
  • 最新的 kentico 10
  • 您是否使用自动生成的加密密钥 (machineKey)?按照上一条评论中链接的文档中描述的步骤进行操作后,您能否确认问题仍然存在?
  • 是的,它是自动生成的,但根据上面的评论,我再次生成,我在 web.config 中看到了机器密钥部分

标签: asp.net .net amazon-ec2 cdn kentico


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

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

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

      【讨论】:

        猜你喜欢
        • 2011-10-24
        • 2011-01-13
        • 1970-01-01
        • 2013-05-06
        • 2011-09-30
        • 2020-02-16
        • 2019-04-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多