The central risk of a CIA agent disclosing sensitive information to someone with whom he was maintaining an illicit extra-marital affair is minor compared with the possibility the affair could be used against him as blackmail.
The moment General Petraeus put himself into a position where his private behavior became something he needed to hide from the public — as stated in his resignation letter— he essentially put national security at risk. It's exactly the type of compromise which would put any government worker at immediate risk of losing a Top Secret clearance.
In fact, anyone applying for a Top Secret for Sensitive Compartmentalized Information (TSSCI) clearance would be denied for simply having any outstanding debt. Something as simple as a DUI or alcohol problem can endanger passing a Secret Clearance review, which is one lower than TSSCI (also referred to as a 'need-to-know').
Petraeus, as the head of the CIA, certainly had the type of Top Secret clearance which allowed him comprehensive access to the most sensitive pieces of National Security information.
Had a foreign agent found out Petraeus was involved in an extramarital affair, the resulting leverage could have been astounding.
That the CIA itself didn't know of Petraeus's activities is itself astounding as well.
Please follow Military & Defense on Twitter and Facebook.