"The house and lot I am interested in buying is still in mortgaged with a certain housing company. However due to unpaid obligations, the said property might be assessed to foreclosure. Now the current "owner" is selling it to me. Is it legal to sell a foreclosed property even if it's still mortgaged?"
Actually it's very risky to buy a property that has been foreclosed. Unless the property has been consolidated with the new owner, the seller of the mortgaged property can still sell but subject to encumbrance because real estate mortgage is a real right that carries with it with the property. As long as there's no foreclosure sale yet.
If it's mortgaged property, look at the title. If you buy a mortgaged property, that property will still be subject to foreclosure proceedings. So, it's risky to buy a mortgaged property which is a candidate for foreclosure.
Do you have any problems or questions related to real estate properties? You ask or tell in the comment below.