If the Lien holder finds out about the "under the table" agreement with the second, it is likely they will pull the deal. I suggest you keep everything above board, tell the first what is going on and see if they will agree to allow the second to receive the 5K that you have agreed to pay(1K + the 4K ). Although it is likely they will say "no", at least you won't end up losing time and money, or worse, end up in a legal battle.
The truth is that the second will lose everything if the foreclosure goes through. I have dealt with several Short Sales that have had this situation. The 1st is in the strong position, and the 2nd stands to lose everything. If they get along, the 2nd will agree to take the 1K in order to build goodwill with the 1st, so if the tables are turned on the next deal, the other bank will return the favor. If the 2nd is a minor player in the mortgage industry, or has a poor reputation, the 1st will just foreclose, and let the 2nd lose completely.
In any case - all the best - my best advice is stay honest and forthright in all things. What happens happens, but at least you can know you did the right thing. And since a man reaps what he sows, it will all work out in the end.