I spoke with the head of my building’s HOA about this (he was also the building’s developer) and he said (I’m paraphrasing):
“In all but the most unusual cases – that is, situations where there might be an issue with the CC&Rs or the property’s title insurance – the institution that forecloses on the property must pay the accrued unpaid HOA dues or else they will not be able to legally transfer the title of the property to a new owner.”
A friend of mine who’s the CEO of a local bank said the same thing in so many words.
Now, they may be wrong; laws may have changed; or whatever else, but the impression I get – and there’s a certain logic to it – is that the owner of the property (whether it’s the original owner or a financial institution) must cure any issues with unpaid HOA dues before legal title will transfer to a new owner. Having said that, maybe the law varies to some degree depending on the circumstances. I’m just reporting what I’ve been told by people who should know about such things.