This is really a 401-K question and outside our area of expertise.
There are restrictions on use of funds withdrawn from a 401-K to avoid tax penalties. A distribution of funds to pay a mortgage and avoid foreclosure is not subject to penalties. We are not familiar with the documentation requirements. If the borrower must be in foreclosure in order to use the 401K funds, this account is not eligible. If a letter stating that the borrower is 60 days past due and the creditor intends to initiate the foreclosure process once the borrower is 120 days past due is sufficient under the 401-K rules, then everything is fine. Your borrower should consult with the plan holder to determine the requirements and if taking a loan in this circumstance is possible.