No, it’s not “illegal” in the sense that this violates some specific criminal law. And even were these publicly traded companies governed by SEC rules, there still likely would be nothing illegal about it (barring, perhaps, a fraudulent statement or omission by the company about their policies, fraud prevention, etc.).