All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
If a woman remarries before the end of her waiting period from her first husband, her marriage is void according to the consensus of the jurists . Not residing with her first husband for a long period does not make it permissible for her to remarry before observing a waiting period. Therefore, she is obliged to observe the waiting period if she consummated the marriage with the first husband or if she has been in seclusion with him. Thus, for a woman who remarries before the end of her waiting period, her marriage is forbidden and invalid. It is an obligation to separate the two of them. She has first to observe a waiting period from her first husband and then another waiting period from the second man if he had consummated the marriage with her. When the two waiting periods are finished, the second man can marry her with a new contract, though there are some differences of opinion among the jurists in this regard.
As regards to the issue to whom the child will be traced back if she gives birth to any in the second year of her invalid marriage, then the answer is that it is possible that the father of the child is the first husband, and it is also possible that the child is from the second man, as she would have given birth to the child after six months of sexual relationship with the second man and less than four years from her separation from the first husband. In such an issue, the classical jurists stated that the child's case should be presented to the Qaafah (a group of people who are specialized in tracing back children to their fathers), and then the child will be traced back according to the decision of this group.
In this century, if it is said that such cases in which the classical jurists referred the issue to the above group, that the child can be traced back according to DNA testing, then this view would not be far from the truth as the percentage of obtaining a wrong result is very rare; it is even said that such testing is 99% accurate. Therefore, this is more accurate than the Ijtihaad (an opinion on matters which are not specified in the Quran or the Sunnah) of the group that are specialized in tracing back the child to his father.
To conclude, the second marriage is void and she is obliged to observe a waiting period from the first husband and when the period ends she has to observe a second waiting period from the second husband. In the case which the questioner mentioned, the child will be traced back either according to the Qaafah or by DNA testing.
Finally, we advise you to take the matter to an Islamic court in your country so that it will look into the matter from all its angles.
Allaah Knows best.