Facebook has identified the perpetrators behind the massive spam attack that bombarded users with large volumes of violent and explicit content earlier this week and is pursuing legal action against them, according to a spokesperson for the social networking giant.

The spam attack tricked unsuspecting users into copying malicious Javascript code into the URL bar of their Web browsers to exploit a cross-site scripting vulnerability, Facebook said Nov. 15. It was not clear which browser had the vulnerability but Facebook claimed its engineers were bringing the problem under control.

The "self-XSS" exploit refers to the fact that social engineering techniques were employed to trick users into entering the code necessary to execute the attacks, as opposed to other types of XSS-based attacks where the perpetrators inject the code on to the Website.

Users are often tricked by a "giveaway, contest, or sweepstakes for some fantastic prize, and to qualify you need to paste this magic code into your browser," Chester Wisniewski, a senior security advisor at Sophos, wrote on the Naked Security blog.

For over 24 hours starting Nov.14, Facebook users were bombarded with explicit and violent content on their newsfeeds. The images, which included adult content, Photoshopped images of celebrities in compromising positions and extreme violence, were spread throughout the site, often without the knowledge of users.

Many users took to Twitter to vent their frustration at the images and to claim they were deactivating their accounts altogether.

To bring the problem under control, Facebook engineers have implemented "enforcement mechanisms" to automatically shut down malicious pages that result from the self-XSS exploit, the social networking giant said. If a user fell victim to the attack, the mechanism should detect that compromise and roll back the account to delete all malicious activity.

Accounts that appear to have been created for the sole purpose of launching these types of attacks will also be shut down, according to Facebook. Affected users are also going through "educational checkpoints" to learn how to protect themselves. Backend measures are also in place to reduce the rate of these attacks.

"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," a Facebook spokesman said, noting that user accounts or data were not compromised as part of this attack.

Back in May, Facebook rolled out a "Self-XSS Protection" security feature to prevent users from inadvertently participating in a cross-site scripting campaign much like this spam attack. The feature was supposed to detect when a user pasted known XSS malicious codes into the address bar and display a challenge window to confirm the user meant to do this. Facebook has update the feature to stop users even when unknown code is entered, as happened in this attack.

Facebook was working with major browser companies to address the underlying issue and that Microsoft had implemented some protections in Internet Explorer 9, according to a Facebook blog post announcing the security feature.

The attack was unusual, even for Facebook which is hit by a new clickjacking or spam campaign practically every day. "Nearly 100 percent" of Facebook scams lead to some form of financial payout for the scammer, even if it's just stealing profile information. This attack seemed to be a "purely malicious act" targeting the site's reputation for a "family friendly environment," Wisniewski said.

There was speculation that this attack could have been a delayed attack from the hacktivist group Anonymous, who had promised a "massive" attack on Facebook on Nov. 5 for not respecting user privacy. Bitdefender researchers reported a new worm that targets Facebook accounts and opens a backdoor on the compromised computer that may be the "Fawkes Virus" promised by the hacker collective in July, George Lucian Petre, product manager for social media security at BitDefender wrote on the company blog. However, Anonymous did not claim credit for the spam attack or this virus on any of its usual channels on Twitter.