Foreclosed property with lis pendens and senior lien

Hi, I recently purchased a foreclosure property. After trustee sale, the owner recorded a lis pendens. I am filing a UD but given there is a lawsuit on wrongful foreclosure, it might take a while till I get the property. I also realized there is a first mortgage on the property as the property was foreclosed on second mortgage. I am not clear about my position here as the lawsuit decision might revert the foreclosure. If I dont get the house till the lawsuit ends, am I liable to pay for the first mortgage if the owner stops the payment? What if the first mortgage forecloses the property, will I get my money back?

@Sean_OToole can you please give your thoughts here?