This isn't just natural regeneration, this is any form of health gain. Unless an attack is strong enough to kill you in one shot, something like regeneration 6 and up, or something like continuous instant health, makes you invulnerable.
I've updated it.
I was using a Motorola 5G stylus, but it has also been happening on several other devices from other players.
This is happening in both single player and multiplayer. I do not know about servers and realms, but due to how the issue works, I'd assume it'd affect those as well.
I have now provided not only a sample pack, but a whole sample world so that it would be much more convenient to test the issue.