How investors should play the cybersecurity war

As companies and governments battle to protect their systems from the threat of online attacks and malware, Bank of America Merrill Lynch has published a list of stocks that could gain from the global drive to improve cybersecurity.

(CNBC explains: Malware)

Dimitri Otis | Photographer's Choice | Getty Images

Cybercrime costs the global economy up to $500 billion a year, according to computer security software firm McAfee, and Cisco estimates that cyber threat alerts grew 14 percent year-on-year in 2013.

Recently, U.S. retail giant Target suffered a massive data breach with the theft of personal information on up to 70 million customers, including names, addresses and phone numbers. Upscale retailer Neiman Marcus also announced a cyber attack in January.

(Read more: Companies fear 'cyber fatality' after Target attack)

"Cybersecurity has become a homeland security issue, with a worst-case 'Cybergeddon' scenario now on the table," said BofA strategists Sarbjit Nahal and Valery Lucas-Leclin in a report called "Safer world primer – global safety and security".

"Positively, IT is also enabling new safety & security solutions and opportunities across sectors."

The global cyber security market will reach $120.1 billion by 2017, up from $63.7 billion in 2011, according to forecasts from consulting company MarketsandMarkets.

Nahal and Lucas-Leclin listed several potential investment targets in the cybersecurity industry. These included Barracuda Networks, which supplies email and web security appliances to the likes of CitiBank, Coca-Cola, Harvard University, IBM and Oreal, and Santa Clara-based Palo Alto Networks, which specializes in firewalls.

(Read more: Cybercrime hits US companies harder: Report)

Other companies for which cybersecurity is a growth-driver or sole business include FireEye, Fortinet, Symantec, VMware Inc and Trend Micro, according to Bank of America.

Nahal and Lucas-Leclin wrote that the cybersecurity industry was part of a global "megatrend" in safety and security, which also covered the auto, energy, real estate and life sciences sectors, among others.

"Although it is difficult to accurately gauge the link between such exposure (to companies working in safety and security) and share price performance (as many factors outside the scope of this analysis are likely to play a role in short- and long-term price development), we still consider that safety and security exposure is an important and positive point to track, given that it is a megatrend with a 25-50-year lifespan," they added.

—By CNBC's Katy Barnato. Follow her on Twitter: @KatyBarnato