A fan ran onto pitch during the dying seconds of the Bavarians' victory at the Imtech Arena and struck the Frenchman in the face with his scarf.
The supporter then made an offensive hand gesture towards Ribery before eventually being apprehended by stewards and escorted from the field of play.
Ribery had been making his first start of the season for Bayern after missing the opening weeks of the 2014-15 campaign through injury.
The 31-year-old marked his return with a deflected strike 10 minutes into the second half, after first-half efforts from Robert Lewandowski and David Alaba had put Pep Guardiola's men in complete control of the tie.
Pierre-Michel Lasogga pulled a goal back for the hosts in the closing stages, but Bayern held on comfortably to set themselves up nicely for Saturday's Bundesliga clash with Borussia Dortmund at the Allianz Arena.