Nothing canonically says that 31 is above the law, merely that our heroes don't have the means to file a complaint about Section 31. While we may interpret Bashir's treatment by Sloane to be improper, for all we know, there's some sort of legal justification for it. For a real world example, drone strikes in the Middle East against terrorists. Normally it would be quite illegal for the Defense Department to assassinate American citizens, especially without putting them on trial first. But my country (apologies, I don't know if you're American or not) is doing just that. http://www.rollingstone.com/politics...ecret-20120416
Regarding a lack of canonical legal grounds for 31 to exist: absence of proof isn't proof of absence. We don't know the ins and outs of the Federation's structure and laws. We've gotten to see some of it, mostly through the military lens. That doesn't mean that just because we haven't seen something, it doesn't exist.
As for Starfleet answering to the executive branch: certainly that seems to usually be the case. But Memory Alpha says that the Fed Council (legislative) occasionally gives Starfleet orders (Star Trek 4 being a good example). No reason Section 31 couldn't be an aspect of Starfleet that falls under non-executive authority.
As for spying on the President: while spying on him may be illegal, that act alone wouldn't make 31 illegal. Additionally, I don't remember the context under which we found out that 31 had an operative in the Prez's cabinet. Do they make it clear that the operative was indeed spying, or merely that a 31 employee works in the cabinet, perhaps the way defense department officials advise the president?
Please let me be clear: I'm not saying definitely that 31 is a Fed agency. I think that it was purposefully framed to be wrapped in shadows. It's certainly either a rogue organization or a legit organization with some rogue individuals on its payroll. Debating stuff like this is why I come here.