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

Client Secret Value is Logged in Plaintext when loading credential #3201

Open
MarcelMichau opened this issue Jan 15, 2025 · 0 comments
Open

Comments

@MarcelMichau
Copy link

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

3.5.0

Web app

Not Applicable

Web API

Protected web APIs call downstream web APIs

Token cache serialization

Not Applicable

Description

Hi

Looking at the logs generated by MS.Id.Web in Application Insights, it seems that the value of the Client Secret is logged in plaintext when building a confidential client using a client secret.

Log Message (note starting characters):

Image

App Registration secrets:

Image

This can be confirmed as a real secret as we were able to copy the secret value from the ClientSecret__XXX log message & use it to request a token.

From what I can gather, this logging was introduced as part of this commit.

Reproduction steps

  1. Configure an app with AzureAd:ClientSecret set
  2. Use IAuthorizationHeaderProvider.CreateAuthorizationHeaderForUserAsync() when calling a protected downstream API
  3. Observe logging output when token is requested

Error message

No response

Id Web logs

No response

Relevant code snippets

internal class ApiService(IAuthorizationHeaderProvider provider)
{
    private async Task<string> GetAuthHeaderForUserAsync(CancellationToken cancellationToken)
    {
        try
        {
            var apiScopes = "...";

            var authHeader =
                await provider.CreateAuthorizationHeaderForUserAsync(
                    apiScopes,
                    cancellationToken: cancellationToken);

            return authHeader;
        }
        catch (Exception ex)
        {
            logger.LogError(ex, "An error occurred while acquiring a token for a user from Entra ID");
            throw;
        }
    }
}

Regression

3.1.0

Expected behavior

Client Secret should not be included in the log message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant