Basically a mixture of mineral spirits (paint thinner) and mineral oil. It does have penetrant characteristics, so use caution around ammunition/primers, as overexposure can negatively affect primer viability. In other words, your ammo will no longer work as designed. As others have warned, it can also harm grip finishes and some plastics.
Opinion follows: Because of it's tendency to solidify and harden over time, WD-40 should not be used as a "lubricant" inside the lockwork of firearms, or as a general lubricant for moving parts on, or in firearms. Also, despite what the company indicates in it's promotional material, the use of WD-40 as a rust prevention strategy is not a good idea, short or long term.
There are many great products today that are specifically designed for gun care, maintenance, and cleaning. WD-40 is not one of them.