Iron Golems will automatically attack all types of undead mob (except zombie/skeleton horses), as well as slimes, spiders, pillagers, witches, piglins, endermen, The Enderdragon (will attempt if within range), vexes (will attempt if within range), silverfish, magma cubes, endermites, guardians, blazes, and shulkers.