The kidneys normally retain magnesium if one is deficient and release it if one has excess. If your kidneys are malfunctioning, however, one should not take Epsom Salts . It isn't that the ES damage the kidneys.
From the Merck Manual:
In hypermagnesemia, the level of magnesium in the blood is too high. Hypermagnesemia usually develops only in people with kidney failure who are given magnesium salts or who take drugs that contain magnesium (such as some antacids or laxatives).
If Epsom Salts turn your urine dark, it could be that you are excreting wasted flushed by the Epsom Salts . It could also be the excretion of the sulphur from the Magnesium Sulphate. Or perhaps you should check for renal disease.
The process is a simple chemical reaction:
In ES, the carbon ingredient of the Magnesium Carbonate is replaced Sulphur, forming Magnesium Sulphate. The magnesium prefers carbon to sulphur and will readily give up its sulphur and seize upon carbon whenever a favourable opportunity for making the exchange presents itself. And this strong affinity of Magnesium Sulphate, Epsom Salt, for carbon is the point to be remembered. Carbon, in one form or another, is the main constituent of the building materials which go to form our vegetation and to provide our foodstuffs. And it is in the crude form of carbon, that the waste products of the human body are thrown off. The magnesium draws out the carbon and renders the now inert residue soluble facilitating excretion.