A man attacked a woman on the Upper East Side by bizarrely stuffing a bag of feces down her shorts, police said.

Surveillance video shows the 27-year-old victim on her cellphone on East 74th Street near First Avenue at about 6 p.m. Monday when the attacker approached her from behind.

Wearing gloves, he grabbed the woman’s shorts at the waist and shoved the bag of excrement down the back.

After a brief struggle, he peeled off his latex gloves and tossed them into the street as he fled.

It was not clear whether the bag contained human waste or animal feces.