According to this wikipedia page:
Stick insect - Simple English Wikipedia, the free encyclopedia
"Some species of phasmid are able to produce a defensive spray when threatened. The spray contains pungent-smelling volatile molecules which the insect gets from its food plant. The spray from one species, Megacrania nigrosulfurea, is even used as a treatment for skin infections by a tribe in Papua New Guinea by virtue of its antibacterial constituents."
I don't know if it's the same kind of spray, but could be it!