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

Hitting .well-known/openid-configuration endpoint leads to memory leak #1397

Open
bhosale-ajay opened this issue Sep 10, 2024 · 6 comments
Open

Comments

@bhosale-ajay
Copy link

Which version of Duende IdentityServer are you using?
7.0.6

Which version of .NET are you using?
8.0

Describe the bug
If hit /.well-known/openid-configuration multiple times it leads to memory leak.
Server is configured as follows

.Services
        .AddIdentityServer(options => {
              // set license keys, login, and logout urls etc
        })
       .AddInMemoryCaching()
       .AddConfigurationStore(options =>
        {
              //
        })
        .AddConfigurationStoreCache()
        .AddOperationalStore(options =>
        {
               //
        })
        .AddInMemoryIdentityResources(IdentityConfig.IdentityResources)
        .AddInMemoryApiScopes(IdentityConfig.Scopes)
        .AddInMemoryApiResources(IdentityConfig.Resources)
        .AddInMemoryClients(IdentityConfig.GetClients(fullBaseUrl, snowBaseUrl, snowSecretValue))
        .AddProfileService<CustomProfileService>();

To Reproduce

Steps to reproduce the behavior.

  • Set up identity and fetch the wellknown endpoints.

Expected behavior
No memory leak should be observed.

Kindly let me know if there is any to way cache the output, and why adding AddInMemoryCaching is not sufficient.

@bhosale-ajay
Copy link
Author

Considering everything else is same, if there are two endpoints within same asp .net project

  1. /.well-known/openid-configuration

  2. /ping which just returns a "pong" as response

If 10,000 non-concurrent requests made then mem usage looks like below

image

@AndersAbel
Copy link
Member

Thanks for sharing these details. We have another issue that we are working on that gives timeouts on the discovery endpoint. I wounder if this could actually be the same issue. The memory leakage could be an early indication that something is wrong and then it would eventually freeze.

Could you please check your dependencies according to the notes in #1361 (comment)?

@bhosale-ajay
Copy link
Author

We do not have dependency on "Azure.Extensions.AspNetCore.DataProtection.Keys", But have dependency on "Azure.Identity" (1.12.0) and "Azure.Core" (1.41.0).
Do note that our services run on Docker image mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64

@bhosale-ajay
Copy link
Author

Our configurations are not dynamic. Is it possible to cache the response? The current code prepares /.well-known response by adds lots of entries to a Dictionary<string, object> and then serializing it to Json.

@AndersAbel
Copy link
Member

We do not have dependency on "Azure.Extensions.AspNetCore.DataProtection.Keys", But have dependency on "Azure.Identity" (1.12.0) and "Azure.Core" (1.41.0). Do note that our services run on Docker image mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64

The issue is in Azure.Core version 1.41.0 and prior, could you please try updating Azure.Core to 1.42.0? There is o new Azure.Identity package that forces the dependency to be updated, so you would have to add a direct reference to Azure.Core version 1.42.0 to your project.

@bhosale-ajay
Copy link
Author

Updated to Azure Core 1.43, and no changes to memory consumption. My worry is that memory is not getting released.

image

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

3 participants