No sources, no history.
According to Constance Reid, Hilbert (1970, reprinted as Hilbert-Courant, 1986), page 7-8 :
At the Wilhelm Gymnasium, David was much happier than he had been at Friedrichskolleg. The teachers seemed to recognize and encourage his originality, and in later years he was often to recall them with affection.
Grades improved — "good's" in almost everything (German, Latin, Greek,
theology and physics) and in mathematics "vorzüglich, [excellent]" the highest
possible mark given at the time. He did so well on his written examinations that
he was excused from taking the final oral examination for the leaving certificate. The evaluation which appeared on the back of the certificate rated his deportment as "exemplary" commented on his industry and "serious scientific interest," and then concluded:
"For mathematics he always showed a very lively interest and a
penetrating understanding: he mastered all the material taught in the school in a very pleasing manner and was able to apply it with sureness and ingenuity."
This is the earliest recorded glimpse of the mathematician Hilbert.
So, the conclusion is: it is not confirmed. After all, does it really matter?