There’s a street saying for this:
“You burn the coal, you pay the toll.”
Also:
Lay down with dogs, gonna get fleas.