Dear New York Tenant:
If the tenant is living in the apartment, then your living arrangement is not based on a subletting. Your status (legal status) is an occupant or roommate. If the tenant is not rent stabilized, there is no restriction on the charge to a roommate (other than the "market") and since you agreed to pay, the tenant found the proper market occupancy fee.
If the tenant is rent stabilized (are there at least six apartments in the building?) then the tenant is restricted on the charge to a roommate to charging not more than a proportional share of the monthly rent. This is based on the tenant's rent and not on the relative sizes of the rooms occupied by the tenant and by the roommate. If the tenant is rent stabilized, you may have a right to sue for the excess in payments above the proportional share. No one will come to your aid if the landlord does not object. You could end your willingness to overpay by moving.
If the tenant is not rent stabilized, and the landlord does not care, your choice is simple: move.
The answer provided to you is in the nature of general information. The general proposition being that you should try to avoid a bad outcome if you can.
This doesn't sound illegal, it sounds like capitalism. If you agreed to the rent, what difference is it to you that your friend (sub-landlord) is making out on the deal? If you don't like it you should find other arrangements. That said, he's not much of a friend.
I may be guessing or not licensed in your state. No atty/client relationship exists.