The chemical will be mixed with tempting food to lure the rats, which have become fussy eaters as a result of the range of diet afforded by the city's development, according to the Shanghai Daily on Wednesday.
To make the laced food - fish meal and spices - even more irresistible, it will contain an addictive drug.
The new form of rat control, though more expensive, will be more environmentally friendly and safer for Shanghai's human population, the paper said.
Poisoned children
A doctor at a local hospital said that children accidentally consuming rat poison was a common hazard.
"We have treated many kids from rural families who have eaten rat poison," Dr Ji Qinying, from the Shanghai Children's Medical Centre, told the paper.
The contraceptive, which is extracted from cottonseed, acts as a spermicide.
It is currently being tested in 100 locations around Shanghai.
"This drug is in trial use. If it proves successful based on the results from the pilot tests and other examinations, we will consider promoting it," the city's health campaigns officer Jin Peiwu told the newspaper.