"The prosecutor's office of the Lvov Region opened a criminal case over violations of railway traffic and operating rules," the office said in a statement.
Fifteen of the more than 50 cars involved capsized and six caught fire when the train, bound from Kazakhstan to Poland, derailed at about 5:20 p.m. local time (2:20 p.m. GMT) Monday. The fire was extinguished at about 10:30 p.m. local time (7:30 p.m. GMT). More than 800 local residents were evacuated.
Yellow phosphorus is a poisonous substance mainly used in fertilizers, with 0.05 to 0.15 grams enough to kill a human being. Those poisoned lose their appetite, experience fatigue and take on a yellow hue. The substance is highly inflammable.
All those poisoned were hospitalized and their lives are no longer in danger.
"The investigation is under the control of the Ukrainian prosecutor general's office," the Lvov Region prosecutor's office said.
Emergencies officials have said the environmental situation in the area is normal, with slightly increased danger in two settlements remaining.