We have an ASP.NET core 2.2 web application exposing some web api controllers. Our application does not have any kind of authentication mechanism, all the exposed endpoints can be called by an anonymous user.
When we host the application under IIS we get three strange warning messages at the application startup. These are the logs we get:
- Using an in-memory repository. Keys will not be persisted to storage.
- Neither user profile nor HKLM registry available. Using an ephemeral key repository. Protected data will be unavailable when application exits.
- No XML encryptor configured. Key {GUID} may be persisted to storage in unencrypted form.
All these logs have Microsoft.AspNetCore.DataProtection as the log context and are written by the ASP.NET core framework internals.
The meaning of these logs seems quite clear to me: there is a "key" (whatever it means) that will be persisted in-memory because no registry storage has been provided (and, of course, it will be lost when the application exits). There is also a warning indicating that this key, if persisted, won't be encrypted in any way.
At this point I would ask the following questions:
- what is the GUID reported inside the logs with the name "key" ? What is used for ?
- is there any security risk associated with this warnings ?
- should I take any action ?
SOME ADDITIONAL INFORMATION:
Some blogs online suggest that these kind of data protection warnings are related to the usage of ASP.NET identity, but we don't use identity in our app (we have no authentication enabled). Other blogs suggests to setup the hosting application pool in order to load the user profile: I already tried that, but the warnings are still there.
IMPORTANT UPDATE 2nd April 2019
I solved the issue thanks to the help of the asp.net core dev team. For a complete reference see the github issue I opened yesterday
Put it briefly the issue is related to the IIS configuration on my development machine. In order for the ASP.NET core data protection to work as expected there are some specific configuration for IIS and the hosting application pool (see here for a complete reference)
UPDATE 13th SEPTEMBER 2019
For the ones having the same warnings inside their ASP.NET core 2.2 web applications I suggest to take a look at this github issue.
We now have added cookie authentication to our product and we need to support the kubernetes hosting. In kubernetes with the cookie authentication the warnings discussed in this stackoverflow question are relevant, because you have to provide ASP.NET core with a place where storing the keys needed by the ASP.NET core data protection system.
We opted to implement a persistent key ring in MongoDB. Some details can be found here. I can't show the code here (the project is not open source), but we have basically started from the official entity framework core key ring store and substituted all the usages of entity framework db context with an injected IMongoCollection<DataProtectionKey>
. We have also modified the DataProtectionKey class by removing the Id property (we prefer letting MongoDB generating its own object ids).