It is forbidden to SELL relics, but it is permitted to "BUY" them (i.e. acquire them for a price) in situations like this ... to get them out of the hands of evildoers. Who knows who might end up buying these relics and for what purpose? Your intention in that scenario is not to engage in commerce over relics, but essentially to RANSOM them from evildoers.
So, for instance, while I cannot traffic in human beings, if I were in some country and saw someone selling children (to be used as sex slaves), I would be perfectly justified in buying these children to prevent that from happening to them. I would myself not be engaged in "trafficking" ... nor would a devout Catholic who was attempting to acquire the relics so they can be returned to their rightful place of honor among faithful Catholics.