IANAL but my understanding is that it's generally illegal to have any kind of "booby trap". The concern (and also legal test) is whether or not it would be likely to spring on a first responder. If you have your house fill with knockout gas whenever someone enters and a fireman needs to kick in your front door, you're going to jail. Someone entering illegally such a burglar still can bring a suit around a booby trap (but could also still liable for prosecution for their illegal entry, etc).