Washington— A spate of hacking attacks has put U.S. states on edge ahead of November’s presidential vote as election officials rush to plug cybersecurity gaps with help from the federal government.

Nine states have asked for “cyber hygiene” scans in which the Department of Homeland Security looks for vulnerabilities in election authorities’ networks that are connected to the internet, according to a DHS official who asked not to be identified because the information isn’t public. With less than two months before the election, DHS wants more states to sign up.

The threat — primarily from foreign hackers or intelligence agencies — affects states that are reliably Democratic or Republican as well as key battlegrounds including Pennsylvania and Ohio, officials and cybersecurity experts said. While hackers may not be able to change the actual outcome from afar, they could sow doubts by manipulating voter registration websites, voter databases and systems used to track results on election night.

“We’re certainly on high alert,” said Dean Logan, the registrar-recorder and county clerk in Los Angeles County, the nation’s biggest electoral district. “Across the whole network of services and online applications for the county there are frequent indications of attempts to get into those systems.”

Most states use voting equipment that can generate a paper record, allowing for audits or recounts if the result is close or tampering is suspected.

Among the exceptions is Pennsylvania, which both Hillary Clinton and Donald Trump are targeting as a priority.

The electronic voting machines in 50 of Pennsylvania’s 67 counties leave no paper trail, according to Verified Voting, a California-based nonprofit that monitors voting methods.

Many of those counties use touch-screen machines, which are especially vulnerable, according to Andrew Appel, a computer science professor at Princeton University who stores in a warehouse the old voting machines that his research teams have hacked over the past dozen years.

Though the touch-screen machines aren’t connected to the internet — where hackers can do damage from around the world — someone with physical access to the devices could employ techniques such as inserting a cartridge carrying malware that could reprogram their software, he said. Similar machines are used in Louisiana, New Jersey, South Carolina, Tennessee and Texas.

“There’s no way to know that they have been hacked,” Appel said. “And there’s no way to recover what the vote should have been, and there’s no way to know that the votes may be wrong.”

In a recent simulation, Symantec Corp. said its workers were able to easily hack into an electronic voting machine. It was possible to switch votes as well as change the volume of data, said Samir Kapuria, senior vice president and general manager of Symantec’s cybersecurity group.

“It was pretty vulnerable to multiple attacks both physically as well as when that information got transmitted upstream for the tabulation systems,” Kapuria said, without providing the machine’s maker or saying where it is used. Symantec is working with the manufacturer to make improvements, he added.

DHS’s major concern isn’t necessarily a hacker changing ballots on Election Day, but an actor stirring up enough confusion in the “election infrastructure” as to undermine public confidence in the vote, according to the agency’s official.

The DHS “cyber hygiene” assessments are quick tests that let states know of holes they should urgently fix.

The department also is in talks with some states to do on-site visits to scan election authorities’ internal networks that aren’t linked to the internet. But with less than two months to go, few states will receive such a deep dive. States have told the feds it would be disruptive at this point to examine individual voting machines, so DHS will have to save those tests for after the election.

Besides the voting machines, hackers looking to cause chaos on Election Day could alter voter registration records and electronic poll-books, used to verify voters’ identities at precincts. Local jurisdictions also worry about hackers tampering with websites that tell people where to vote or provide other information about the voting process.

Meddling with systems that tabulate and report the votes on election night — whether state election boards or media organizations — is another potential entry point for those wanting to cause mischief and undercut public confidence.