I used to tell my sister quite often she did something stupid. I never had the intention of implying she WAS stupid, only that the specific thing she did at that moment could've been avoided if she had just stopped to think for a moment.
What I didn't realise back then was that for certain things that looked stupid to me, it was only because she was missing some vital experience to know that it wasn't going to work. So the problem was ignorence rather than stupidity.
The result was usually that she got really upset and responded half crying with "I'm not stupid" and refusing to listen to any explanation to why it wasn't going to work.
Since then I have learned that even smart people do/say stupid things. Mostly when they can't remember a vital piece of information or are missing a certain insight in that specific context. Without my sister crying out to me that "she wasn't stupid" even though I never said that I never would've realised how my way of wording actually felt to her.
From what you describe with your boss I see 2 possible reasons why he would use that way of wording:
1) He's ignorant about the effects like I was.
2) He's trying to manipulate you.
Either way you can simple answer the remark with:
Are you calling me stupid?
If your voice cracks or you choke up it only adds to that message. That his way of wording would imply that you ARE stupid (even though that's not literally what he says).
In case of (1) he might back off or at least explain the difference between "a stupid question" and "someone stupid asking a question". Either way, just mention that you are not interested in excuses but would still like to know the answer to your "stupid question" (using air quotes with your fingers optional). Or you could handle it like in this conversation:
OP: Sorry, what is X?
Boss: That's a stupid question.
OP: Are you calling me stupid?
Boss: No, I'm calling the question stupid, everyone knows what X is.
OP: I clearly don't, otherwise I wouldn't have asked what it was in the first place. So could you please just explain what X is without implying I'm stupid?
In case of (2) the manipulation is turned around. Especially if your voice cracks.
You have to do this [my way], you don't want to look like an idiot, do you?
Did you just call me an idiot?
No I'm saying you'll look like an idiot if you don't do it [my way], not that you are an idiot.
Care to explain what makes you think I would look like an idiot otherwise? I must be missing something.
He can either prove the stupidity of your question by explaining it so you can see it yourself (most likely you'll just have that aha-moment and can cary on like nothing happened, doing it [his way]) or he is unable to really explain it and the best he can do is ignore you further or keep trying to (sublty?) belittle you. The longer you then force him to explain himself the more you take the power out of his argument.
Virilo in his answer says it's an undesireable result to make your boss feel embarassed. I disagree with this. A person in a respectful position like your boss should still earn that respect. If he has no issue with implying other people are stupid, then those people should be allowed to call him out on that.
Important note: If you choose to handle it this way make sure to actually allow your boss to answer your original question.
If you just shut down after any mention of stupidity and stop listening altogether then it's THAT action that makes you look stupid. If on the other hand you only insist on being explained something very basic that you should've known since first grade while asking nicely to skip implying you're stupid, then you're only looking as stupid as your question actually is and shift the blaming back to your boss.