Exhibit 10.97

EXECUTION VERSION

AMENDMENT NUMBER TWO

to the

MASTER REPURCHASE AGREEMENT

Dated as of November 20, 2012,

among

PENNYMAC CORP.,

MORGAN STANLEY BANK. N.A.

and

MORGAN STANLEY MORTGAGE CAPITAL HOLDINGS LLC

This AMENDMENT NUMBER TWO (this “Amendment Number Two”) is made this 26th day of
August, 2013, among PENNYMAC CORP., a Delaware corporation, as seller
(“Seller”), MORGAN STANLEY BANK, N.A., a national banking association, as buyer
(“Buyer”) and MORGAN STANLEY MORTGAGE CAPITAL HOLDINGS LLC, a New York limited
liability company, as agent for Buyer (“Agent”), to the Master Repurchase
Agreement, dated as of November 20, 2012, between Seller and Buyer, as such
agreement may be amended from time to time (the “Agreement”). Capitalized terms
used but not otherwise defined herein shall have the meanings assigned to such
terms in the Agreement.

RECITALS

WHEREAS, Seller, Buyer and Agent have agreed to amend the Agreement to make a
change to one of the representations and warranties set forth therein, as more
specifically set forth herein; and

WHEREAS, as of the date hereof, Seller represents to Buyer and Agent that Seller
is in full compliance with all of the terms and conditions of the Agreement and
each other Program Document and no Default or Event of Default has occurred and
is continuing under the Agreement or any other Program Document.

NOW THEREFORE, for good and valuable consideration, the receipt and sufficiency
of which are hereby acknowledged, and for the mutual covenants herein contained,
the parties hereto hereby agree as follows:

SECTION 1. Amendment. Effective as of August 26, 2013 (the “Amendment Effective
Date”), Subsection (4) of Representation (ccc) to Part I of Schedule 1 to the
Agreement is hereby amended to read in its entirety as follows:

(4) No Mortgage Loan is (a) a Section 235 subsidy loan (24 C.F.R. 235), or a
graduated loan under Section 245 (24 C.F.R. 203.45 and 24 C.F.R. 203.436),
(b) an advance claim loan, or (c) a VA Vendee loan;

SECTION 2. Defined Terms. Any terms capitalized but not otherwise defined herein
shall have the respective meanings set forth in the Agreement.

SECTION 3. Effectiveness. This Amendment Number Two shall become effective as of
the date that the Agent shall have received:

(a) counterparts hereof duly executed by each of the parties hereto, and

(b) counterparts of that certain Amendment Number Two to the Pricing Side
Letter, dated as of the date hereof, duly executed by each of the parties
thereto.

--------------------------------------------------------------------------------

SECTION 4. Fees and Expenses. Seller agrees to pay to Buyer and Agent all
reasonable out of pocket costs and expenses incurred by Buyer or Agent in
connection with this Amendment Number Two (including all reasonable fees and out
of pocket costs and expenses of Buyer’s or Agent’s legal counsel) in accordance
with Section 13.04 and 13.06 of the Agreement.

SECTION 5. Representations. Seller hereby represents to Buyer and Agent that as
of the date hereof and taking into account the terms of this Amendment Number
Two, Seller is in full compliance with all of the terms and conditions of the
Agreement and each other Program Document and no Default or Event of Default has
occurred and is continuing under the Agreement or any other Program Document.

SECTION 6. Binding Effect; Governing Law. THIS AMENDMENT NUMBER TWO SHALL BE
BINDING AND INURE TO THE BENEFIT OF THE PARTIES HERETO AND THEIR RESPECTIVE
SUCCESSORS AND PERMITTED ASSIGNS. THIS AMENDMENT NUMBER TWO SHALL BE CONSTRUED
IN ACCORDANCE WITH, AND GOVERNED BY, THE LAWS OF THE STATE OF NEW YORK, WITHOUT
GIVING EFFECT TO THE CONFLICT OF LAWS PRINCIPLES THEREOF (EXCEPT FOR SECTION
5-1401 OF THE NEW YORK GENERAL OBLIGATIONS LAW WHICH SHALL GOVERN).

SECTION 7. Counterparts. This Amendment Number Two may be executed by each of
the parties hereto on any number of separate counterparts, each of which shall
be an original and all of which taken together shall constitute one and the same
instrument.

SECTION 8. Limited Effect. Except as amended hereby, the Agreement shall
continue in full force and effect in accordance with its terms. Reference to
this Amendment Number Two need not be made in the Agreement or any other
instrument or document executed in connection therewith, or in any certificate,
letter or communication issued or made pursuant to, or with respect to, the
Agreement, any reference in any of such items to the Agreement being sufficient
to refer to the Agreement as amended hereby.

[Signature Page Follows]

 

2

--------------------------------------------------------------------------------

IN WITNESS WHEREOF, Seller, Buyer and Agent have caused this Amendment Number
Two to be executed and delivered by their duly authorized officers as of the
Amendment Effective Date.

 

PENNYMAC CORP. (Seller) By:  

/s/ Pamela Marsh

Name:   Pamela Marsh Title:   Managing Director, Treasurer MORGAN STANLEY BANK,
N.A. (Buyer) By:  

/s/ Zachary Phelps

Name:   Zachary Phelps Title:   Authorized Signatory MORGAN STANLEY MORTGAGE
CAPITAL HOLDINGS LLC (Agent) By:  

/s/ Christopher Schmidt

Name:   Christopher Schmidt Title:   Vice President

Amendment Number Two to Master Repurchase Agreement