Although such an ability is not as far-fetched as it sounds. There are real beetles called bombardier beetles with a very similar natural weapon.

They have two separate chambers in their abdomen, in which two different chemicals are stored. Individually, these chemicals are relatively harmless. But when mixed together, they react violently and get
very hot. When the beetle feels threatened, it can release the chemicals so that they mix together and explode out of the end of the abdomen, showering potential attackers with a boiling poison.