Praise be to Allah.
It is not valid to wipe over the socks when doing wudu except in the case of one who put them on in a state of purity. This is indicated by the saheeh Sunnah of the Prophet (blessings and peace of Allah be upon him).
Al-Bukhari (206) and Muslim (274) narrated that al-Mugheerah ibn Shu‘bah said: I was with the Prophet (blessings and peace of Allah be upon him) on a journey, and I bent down to take off his khuffayn (leather socks), but he said: “Leave them, for I put them on when my feet were clean (taahir),” and he wiped over them.
According to a version narrated by Abu Dawood (151): “Leave the khuffayn, for I put the khuffayn on my feet when they were clean (taahir).”
This indicates that wiping over the khuffayn is not permissible unless one put them on in a state of complete purity. End quote.
Ibn Qudamah said in al-Mughni (1/174):
We do not know of any difference of scholarly opinion regarding the stipulation that prior purification is required in order for it to be permissible to wipe (over the khuffayn or socks). End quote.
Imam Malik (may Allah have mercy on him) said:
Wiping over the khuffayn is only permissible for one who put the khuffayn on his feet when they were clean (taahir), after doing wudu. As for the one who put them on his feet when they were not clean and he had not done wudu, he cannot wipe over the khuffayn."(Al-Muwatta’ 1/37).
It says in al-Muntaqa Sharh al-Muwatta’ (1/78):
It is as he said: if a person put on his khuffayn after doing wudu, then he broke his wudu, then took off the khuffayn, then put them on again, the ruling on wearing them when in a state of purity is no longer applicable, and he is now wearing them when not in a state of purity. Putting on the khuffayn when in a state of purity is a condition of it being valid to wipe over the khuffayn. End quote.
Based on that, if someone takes off his socks then puts them on again when he is not in a state of purity, it is not permissible for him to wipe over them; rather it is essential for him to wash the feet when doing wudu. The fact that he only took the socks off for a few seconds does not change the ruling, because in fact he put on the socks when he was not in a state of purity, so it is not permissible for him to wipe over them.
And Allah knows best.
For more information, please see the answer to question no. 9640.