Facebook has reported a major security breach in which 50 million user accounts were accessed by unknown attackers.

Key points: About 90 million people were logged out to help fix the problem

About 90 million people were logged out to help fix the problem Anyone having difficulty logging back in is advised to visit the site's help centre

Anyone having difficulty logging back in is advised to visit the site's help centre There is no need to change Facebook passwords

In a blog post, the company said hackers exploited a bug that affected its "View As" feature, which lets people see what their profiles look like to someone else.

That would let attackers steal "access tokens," which are digital keys that Facebook uses to keep people logged in.

Possession of those tokens would allow attackers to "seize control" of user accounts, Facebook said.

Specifically, from the View As feature, a bug somehow allowed a video uploader to appear for sending "happy birthday" messages, Guy Rosen, Facebook's vice president of product management said.

Another bug then created an access token that made Facebook think the hacker had legitimately signed in with the account being viewed.

"We haven't yet been able to determine if there was specific targeting," Mr Rosen said in a call with reporters.

"It does seem broad. And we don't yet know who was behind these attacks and where they might be based."

Facebook said it had taken steps to fix the security problem and alerted law enforcement.

To deal with the issue, Facebook reset some logins, so 90 million people have been logged out and will have to log in again.

That includes anyone who has been subject to a View As lookup in the past year.

Access to third party apps could be the bigger problem

In a call with reporters on Friday (local time), chief executive Mark Zuckerberg said the company does not know yet if any of the accounts that were hacked were misused.

Jake Williams, a security expert at Rendition Infosec, said the stolen access tokens would have likely allowed attackers to view private posts and probably to post status updates or shared posts as the compromised user, but would not affect passwords.

"The bigger concern (and something we don't know yet) is whether third party applications were impacted," Mr Williams said in a text exchange.

"Facebook offers a login service for third parties to allow users to log into their apps using Facebook. In other words, Facebook is providing the identity management for countless other sites and services. These access tokens that were stolen show when a user is logged into Facebook and that may be enough to access a user's account on a third-party site."

Mark Zuckerberg was called in to testify in a congressional hearing over Facebook's privacy policies this year. ( AP: Pablo Martinez Monsivais )

The hack is the latest setback for Facebook during a year of tumult for the company.

News broke early this year that a data analytics firm that once worked for the Trump campaign, Cambridge Analytica, had improperly gained access to personal data from millions of user profiles.

Then a congressional investigation found that agents from Russia and other countries have been posting fake political ads since at least 2016. Mr Zuckerberg appeared at a Congressional hearing over Facebook's privacy policies in April.

Facebook has more than 2 billion users worldwide.

The company said people do not need to change their Facebook passwords, but anyone having trouble logging on should visit the site's help centre.

Those who want to log out can visit the Security and Login section of their settings, which lists the places that people are logged into Facebook.

It offers a one-click option of logging out of all locations.

'It's yet another warning'

Ed Mierzwinski, the senior director of consumer advocacy group US PIRG, said the breach was "very troubling".

"It's yet another warning that Congress must not enact any national data security or data breach legislation that weakens current state privacy laws, pre-empts the rights of states to pass new laws that protect their consumers better, or denies their attorneys general rights to investigate violations of or enforce those laws," he said in a statement.

Analyst Michael Pachter said, "the most important point is that we found out from them," meaning Facebook, as opposed to a third party.

"As a user, I want Facebook to proactively protect my data and let me know when it's compromised," Mr Pachter said.

"Shareholders should ultimately approve of Facebook's handling of the issue."

AP