By: Rabbi Ari Enkin
Although the Torah clearly prohibits the consumption of worms, or all other insects for that matter, there are, however, some interesting exceptions to the rule. The Torah’s prohibition on consuming insects applies only to those things that “live in the seas and in the streams”, “fly in the air” and “creep on the ground”. So severe is the prohibition on eating any such creepy crawlers that often the consumption of a single insect is a concurrent violation of multiple prohibitions.
Among the insects which are permitted to be eaten are grasshoppers, which the Torah explicitly permits. Nevertheless, one will rarely see grasshoppers on the menus of kosher restaurants since it is unclear which of the many species of grasshoppers are the ones which the Torah actually permitted. As such, a decision was made to ban the consumption of all grasshoppers in fear of possibly eating one of the forbidden species, many of which look nearly identical to the permitted ones. There are certain communities, however, most notably Yemenite ones, where the consumption of certain species of grasshoppers is routine.
There are also a number of circumstances in which the consumption of worms is permitted. For example, worms which are found within a fish are often permitted to be eaten along with the fish itself. There are generally two types of worms which can be found inside a fish – those in the flesh of the fish and those in the intestines. It is only the worms which are embedded in the flesh of the fish which are permitted. Worms which are found in the intestinal tract, evidence of having been recently swallowed, remain prohibited. For more on this issue, see here: link.
Similarly, one will often find worms in cheeses that are hard, aged, or otherwise prepared in a way that gives the cheese a very sharp taste. These worms are kosher and are permitted to be eaten as long as they remain embedded within the cheese. However, if they leap off or otherwise separate from the cheese, they are then forbidden to be eaten. Some authorities even allow the consumption of worms which have separated from cheese as long as they have not gotten further than the plate or serving dish.
Additionally, it is permitted to eat a worm that grew in a fruit that had been detached from its source of growth and had never been exposed to the air. However, worms and other insects which grew in a fruit while it was still attached to the tree are forbidden to be eaten. If one is in doubt whether a worm that is found in a fruit is of the permitted or forbidden species, the fruit may not be eaten.
It is permitted to grind stalks of wheat which are found to be wormy as long as the flour will be properly sifted following the grinding. It is also permitted to eat burnt or pulverized worms, insects, and other non-kosher products when there is a medical benefit in doing so. Honey is a kosher product even though it is the by-product of non-kosher insects.
Another exception to the prohibition on consuming insects applies to certain aquatic species. As mentioned, insects are only prohibited if they grew in seas, rivers, or lakes. Worms and insects that grew in water originating in containers or cisterns are permitted to be consumed when swallowed in the course of drinking directly from such sources. For example, one who is forced to drink water directly from a well would be permitted to do so without having to first check the water for any bugs. On the other hand, one who transfers well water into a cup would be required to first check the water before drinking it as any bugs which might be present would no longer be in their natural source, and are therefore forbidden accordingly. In the olden days unpasteurized vinegar would often breed certain bugs which were permitted to be consumed along with the vinegar. Such vinegar is no longer on the market today.
It is interesting to note that the Torah only prohibits insects which are visible to the naked eye. Insects which are only visible through a microscope are permitted to be consumed in the normal course of eating. So too, insects that have fully withered and dried are often permitted, as well. Even when worms and bugs are technically permitted, it is commendable to make the effort not to consume them due to the concern of “baal teshaktzu”, the prohibition to engage in anything which might be considered disgusting. Indeed, even worms that are technically permitted to be eaten should be avoided as they are said to cause both spiritual and physical harm.
Some time ago a controversy erupted in New York City concerning bugs which were repeatedly found in the public water supply. As a result, a number of halachic authorities ruled that the New York City drinking water must be filtered prior to consumption. Other authorities insisted that this was not required as the bugs were not visible to the naked eye and therefore permitted. It was also suggested that the municipal water supply chain is halachically identical to a cistern in which case there would be no prohibition on consuming such bugs. According to the latter approach, however, the water would only be permitted when drunk directly from the faucet – certainly an unrealistic arrangement for a household that regularly drinks tap water. 
 Vayikra 11
 Makkot 16b
 Vayikra 11:22
 Taz Y.D. 85:1
 Y.D. 84:16
 Chullin 67b
 Taz;Y.D. 89:4
 Aged cheese is loosely defined as being aged six months or more. Shach Y.D. 89:15
 Y.D. 84:14, Rema Y.D. 84:16
 Shach Y.D. 84:46
 Y.D. 84:6
 Y.D. 84:7
 Y.D. 84:14
 Y.D. 84:17
 Y.D. 81:8
 Y.D. 84:1
 Rema Y.D. 84:1. For more on bugs and water see: Darkei Teshuva 84:9,28
 Aruch Hashulchan Y.D. 84:36, Binat Adam;Klal 38:49, Tuv Taam V’daat;Kuntres Acharon 53
 Y.D. 84:4
 Aruch Hashulchan Y.D. 84:36, Igrot Moshe Y.D. 2:146
 Avoda Zara 68b
 Shabbat 90a
 For more on the New York Cite water supply controversy see: The Laws Of Pesach (Rabbi Blumenkrantz) Chapter 29