I thought WD40 is a mineral oil. I think it used to be dinosaurs and plants and other critters before it became 'mineral' and then it got pumped out from deep under the earth's surface, refined and packaged in a bottle.
Like a lot of other stuff it's mostly C from CO2, hydrogen from H2O and sunlight to break off the Os so that the Cs and Hs can combine. I don't drink it because other CHs taste better, don't use it as aftershave because other CHs work and smell better, but I've put it on blades when I ship them or when I won't use them for a while as well as when sanding razors.

It's probably somewhat carcenogenic like most things including sunlight are, but it's unlikely to be as bad as, say, smoking tobacco.