Not illegal but arguably
Not illegal but arguably unethical imho. The car companies hate it for obvious reasons. They make no money on the markup and the practice sullies their brand with certain customers (like me). For the suckers that do elect to pay up to $18K over MSRP (plus over $3K in high profit dealer installed options), if they put 10% down and decide to sell the car a couple years down the road, they're under water and mad as hell.
I was ready to but but a $15K markup put me into BMW X5 territory so that's what I bought and I couldn't be happier. BMW (or Mercedes) do not mark up their cars. I'll never darken the doorstep of a Kia dealership again.