The problem with the verb is pragmatic, not grammatical. The sentence is correct given suitable context. The reason a factive verb sounds odd is that, if John know Mary bought a hyena, then Mary bought a hyena. We don't need to ask what John knows Mary bought, we can just ask what Mary bought. They have to be the same.
However, being linguists and having a sentence that theory tells us is grammatical, we should be able to find a context that makes it usable. It's John's birthday. (We know that) John knows that Mary is buying some balloons and a cake. She intends to surprise him by also buying champagne. If we're not sure whether he knows about this, we can ask what John knows Mary bought. (Answer: balloons, cake, but not champagne.) We're sneaking an invisible plural 'what' under the radar.
Pardon me for the late reply and I thank you for the great explanation of my question. I assumed the sentence is grammatical, but couldn't just figure out what it means and in what context it can be used. It is clear now. Thank you