Some pixels doesn't render on the image ID MASK
Don't use ID Masks
Just don't. They have little use, this is a really poorly designed feature. You simply cannot make a good mask with a 2bit color depth image.
Cryptomatte is the solution
Look into using Cryptomatte. You need to enable it's layers in the View Layer properties tab:

You can then get any masks easily using Cryptomatte node in the compositor and they will be a lot higher quality: