代码之家  ›  专栏  ›  技术社区  ›  Vicky

Azure AD B2C易受打开重定向攻击?

  •  5
  • Vicky  · 技术社区  · 7 年前

    我正在使用OWIN&OpenId使用Azure AD B2C对我的web应用程序的用户进行身份验证。授权。cs的代码如下:

    app.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
                {
                     MetadataAddress = string.Format(AadInstance, Tenant, policy),
                    AuthenticationType = policy,
                    ClientId = clientId,
                    Authority = authority,
                    PostLogoutRedirectUri = postLogoutRedirectUri,
                    RedirectUri = postLogoutRedirectUri,
                    Notifications = new OpenIdConnectAuthenticationNotifica....
    

    在注销时,它会导致重定向到postLogoutRedirectUrl,如下所示

    https://login.microsoftonline.com/MY_TENANT/oauth2/logout?p=my_policy&post_logout_redirect_uri=https%3A%2F%2Fgoogle.com%2F

    注销后重定向URI存在于门户中的重定向URI中。

    如果我停止浏览器并将地址栏中的注销后uri更改为https%3A%2F%2Fevil。com%2F,即使此url https://evil.com/ 不在允许的重定向uri中。

    为什么广告B2C没有停止重定向?这不容易受到攻击吗?

    2 回复  |  直到 7 年前
        1
  •  5
  •   Parakh    7 年前

    当您使用Azure AD B2C登录时,B2C服务将向“redirect\u uri”(应用程序)发送令牌。由于令牌需要保持安全,B2C服务要求您将其应发送令牌的URL列入白名单。

    当您注销时,B2C服务不会将任何安全信息传输回应用程序。因此,即使用户被重定向到恶意站点,也不会丢失任何安全信息。

        2
  •  2
  •   RMD    5 年前

    如果在注销请求中作为参数传入了有效的ID令牌,则可以更改此行为以强制Azure AD B2C仅处理注销重新定向。要使B2C自动包含ID令牌并检查其存在,只需在Azure门户中编辑您的登录/注册策略,即:

    enter image description here

    或者,如果您使用的是自定义策略,则可以添加 SingleSignOn 元素到 UserJourneyBehaviors 节,并设置 EnforceIdTokenHintOnLogout 为真,即:

    <UserJourneyBehaviors>
         <SingleSignOn Scope="Tenant" EnforceIdTokenHintOnLogout="true" />
    
    </UserJourneyBehaviors>