Is it illegal to booby trap your property?
The laws vary by state, some allow you to use traps as long as they don't cause serious harm, while others don't let you use them at all. No state allows you to set a lethal booby trap.
Here is the California law about them: https://law.justia.com/codes/california/2005/pen/12355.html