While the ender dragon is perched, it can take damage from firework rockets shot from a crossbow, although depending on the angle it may not (see MC-313168).
To reproduce
Create a new world
/execute in minecraft:the_end run teleport @s 0 72 0/kill @e[type=end_crystal]/item replace entity @s weapon.offhand with firework_rocket[minecraft:fireworks={explosions:[{has_trail:1b,shape:"small_ball",colors: [4312372]}],flight_duration:1b}] 64/item replace entity @s weapon.mainhand with minecraft:crossbow[minecraft:enchantments={quick_charge:3}]/data modify entity @n[type=minecraft:ender_dragon] DragonPhase set value 3Shoot the ender dragon from the side or behind while it is perched, and observe that it takes damage
This may be intended for the same reason as MC-311111 (whatever that reason is).
Video showing this issue and MC-313168: