You pay additional fees to your bank, cable company, cell phone carrier, auto dealer and you do not consider them ILLEGAL. Inconvenient yes, Illegal, No. Just like those other fees, you can challenge them. Doing so can have consequences or result in the fees disappearing. The suggest such fees are illegal is silly. Licensed professionals in nearly every discipline are regulated regarding the service for which they are able to charge a consumer. That is the benefit to the consumer for this bureaucratic oversight.
I can't speak to the legalities, but I don't believe this is a wise business decision. This agent is getting the full listing commission and the buyer's side commission unless they had a different arrangement. If you did not agree to this fee up front, before anything was signed, I can't imagine how it would be enforceable.
You could always call their bluff and just offer to rescind the transaction. I suspect they would find a way to get the fee waived then.