World number one Nadal has not been beaten since Nick Kyrgios knocked him out of the Western & Southern Open in August and took just over an hour to dispatch Fognini 6-3 6-1.
Federer, playing his first tournament since losing to Juan Martin del Potro in the quarter-finals of the US Open, later breezed through with a 6-4 6-2 win over Alexandr Dolgopolov.
The Swiss great, eyeing a second Shanghai Masters title, broke in the first game of the match and twice in the second set to march into the last eight.
Del Potro struck a blow for experience over youth, ousting third seed Alexander Zverev 3-6 7-6 (7-5) 6-4. The Argentine will now take on Viktor Troicki, who knocked out 12th seed John Isner.
Marin Cilic, the fourth seed, was a 7-6 (7-1) 6-4 winner against Steve Johnson, while Grigor Dimitrov got past Sam Querrey to set up an encounter with Nadal.
Richard Gasquet and Albert Ramos-Vinolas also reached the quarter-finals by beating Gilles Simon and Jan-Lennard Struff respectively.