That may or may not be legal. Were they sheet metal screws or machine screws with nut ? Also is issue on if it had a chase nipple or wires just ran thru knock outs. Often its not a simple yes or no. Outlet if installed properly is fine. I would dought there is any real danger here and would be simple fix.
Presuming the outlet has some appropriate type of overcurrent protective device, then the question essentially boils down to whether mounting a box on another box violates the UL listing of either box. But if the outlet is not protected from overcurrent, then it violates 240.3 aand 406.3.