Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use Msal localStorage option on Azure Frontdoor (with WAF) hosted website #7537

Open
2 tasks
yurnih opened this issue Jan 28, 2025 · 2 comments
Open
2 tasks
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Attention 👋 Awaiting response from the MSAL.js team public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.

Comments

@yurnih
Copy link

yurnih commented Jan 28, 2025

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

4.0.2

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

4.0.2

Public or Confidential Client?

Public

Description

When upgrading to MSAL v4 and using localStorage as the backend for caching, MSAL creates a session cookie msal.cache.encryption as described in docs. This cookie stores a JSON string with the following format: {"id":"...uuid...","key":"qQfZ7...oWmXE"}.The contents of this cookie triggers web application firewall rules for sql-injections.

Error Message

No response

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

  • Sent
  • Pending

MSAL Configuration

{
  auth: {
    clientId: msal.clientId,
    authority: `https://login.microsoftonline.com/${msal.tenantId}`,
    redirectUri: '/account/login',
    navigateToLoginRequestUrl: true,
  },
  cache: {
    cacheLocation: BrowserCacheLocation.LocalStorage,
  }
}

Relevant Code Snippets

private tryMsalLogin(allowRedirect: boolean = true, background: boolean = false) {
  if (this.msal.instance.getAllAccounts().length === 0) {
    if (!allowRedirect) return;
    return this.loginRedirect();
  }
  this.msal
    .acquireTokenSilent({
      scopes: this.env.appScope,
      account: this.msal.instance.getAllAccounts()[0],
    })
    .subscribe({
      next: (value) => this.setToken(value.accessToken, background),
      error: (_) => {
        if (!allowRedirect) return;
        this.loginRedirect();
      },
    });
}

private loginRedirect(): void {
  this.msal.loginRedirect({
    scopes: ['openid', 'email', 'offline_access', ...this.env.appScope],
  });
}

Reproduction Steps

  1. Create an application with MSAL v4
  2. Deploy behind Azure Front Door with web application firewall rules turned on
  3. Login in application
  4. After login is finish and local storage / cookies are set all following requests on the domain are blocked (Detects MySQL comment-/space-obfuscated injections and backtick termination / Detects basic SQL authentication bypass attempts / Detects classic SQL injection probings)

Expected Behavior

Similar as MSAL v3

Identity Provider

Entra ID (formerly Azure AD) / MSA

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari, Other

Regression

@azure/msal-browser ^3

@yurnih yurnih added bug-unconfirmed A reported bug that needs to be investigated and confirmed question Customer is asking for a clarification, use case or information. labels Jan 28, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Jan 28, 2025
@github-actions github-actions bot added msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package public-client Issues regarding PublicClientApplications labels Jan 28, 2025
@plamber
Copy link

plamber commented Feb 13, 2025

Hello,
I can confirm that the issue also occurs on our end. Our SPA applications are hosted behind Azure Front Door, and SQL rules 942370, 942200, and 942000 are being triggered, causing the site to stop serving content.

Image

We temporarily disabled the prevention mode in our WAF policies to better understand how to create a proper exclusion rule. Ideally, this should be addressed within the library itself to prevent these false positives from occurring.

We appreciate your support in resolving this. Can maybe @tnorling help us out?

@yurnih: Have you already implemented a workaround for this?

Best regards,
Patrick

@adrianmartinm
Copy link

I'm getting blocked too if I use LocalStorage, any news on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-unconfirmed A reported bug that needs to be investigated and confirmed msal-angular Related to @azure/msal-angular package msal-browser Related to msal-browser package Needs: Attention 👋 Awaiting response from the MSAL.js team public-client Issues regarding PublicClientApplications question Customer is asking for a clarification, use case or information.
Projects
None yet
Development

No branches or pull requests

3 participants