Praise be to Allah
The basic principle is that it is permissible to sell medicines that are not known to be haraam, because the basic principle is that selling or trading is permissible, as Allah, may He be exalted, says (interpretation of the meaning):
“But Allah has permitted trade and has forbidden interest”
Things do not become haraam on the basis of mere uncertainty.
Medicines may contain substances that it is haraam to consume, such as alcohol, yet despite that it may still be permissible to sell them, because it is a small amount that is fully absorbed into the medicine in such a way that if a person were to drink a lot of this medicine, he would not become intoxicated.
It says in Fataawa al-Lajnah ad-Daa’imah (22/297): Some medicines and sweets are sold in the marketplace that contain a tiny amount of alcohol. Is it permissible for us to consume them? Please note that if a person were to eat the sweets and have his fill of them, he would never reach the point of intoxication.
Answer: If the alcohol in the sweet or medicine is of a very tiny amount, such that eating or drinking a lot of that thing would not lead to intoxication, then it is permissible to consume it and to sell it, because it does not have any effect on the taste, colour or smell, because it has been absorbed into the pure and permissible components. But it is not permissible for the Muslim to make anything like that or to add it to the food of Muslims, or to help someone else in doing that. End quote.
Statements and fatwas on the permissibility of using medicines containing a tiny amount of intoxicant alcohol have been issued by Islamic fiqh councils, and fatwa-issuing councils and bodies in the Muslim world, whilst noting that it is preferable to avoid adding alcohol to any medicines, so as to avoid dubious matters.
It says in a statement of the Islamic Fiqh Council belonging to the Organization of the Islamic Conference, no. 23(11/3) in response to enquiries from the International Institute of Islamic Thought (IIIT) in Washington:
Question no. 12:
There are many medicines that contain varying amounts of alcohol, between 0.01% and 25%. Most of these medicines are remedies for colds, sore throats, coughs and other common ailments. These alcohol-containing medicines constitute nearly 95% of the medicines for such ailments, which makes it very difficult or even impossible to obtain medicines that are free of alcohol. What is the ruling on taking these medicines?
Answer: The Muslim patient may take medicine containing a small amount of alcohol if alcohol-free medicine is not available, and that medicine has been prescribed by a trustworthy doctor.
End quote from Majallat al-Majma‘, issue no. 3, vol. 3, p. 1087
In a statement issued by the Islamic Fiqh Council belonging to the Muslim World League, it says: It is permissible to use medicines containing alcohol in small amounts that are fully absorbed, that is dictated by the way in which the medicine is made, when there is no alternative to it, on condition that it be prescribed by a doctor of good character
It is also permissible to use alcohol for external cleansing purposes, to clean wounds and kill germs, and to use it in creams and lotions that are used externally.
End quote from Qaraaraat al-Majma‘ al-Fiqhi al-Islami bi Makkah al-Mukarramah, p. 341
What was said about alcohol may also be said about some other haraam derivatives, such as those that are taken from meat that was not slaughtered in the prescribed manner, or from pork. If they are in small amounts that are fully absorbed, or have undergone a process of chemical transformation (istihaalah) that has changed their nature completely, in the sense that they have turned into a new, pure substance, then they may be overlooked and it is permissible to use medicines and cosmetic products that contain them, and it is permissible to sell such products.
This has been discussed in detail in the answer to question no. 97541.
To sum up: medicines and products may contain haraam substances, but it may be permissible to consume them and sell them.
If there is a medicine or product that would cause intoxication if drunk in large amounts, or it contains lard (pig fat), for example, that has not been transformed (istihaalah), then it is not permissible to consume it or sell it.
The one who works in the pharmacy must avoid that.
Thus you will know that the basic principle is that it is permissible to work in pharmacies, and that most types of medicine are permissible.
If it becomes clear that there is a medicine that it is haraam to consume, then it is not permissible to sell it, but there is nothing wrong with continuing to work there whilst avoiding selling that which is haraam.
And Allah knows best.