We already take damage in the border but sometimes it isn’t very effective especially when the player outside the border is underground and can find redstone, gaps, and books for heals So here is a 3 phase system to mitigate that
Phase 1
After 5 seconds of being outside the bounds you will start taking 1 heart of damage per 2 seconds
Phase 2: after 1 minute of this you will get 3 hearts taken away per 2 seconds
Phase 3: if all else fails after 2 minutes you will be immediately killed\
Also the border will close in quicker for underground players