Allah's Messenger (sallallaahu alayhi wa sallam) said, "Whoever died and he ought to have fasted (the missed days of Ramadan) then his guardians must fast on his behalf."
[Sahih al-Bukhaari Hadith No. 1952]
Ibn Hajar al-asQalaani writes:
The 'aSHaab al-Hadiith have permitted that one fast on behalf of the dead. Imaam al-Shaafi'i said in his old Madhhab that if the hadiith is authentic it is to be acted upon. What is mentioned in the hadiith is also the opinion of Abu Thaur, and of a group of Muhaddithuun from among the Shaafi'i school of thought.
al-BayhaQii said this is established and I know of no difference of opinion among the scholars of hadith regarding the authenticity of this hadiith [i.e. they all agree it is authentic]. Therefore, it is waajib to act according to it. Then, he mentioned what al-Shaafi'i said: Everything I say which opposes that which is established as authentic from the Prophet (sallallaahu alayhi wa sallam), then take the hadiith and do not make taqliid of me.
Volume 4 Page 193