The violent and graphic images and videos confronting Facebook users in their newsfeeds have been doctored to show celebrities, including teen star Justin Bieber and singer Rihanna, in indecent poses, as well as other sexually explicit content.

Some Facebookers have also been tricked into sharing offensive content with others, after pasting “malicious” content into their browser URL bar.

Facebook bosses confirmed they have managed to stop the spam, but warned users to remain vigilant to keep their accounts from being hijacked.

There is speculation Anonymous – a loose global affiliation of hackers, which has targeted other major companies in the past, is responsible.

A group claiming allegiance to Anonymous claimed in a YouTube video that it had created the “Fawkes virus” to attack Facebook.

An automated voice in the video said: “Using a simple Facebook account, the worm can be carried into other accounts with little or no interaction.

“We did not expect the intensity with which this would spread.”

Facebook spokesman, Andrew Noyes said in a statement: “We experienced a co-ordinated spam attack that exploited a browser vulnerability.

“Our efforts have drastically limited the damage caused by this attack and we are now in the process of investigating to identify those responsible.”

He added: “Protecting the people who use Facebook from spam and malicious content is a top priority for us and we are always working to improve our systems to isolate and remove material that violates our terms.”

In the meantime, Facebook warned users to never cut and paste unknown code into a browser’s address bar, and to always use an up-to-date browser, as well as to flag and report any suspicious content.