Nothing can be perfectly safe. For every defensive measure, there is a countermeasure. The most you can do is make it expensive to attack you... but that is, in and of itself, very expensive. Ultimately, all of society relies on trust to one degree or another.
And you can't defend a shoreline, either. This is a classic beachhead scenario, really. As for your cost references....
A Tippyverse mostly relies on the ability to make spell effects at-will anyway. While yes, it would cost about that to do repeated castings, a Command-word Widget of Forbiddance, at the minimum caster level (11), would run (by DMG estimates) Spell level * caster level * 1800 + 100 * material component cost. If we set it for a single 60-foot cube per invocation, with the password option, that's 500,000 for the material components. Grand total for the widget: 618,800 gp (market).
Compare to the True Resurrection trap you postulated for dealing with the XP problem, which runs 2,500,000 for the material components, 76,500 for the magical supplies, and 6,120 xp to craft.