One would imagine that Starfleet Intelligence could do what Section 31 does. Section 31 lacks the moral compass and is far more pragmatic in it's approach.
I agree with you 100% that the legitimate foreign intelligence needs of the Federation can be served by Starfleet Intelligence rather than Section 31. I have a bit of a quibble though -- I don't actually think Section 31 is all that pragmatic. When you look at their operational history, almost every single operation we see them undertake actually results in massive blowback, often at the cost of thousands of Federation lives. Founder virus? Prompts the Female Shapeshifter to order the extermination of the Cardassian species and to order the Jem'Hadar to give a Pyrrhic victory to the Allies in Cardassia orbit, only averted when Odo shares the cure. Installation of Section 31 mole as chair of the Tal Shiar? The Tal Shiar under him fails to stop the rise of Shinzon, who subsequently kills Data and scores of Starfleet officers aboard the Enterprise in his attempt to genocide Earth. Recovery of Khan and his Augments in the Kelvin Timeline to provoke a war with the Klingons to install the head of Section 31 as military dictator of the Federation? Leads to the crash-landing of the USS Vengeance in the middle of downtown San Francisco, killing thousands of Federation citizens. The development of Control in the 2250s? Nearly leads to the extermination of all life in the Milky Way Galaxy.
Section 31 is the reverse Midas of the Federation. Everything they touch turns to shit.