I believe I can solve the first riddle with just one question.
I assume that the dwarves are cursed to answer questions alternating between true answers and false answers, regardless of the knowledge or intelligence of the dwarf being questioned.
The question is:
If, after asking you this question, I ask you "how do we get out?", what answer could you not give me due to truth-speaking restrictions?
Truth-speaker reasoning:
Next time, I will have to answer the question falsely.
So I cannot answer the next question with the truth.
So for that question, I could not answer with the correct way out.
I am a truth-speaker right now, so I must answer truthfully and say the correct way out.
False-speaker reasoning:
Next time, I will have to answer the question truthfully.
I cannot answer the next question with falsehood.
If I answer this question with an incorrect way out, then I have answered it with the truth, because if I am asked that question next, I cannot answer with falsehood.
If I answer this question with the correct way out, then I have answered it with falsehood, because if I am asked that question next, I can, and must, answer it with the correct way out.
Therefore, I must answer the question with the correct way out.
So ask any one of the dwarves that question, then do what he/she says about how to get out.
If dwarves explode under these circumstances, because they don't know the correct way out and thus don't know if they're telling the truth, then instead ask a random dwarf
If, after asking you this question, I ask you "which of you knows the way out?", what answer could you not give me due to truth-speaking restrictions?
Then ask the dwarf who knows the way out the first question of this post.