A  foreclosure sale removes all liens against a property other than tax liens (which typically aren't a problem because there is almost always enough value in the property to at least cover the taxes; they get satisfied before the first mortgage).  If there's money left from the proceeds, after the taxes and the first mortgage (including the foreclosure costs/legal fees) are satisfied, it would go toward the HELOC assuming no other lien had priority. However any unpaid balance would only be a potential deficiency judgment against the foreclosed property owner, not a lien against the auction purchaser's interest.Note:   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.