Bitcoin is a money and stealing a money is absolutely illegal actually stealing anything is illegal and bitcoin has a good nice value to how it can be legal.
According to certain theory, if you have coded a contract and there is loop hole in the code, you lose your bitcoin, it is legal.