I don't think there are any laws in the USA or UK limiting the number of middle names, though there would be practical limits on how many would physically fit on an official birth certificate.
There have been several instances over the years where parents have given children 26 names, one starting with each letter of the alphabet, which means 25 middle names.
Personally I think this is one of the eccentric things parents might do with names which children need the LEAST "protecting" from. It's not like there is any reason to have to write out all of one's middle names, if one has more than one, in any normal life situation. I do not see how having 25 or even more middle names could really harm a child.