Is there a maximum duration for an MS in Germany, and are there allowances for medical leave?
It is almost always possible to take a vacation semester, which is either free of charge, or at a fraction of the standard fee you would normally pay. (But you also lose some student perks, such as the public transportation ticket and student discounts.)

But you have to check with your Studienordnung or Prüfungsamt. You will certainly have a maximum number of semesters for your studies as well as a maximum time between finishing your last lectures and beginning your thesis. 

In case of illness, as long as you have an official waiver from a doctor saying you can't study/work, most of these limits don't apply.

tl;dr: Check with your "Prüfungsamt"