A debtor can redeem (pay off the amount owed) at a foreclosure (prior to the actual sale) and stay in the home. The debtor does not need prior court approval regardless of CPLR 5236 & CPLR 5240 (which are statutes regulating legal practice that state to the contrary) because there is a common law (general understanding law) that permits such payments.
See Rondack Constr. Servs., Inc. v. Kaatsbaan Intl. Dance Ctre., In.c, 2009 NY Slip Op 09264 - for the Court of Appeals' (highest court in the State of New York)decision stating this rule.
Take Away - Until a house is sold at foreclosure a homeowner can always pay off the entirety of their debt and avoid foreclosure - its equitable - its fair - and its the way it should be.