I understand that duct mastic is used on ductwork but is it also used on the critically hot areas such as exhaust flues? I'd figure a masonry fireplace sealant would be okay too. It might be a good idea to check the conductivity(in case it flows into the box a little) and adhesion to the surfaces you want to have it attach to as well. I think its still a better idea to stick with something that is rated for both UL 1479 and UL 2079 when in an area that has an increased hazard. Granted a 4 hour fire rating with a product like this might be a little overkill but it's only $11.47 and the tube could handle all of the more hazardous air sealing for most houses.
Shop 3M 10.1-oz Red Specialty Caulk at Lowes.com