Steps To Reproduce
- Self-host Bitwarden
- Add a new item with a Website URL with valid favicon
- Reload the Bitwarden client, eventually the icon disappears
Expected Result
Valid icons stay correctly cached so they show up correctly in the client.
Actual Result
Icons randomly disappear off some items.
Screenshots or Videos
No response
Additional Context
I tried to track down why this is occurring, and I can't say for sure, but I think it is to do with a shared Memory Cache between the IconController and ChangePasswordUriController in the Icons server component.
In server/src/Icons/Startup.cs
// Cache
services.AddMemoryCache(options =>
{
options.SizeLimit = iconsSettings.CacheSizeLimit;
});
services.AddMemoryCache(options =>
{
options.SizeLimit = changePasswordUriSettings.CacheSizeLimit;
});
AddMemoryCache is called twice, but I'm not sure that calling this twice actually adds a separate memory cache to each controller instance. I'm not even sure iconsSettings.CacheSizeLimit ever gets used, as I think it is overwritten by the changePasswordUriSettings.CacheSizeLimit
Both the ChangePasswordUriController and IconsController use the same key (the domain) to cache values for the result. I am pretty sure that IconsController caches an icon successfully, then the ChangePasswordUriController runs, gets a null result and caches that null result.....overwriting the icon.
I created a patched version that uses a unique key in each controller, when accessing the MemoryCache, and the issue seems resolved.
e.g.
var mappedDomain = "Icon-" + _domainMappingService.MapDomain(domain);
var mappedDomain = "ChangedPasswordUri-" + _domainMappingService.MapDomain(domain);
Build Version
2026.4.2
Environment
Self-Hosted
Environment Details
Issue Tracking Info
Steps To Reproduce
Expected Result
Valid icons stay correctly cached so they show up correctly in the client.
Actual Result
Icons randomly disappear off some items.
Screenshots or Videos
No response
Additional Context
I tried to track down why this is occurring, and I can't say for sure, but I think it is to do with a shared Memory Cache between the IconController and ChangePasswordUriController in the Icons server component.
In server/src/Icons/Startup.cs
AddMemoryCache is called twice, but I'm not sure that calling this twice actually adds a separate memory cache to each controller instance. I'm not even sure iconsSettings.CacheSizeLimit ever gets used, as I think it is overwritten by the changePasswordUriSettings.CacheSizeLimit
Both the ChangePasswordUriController and IconsController use the same key (the domain) to cache values for the result. I am pretty sure that IconsController caches an icon successfully, then the ChangePasswordUriController runs, gets a null result and caches that null result.....overwriting the icon.
I created a patched version that uses a unique key in each controller, when accessing the MemoryCache, and the issue seems resolved.
e.g.
Build Version
2026.4.2
Environment
Self-Hosted
Environment Details
Issue Tracking Info