Covert attacks on the network topology of a power grid is considered. In a so-called man-in-the middle attack, an adversary alters data from certain meters and network switches to mislead the control center with an incorrect network topology while avoiding detection by the control center. A necessary and sufficient condition for the existence of an undetectable attack is obtained for strong adversaries who can observe all meter measurements and network data. For weak adversaries with only local information, a heuristic method of undetectable attack is proposed. Countermeasures to prevent undetectable attacks are also considered. It is shown that undetectable attacks do not exist if a set of meters satisfying a certain branch covering property are protected.