From the Super Mario Wiki, the Mario encyclopedia
It is given to Mario by a "fan". Mario's partner eats it first, but before they can give some to Mario, they start to feel sick, and Mario must face his next fight alone, after which his partner will recover. Before fighting with Rawk Hawk, he reveals that he tricked them into eating the poisoned cake. If Mario decides not to eat the cake (though Mario's partner will say otherwise), Shellshock will eat it instead and is thus the one to be poisoned.