There are different types.
They all involve a deficiency of an enzyme needed in cortisol production. Since the pituitary senses there isn't enough cortisol, it keeps trying to make the adrenals make cortisol. But because that enzyme is missing, the building blocks of cortisol build up. These substances get turned into androgens - male hormones - and cause abnormalities in sexual development.