This is the hadith you mentioned and it’s source.
عن أنس، عن عمر بن الخطاب: أن علياً "عليه السلام" رأى حية تقصده وهو في المهد، وقد شدت (وشدت) يداه في حال صغره.
فحول نفسه، وأخرج يده، فأخذ بيمينه عنقها، وغمزها غمزة[1]، حتى أدخل أصابعه فيها، و أمسكها حتى ماتت.
فلما رأت ذلك أمه نادت واستغاثت، فاجتمع الحشم، ثم قالت: كأنك حيدرة [حيدرة] اللبوة، إذا غضبت، من قبل أذى أولادها
مدينة المعاجز ج2 ص35 ومناقب آل أبي طالب ج2 ص287 و 288 و (ط المكتبة الحيدرية) ج2 ص120 وبحار الأنوار ج41 ص274 والإمام علي بن أبي طالب "عليه السلام" للهمداني ص611.
Haydara means a fierce lion
Just because the hadith is mentioned doesn’t really mean it is authentic. However, we know that Imam Ali was brave from a young age, and just as Allah chose certain prophets to show signs of greatness from a young age, that could very much be the case with Imam Ali.
The part of Arabs had a custom to check legitimate birth of child, I have never heard of.