If there's money left from the proceeds after a foreclosure, after the taxes and the first mortgage are satisfied, it would go toward the HELOC (assuming no other lien had priority). However any unpaid balance could result in a deficiency judgment against the foreclosed property owner.A "deficiency judgement" is a judgement that can be obtained by a lender against a borrower if their property sells for less than the remaining balance on the mortgage. Technically, it's only called a "deficiency judgment" if at least part of the loan was paid off by the foreclosure sale of the property, so if the no money was applied to the HELOC, it's just a lawsuit and judgment on the loan, not a deficiency judgment.  But either way, the borrower is liable for it.