Skip to content

Icon Cache Invalidated By Change Password URL Cache? #7701

@DigitalDJ

Description

@DigitalDJ

Steps To Reproduce

  1. Self-host Bitwarden
  2. Add a new item with a Website URL with valid favicon
  3. 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

  • Ubuntu 26.04 with podman

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions