All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
The question is somewhat unclear. You did not clarify the kind of contamination to us. Is it because the halaal food is placed in the same containers in which there are traces of the unlawful food, or are there no traces of the unlawful food in them but they were used to produce the unlawful food? Or do you mean something else?
In any case, you should know that any obligation that is difficult and hard to abide by is subject to the verse (which means): {We charge no soul except (within) its capacity.} [Quran 7:42]
As-Sa‘di said, “The verse means that Allah only charges the person with what he can endure, so he has to abide by Allah's commands to the best of his ability. If he cannot fulfill some of the religious obligations that others are able to fulfill, he is exempted from them; Allah, The Exalted, says (what means):
- {Allah does not charge a soul except (with that within) its capacity.} [Quran 2:286]
- {Allah does not charge a soul except (according to) what He has given it.} [Quran 65:7]
- {He has chosen you and has not placed upon you in the religion any difficulty.} [Quran 22:78]
- {So, fear Allah as much as you are able.} [Quran 64:16]
The religious obligation is waived when the person is unable to observe them, and the prohibitions are excused in case of a valid necessity (to commit it). In other words, there is no obligation with inability, nor is there any prohibition with necessity.”
Based on the above verses, the following Shariah rules were deduced:
- “Hardship begets ease.”
- “Necessities overrule prohibitions (i.e. necessity renders prohibited matters permissible).”
- “The necessity is measured in accordance with its true proportions by its extent. Necessity must only be answered proportionately.”
- "When a matter tightens, it will widen, and vice versa (i.e. whenever or wherever Muslims experience unexpected hardship preventing them from abiding by some religious obligations, the Shariah eliminates this hardship - and when the hardship ends, things should return to the ordinary state or the original ruling).
Allah knows best.