Neither is correct.
You can't use the present perfect tense before "before". The index time for the present perfect is now.
You can say:
"The bacteria had gotten to it before we ate it."
"The bacteria got to it before we ate it."
"The bacteria will get to it before we eat it."