"Foot gun" for shooting one's self in the foot.
If you require a more crass application just substitute another body part for "foot".
For example:
Wow, I can't believe that guy actually committed that code.
Yeah, he really shot himself in the dick with that one.