To understand who pays real estate commissions -- whether it's sellers or buyers or both -- first take a look at how real estate agents are paid and how they share cooperating commissions. Don't be embarrassed if you don't know how commissions work because I've had clients who didn't know, even though I had sold their home, represented them to buy a new home and then later listed that home for sale.
In the case of your particular scenario, the seller would be the lender or bank that foreclosed on the home. If it's an REO, or bank owned property, the bank should negotiate the real estate agent's commission. If it's owned by a private lender, they would be responsible for the commission. The seller is not always a private party. In the case of foreclosures, the seller is whomever currently holds the title, like the bank or lender.