Subordinate liens & refinance classification
Paying off a second mortgage is not automatically limited/no-cash-out. The purpose and history of the subordinate lien matter.
Fannie
Under the Limited Cash-Out framework, eligible purchase-money subordinate financing can generally be included in the refinance. Paying off a non-purchase-money subordinate lien can instead push the transaction into cash-out unless another specific exception applies.
Freddie
Freddie's Section 4301.4 similarly restricts which junior liens may be paid off or paid down in a no-cash-out refinance. The lien's original purpose and transaction history matter.
Official guide baseline
Fannie Mae Selling Guide · Freddie Mac Seller/Servicer Guide
Refinance classification matters. A transaction that falls outside limited/no-cash-out rules may become cash-out even when the borrower receives little or no cash personally.