You mean, other than law, police and the courts? You're describing an illegal action, under copyright law. If I steal your car and give it to a charity it's still stealing. Ditto, open source. They don't get to keep the car, they don't get to keep your code.
Granted, the courts treat genuine donations and pledges to charities differently than other gifts, and regard them as binding contracts; crediting the good work of charities of consideration to everyone including the donor (whether that's really true or not.) But I doubt your question referred to such subtleties.