The proposed CUBES spectrograph for ESO's Very Large Telescope will be an exceptionally powerful instrument for the study of comets. The gas coma of a comet contains a large number of emission features in the near-UV range covered by CUBES (305-400 nm), which are diagnostic of the composition of the ices in its nucleus and the chemistry in the coma. Production rates and relative ratios between different species reveal how much ice is present and inform models of the conditions in the early solar system. In particular, CUBES will lead to advances in detection of water from very faint comets, revealing how much ice may be hidden in the main asteroid belt, and in measuring isotopic and molecular composition ratios in a much wider range of comets than currently possible, provide constraints on their formation temperatures. CUBES will also be sensitive to emissions from gaseous metals (e.g., FeI and NiI), which have recently been identified in comets and offer an entirely new area of investigation to understand these enigmatic objects.