Many practical complex networks, such as the Internet, WWW and social networks, are discovered to follow power-law distribution in their degree sequences, i.e., the number of nodes with degree in these networks is proportional to for some exponential factor . However, these networks also expose their vulnerabilities to a great number of threats such as adversarial attacks on the Internet, cyber-crimes on the WWW or malware propagations on social networks. Although power-law networks have been found robust under random attacks and vulnerable to intentional attacks via experimental observations, how to better understand their vulnerabilities from a theoretical point of view still remains open. In this paper, we study the vulnerability of power-law networks under random attacks and adversarial attacks using the in-depth probabilistic analysis on the theory of random power-law graph models. Our results indicate that power-law networks are able to tolerate random failures if their exponential factor is 2.9, and they are more robust against intentional attacks if is smaller. Furthermore, we reveal the best range for the exponential factor by optimizing the complex networks in terms of both their vulnerabilities and costs. When , the network maintenance cost is very expensive, and when the network robustness is unpredictable since it depends on the specific attacking strategy.