I'm trying to replace the MAF sensor in my Mitsubishi 2003 Lancer ES GLi1.8, and it's bolted into a plastic housing that fits the air filter. The bolts are weird, in that they have a head about 2mm thick, perfectly round aside from two small flat sides. How do I remove something like this? I'm inclined to buy a new air filter housing instead.
Just unscrew the nut from the other side and pull the bolt through, the shape of the bolt head is designed to fit into the plastic tabs which will keep the bolt from spinning. If the nut is frozen use a penetrating spray like WD40 to help get it free. This can take time to work, a few sprays over an afternoon can sometimes make a big difference.
If you can't get the bolt loose with a penetrating spray use a pair of locking pliers (my small locking pliers have saved me many times) to grip the bolt. It's really no big deal if those plastic parts break off or you cut them off as locking pliers will hold it in place for you to put it back on, or you just replace the bolt with a hex head one.
Try some penetrant fluid (PB blaster or something else), let it soak for a while.
Then hold the round head with some pliers and try to remove the nut. Depending on your luck (and skill) it might be viable to flatten the round head with a rotary tool, so holding the head should be easier.
Should the plastic tabs break: That damage should be negligible or repairable, in worst case you need an new filter housing (that was your first plan).
The nut and threaded portion doesn't show severe corrosion but applying any penetrant fluid, light machine oil or WD40 should work to penetrate. It may take anywhere from a few minutes to several hours. Apply first then address the flat headed bolt, probably designed for clearance, not obstructing anything in the area. Since it twisted from attempts to loosen the lightly corroded nut and threaded portion of the bolt, you have several ways to deal with grabbing the flat part.
Since the plastic walls are damaged and allowing the flat headed bolt to rotate, either remove as much of the damaged plastic for needle nose pliers to grab the flats or try wedging a thin bladed screwdriver between the plastic protrusions to stop the flat bolt from rotating while trying to loosen the nut. The maf sensor isn't bolted with a lot of torque so loosening the nut should not take much effort to break the corrosion (becoming a mechanical form of loctite). If you manage to loosen the nut just a few degrees of rotation, retighten it. This lets the penetrating fluid work its way further into the corroded threads. Loosen some more and retighten as you work the nut off. Hopefully the flat headed bolt can be wedged in place from rotating or grabbing the flat portions with a needle nose pliers.