Cosmetic products are carefully formulated to ensure ingredients are delivered to the appropriate site on the skin or hair. The skin is an effective barrier against penetration which is why even today most medicines have to be swallowed or injected and very few can be absorbed through the skin from topical patches.
Of course some substances do penetrate the skin or may be ingested (from oral care and lip products) but these are readily metabolised and harmlessly excreted. They do not accumulate within the body to reach unsafe levels. All of these elements will be addressed by the safety assessor and will be factored in to the safety assessment.
The ability of a substance to enter through the skin is a complex thing and is down to the characteristics of each individual substance, such as its ability to be soluble in lipids and its size (molecular weight). Just as our weight is measured by the unit 'kilograms', the 'weight' or 'size' of each individual unit of a substance (molecule) is estimated in the unit 'Daltons'. You may sometimes come across a reference to the 'Dalton rule'. This is a 'rule of thumb' and says that substances above about 500 Daltons in size will not easily pass through the skin; substances below about 500 Daltons will find it easier, but only if they have a low electrical charge and are neither very soluble in lipids nor water. This rule applies to undamaged skin; broken skin (cuts, grazes, inflamed areas) allows many substances to gain access to the body which would not normally be able to pass through the skin.
The safety assessment required for each cosmetic product before it is placed on the market takes into account any possibility of skin penetration, including as necessary any use on damaged skin, to ensure there can be no harm caused to the consumer.