In an opening statement to the Senate Commerce Committee, Mayer apologized to Yahoo's users, blamed "Russian agents" for the breach and said that Yahoo quickly worked to protect user accounts and contact law enforcement.
Mayer apologized for both breaches and said that its hard for companies to fight against state-sponsored attackers who "tend to be more sophisticated, more persistent and who attack more targets.They're very good at hiding their tracks", she said.
Ms Mayer said increasing the potential consequences of hacks for the perpetrators would help deter attacks, on both the state-sponsored and commercial side.
'As we all have witnessed: no company, individual or even government agency is immune from these threats, ' Mayer said.
Mayer is part of a long line of company executives and former executives who have made their way to Capitol Hill in recent years to explain how their company fell victim to a cyberattack.
The digital diva - who left the helm of Yahoo earlier this year after it was acquired by Verizon - was forced to testify with a subpoena after she refused several requests to testify voluntarily, according to a Tuesday report.
The hearing comes after Equifax said failure to install a security update may have led to exposure of information of more than 145 million people in the U.S. and nearly 700,000 people in the UK.
He also said the company is on schedule to release a computer app in January that will allow consumers to lock and unlock their credit data.
"Social security number a static identity as a basis for our online identity will not be secure is not secure and will never be secure in the future", said Entrust Datacard Corp.
But that change would be a stark change from the current system, said Paulino de Rego Barros, acting boss of Equifax. "Not fines, or other penalties - or real deterrents", said Connecticut Sen.
However, it was revealed later that three billion user accounts were affected.
The Senate Commerce Committee took the unusual step of subpoenaing Mayer to testify on October 25 after a representative for Mayer declined multiple requests for her voluntarily testimony.