Mooshrooms take damage when trying to jump in enclosed space. Damage is dealt when the mooshroom headbutts the roof. It's probably suffocation damage. Bug also affects cows.
1.Build a place similiar to this on the image.
3.Mooshrooms must hit the roof blocks when they're trying to jump
4.Mooshrooms will take damage