Thanks for raising this topic.
I can confirm that saving favicons is unreliable but I’m not sure all the details match your description exactly.
For starters, I haven’t tested this specific feature in KeePass 2.40, although it is highly unlikely that has introduced a bug relating to favicons. The selection of the favicon is done by the Kee browser addon rather than KeePass or KeePassRPC (they merely save whatever icon they are given by the addon).
There is an ongoing Firefox bug which Mozilla have shown no interest in fixing:
In Firefox 63, Mozilla made significant changes to the way they handle favicons and it is my hypothesis that any recent increase in the number of favicon saving failures would relate to this change:
In my own testing, I see the unreliability described in bug 1417721 but also notice similar problems with Chrome so unfortunately it doesn’t appear that favicon support is a feature that browser manufacturers take especially seriously.
There is a feature request to allow add-ons to access the favicon through a reliable mechanism but this has not yet been scheduled by Mozilla and I’ve seen no indication from Google that they would follow suit with Chrome:
There may be a solution that doesn’t rely upon browser manufacturers. It should be possible for Kee to access information about each web page and make a direct request to the web site in question in order to load the favicon.
However, doing this reliably is a complex piece of work and may even be too large to be included within the Kee addon. A related alternative could be the development of a new service hosted on the internet that Kee could request the favicon from.
In both of those approaches, there are privacy implications that would need to be considered so I strongly favour solutions supplied by the browser manufacturers and so would prefer to defer any work on this.
If the frequency of these problems has indeed increased with Firefox 63, that might force us towards one of the less-ideal solutions so I’ll keep an eye on this topic over the coming months.