There are two answers to this question: the theoretical answer and the practical answer. In theory, no one can answer your question. There is very little case law regarding album art, and none of it that I can find concerns your situation or anything closely resembling it. This is one of those things no one has a strong interest in clarifying through court action because both sides see the negative consequences of a potential loss as outweighing the benefits of a potential win. At present, the metadata is not considered separately from the song file itself, and so the legality of the former is dependent upon the legality of the latter.
In practice, there is virtually no chance that anyone would ever take legal action against you for downloading cover art for songs you legally own. This is especially true if you are just restoring what was originally there. That is, if by “cleaning up messed up metadata” you mean “the song came with the correct cover art and something went wrong somewhere along the way,” no one is going to care. Your actions do not threaten anyone’s copyright, and it would be nearly impossible to win a case against you without spending far more than it would be worth. So you have little to be worried about regardless of theory.
Standard disclaimer: I am not a lawyer. The above is based on seminars I’ve taken on copyright law and discussions with colleagues who have studied and/or practiced copyright law. The information may be out of date or based on a misunderstanding. It is always advisable to speak to a practicing lawyer.