Ex-Brighton & Hove Albion man and current Stuttgart hotshot Undav struck twice in the space of five minutes in the first half before Edin Dzeko gave the hosts a lifeline, but Germany always looked the more likely to score again in the latter stages and came away with all of the spoils after a monumental effort.
Initially lamenting the absences of Jamal Musiala and Kai Havertz, Germany could not pick the Bosnia-Herzegovina lock in the opening 25 minutes, being met with stiff resistance from Sergej Barbarez's men as the hosts dug in for a fight.
However, within the space of five minutes in the second quarter of the match, Undav had a brace to his name, firstly side-footing home after a delicate touch from Florian Wirtz before latching onto a Maximilian Mittelstadt delivery into the box.
While Julian Nagelsmann's team were highly comfortable for the most part, Bosnia-Herzegovina showed a glimpse of what they are capable of on the counter; Ermedin Demirovic struck the crossbar mere seconds after Germany were denied a penalty at the other end.
Barbarez's side were immediately under the cosh at the start of the second period too, but after Undav had a hat-trick goal disallowed and Germany failed to add to their lead, Dzeko headed home to reduce the deficit and set up an unmissable final 20.
A member of the Bosnia-Herzegovina coaching team was sent off as tempers rose, but Germany were never under serious threat of throwing their advantage away as they moved onto seven points from three games in League A Group 3.
As the Netherlands could only manage a 1-1 draw with Hungary in the group's other game, Die Mannschaft are now two points clear at the top, while Bosnia drop to fourth after equalling their longest-ever winless run of nine straight matches.
BOSNIA-HERZEGOVINA VS. GERMANY HIGHLIGHTS
Deniz Undav goal vs. Bosnia-Herzegovina (30th min, Bosnia-Herzegovina 0-1 Germany)
Germany have lift-off on the half-hour mark, as Undav is the beneficiary of an absolutely exquisite assist from Bayer Leverkusen star Wirtz.
The latter beats the offside trap with a perfectly-timed run to meet Robert Andrich's lofted pass, but rather than go for goal from a few yards out, he taps the ball back to the arriving Undav.
The Stuttgart striker ensures that Wirtz would not live to regret being unselfish with a clinical first-time finish into the bottom corner!
Deniz Undav goal vs. Bosnia-Herzegovina (35th min, Bosnia-Herzegovina 0-2 Germany)
Make that three goals in two starts for Germany for Undav, who doubles his and Die Mannschaft's tally for the night just five minutes after his opening strike.
On this occasion, left-back Mittelstaft delivers a low ball to the six-yard box, where Undav gets ahead of his man and comfortably side-foots home to put Germany in cruise control.
Deniz Undav disallowed goal vs. Bosnia-Herzegovina (58th min, Bosnia-Herzegovina 0-2 Germany)
Undav momentarily thinks that he has his hat-trick goal, picking up the pieces after Tim Kleindienst's close-range effort is saved by Nikola Vasilj, but Kleindienst had just strayed offside as Mittelstadt delivered the cross.
Edin Dzeko goal vs. Germany (70th min, Bosnia-Herzegovina 1-2 Germany)
Germany should have been out of sight, but instead, the 2014 World Cup winners are in for an incredibly nervy finale, as Bosnia-Herzegovina skipper Dzeko cuts the deficit in half!
The 38-year-old peels away at the back post to meet Benjamin Tahirovic's corner, and his header finds the bottom corner past Alexander Nubel, who did not cover himself in glory with a weak attempt to push the ball past the post.
MAN OF THE MATCH - DENIZ UNDAV
Now boasting double the amount of goals than he has starts in a Germany kit, Undav has taken to international football like a duck to water, even if he was a very late bloomer on the international scene at the age of 28.
Undav took both of his first-half finishes like a seasoned poacher, and he would have gone home with the match ball had Kleindienst not strayed slightly offside before his disallowed goal in the second, but two was ultimately enough for Die Mannschaft.
BOSNIA-HERZEGOVINA VS. GERMANY MATCH STATS
Possession: Bosnia-Herzegovina 27%-73% Germany
Shots: Bosnia-Herzegovina 8-12 Germany
Shots on target: Bosnia-Herzegovina 1-4 Germany
Corners: Bosnia-Herzegovina 3-2 Germany
Fouls: Bosnia-Herzegovina 10-9 Germany
BEST STATS
WHAT NEXT?
Nagelsmann's side now embark on a long flight home and have just two full days to recover before they go again, hosting fellow heavyweights Netherlands at the Allianz Arena on October 14.
Meanwhile, Bosnia-Herzegovina hope to keep their slim chances of a top-two finish alive when they pit their wits against Hungary in Zenica at the same time on Monday evening.