This article is an exercise in arithmetic---we will run some numbers to see how much vote tampering would be required to change the results of, in this example, the 2016 presidential election. It appears that no foreign power was able to change the results of that election, but some commentators have assumed that changing election results would require a great deal of effort. If the goal of the bad guys is to put out a banana republic-style 99% win, that would be the case. But changing a democratic election requires changing a much smaller number of votes.
Here are some notes on my process. I used election data from Politico that you can find here. I also used public data on the number of counties in various states. My analysis is based on knowledge of the results---I know which states to flip. An adversary wouldn't know the exact total in advance although polling would give them some guidance; this assumption makes my analysis optimistic. On the other hand, I will count the number of votes that needed to be nullified to flip the result, which is an optimistic assumption. As in baseball, in which front runners playing each other has a larger effect than each team playing another, flipping a vote both takes it away from your opponent and gives a vote to you.
The popular vote totaled 62,523,126 for Clinton and 61,201,031 for Trump. That gives a difference of 1,322,095 or 1.1% of the total votes cast.
However, the United States presidential election is based on the Electoral College. The adversary needs to flip enough states to change those results, namely 270 out of 538. (As an aside, I believe that the wisdom of the Founding Fathers has been repeatedly affirmed and I understand their reasons for creating the Electoral College. Each voting system has its own concerns, as Martin Gardner showed in his outstanding article.) The election results gave 232 Electoral College votes to Clinton and 306 to Trump, a difference of 38. The winning difference was 7.1% of the total number of Electoral College votes.
In order to change the Electoral College results, we need to flip enough states to make up that difference. States with close popular vote totals require nullifying fewer votes to flip the state. I scanned the state-by-state results and found nine states whose popular vote difference between Clinton and Trump were 4% or less: Arizona, Colorado, Florida, Maine, Michigan, Nevada, North Carolina, Pennsylvania, and Wisconsin. The large number of close states gives attackers many options in how to affect results.
There are, in fact, several two-state combinations that provide the required Electoral College margin. I chose to look at two, Florida and Pennsylvania. Florida's vote was 4,485,745 for Clinton and 4,605,515 for Trump, a difference of 119,770 or 1.3% of the total. Pennsylvania's vote was 2,844,705 for Clinton and 2,912,941 for Trump, a difference of 68,236 or 1.2% of the total number of votes. Each of these states, as it turns out, has 67 counties. This difference is within the polling error of many polls, so nullifying the required number of votes may be difficult to detect by comparisons to polling.
Flipping the overall election results would require nullifying only 188,006 votes or 0.15% of the nationwide popular vote. That seems like a pretty small number to me. Even if the attacker chose to attempt to nullify many more votes to maximize their chance of success, the result would be a relatively small proportion of the votes cast.
My Princeton colleague Andrew Appel describes here his extensive work on voting machine technology. Some non-technical commentators, when faced with the work of Andrew and others, claim that changing machines would require too much effort, but the small number votes in danger calls that claim into question. And attacking the machines is not the only avenue available to attackers, who could also target voter registration systems. Voter registration attacks are sufficient to prevent voters from voting, which falls under the conservative vote nullifying methodology we have used here.
The underlying principle---that a relatively small number of votes need to be compromised to change the results of a democratic election---have been pointed out before. Our exercise on the 2016 election shows that changing the results of this election would have required affecting a small proportion of the vote, despite the unambiguous margins in the vote totals. Protecting the integrity of American voting will require significant and steady effort.