A debtor can used the bankruptcy laws to strip off a second mortgage.
This can only be done in chapter 13, not in chapter 7. It can only be done if the second mortgage is completely underwater, meaning that the property is worth less than what is owing on the first mortgage. And you cannot subtract commissions and other closing costs in calculating the property value. Getting an appraisal is advisable.
If the property is worth $295,000 and you owe $300,000 on your first mortgage and $150,000 on your second mortgage, you can strip the second mortgage over the three or five year period of the chapter 13 bankruptcy.
The lender holding the second will be reduced to status as an unsecured creditor. You will make payments each month equal to your monthly surplus, and the lender holding the second will receive its pro rata share of the surplus along with all other unsecured creditors, for example, credit card companies.