We all know that unprotected sex puts promiscuous bedfellows at risk of sexually transmitted infections, but now it seems that those logging on to seek gratification from behind the safety of their computer screen are opening themselves up to viruses of a different kind.

Top porn websites – some of which are among the most-visited sites on the internet – are putting users' computers at risk, according to a recent study.

Researcher Conrad Longmore claims that advertisements displayed by the sites were found to contain malware programs, which install harmful files on users' machines without their permission.

Download the new Independent Premium app Sharing the full story, not just the headlines

Mr Longmore told the BBC that two popular sites – XHamster and PornHub – pose the greatest threat.

While the sites themselves do not host any malware themselves, embedded adverts could cause problems for users.

Mr Longmore said: "We call these malicious advertisements 'malvertising'".

"The way the ads are bought and sold across all websites is incredibly complex.

"Ads can often be repackaged and resold so that it is hard to tell where they originated from, and the criminals behind them go to great lengths to disguise what they are doing."

Using Google's diagnostic advice service, Mr Longmore found that xhamster – the 46th most popular site on the internet, according to monitoring firm Alexa – had 'malvertising' on 1,067 out of 20,986 pages screen over the last 90 days, accounting for 5 per cent of its content. According to Alexa, the average XHamster user visits just over 10 pages per visit, meaning they have a potential 42 per cent risk of coming across damaging adverts each time they log on.

Another popular site, PornHub, was found to have malware within advertising on 12.7 per cent of its pages.

Last year, the world's most popular porn site (and 34th most visited site on the net), XVideos, was found to be exposing its users to malware with banner adverts, though recent research appeared to show that the site had "cleaned up," removing all harmful advertising.

Mr Longmore said that there needs to be a clear reporting system in place, so that users that discover malicious adverts can make the site's owners aware.

However, he said that users are often hesitant to "kick up a fuss" while visiting pornagraphic websites.

"Part of the problem is that porn is a taboo subject," he told the BBC.

"But the reality is that these are hugely popular sites with many of them in the top 100 most popular sites globally. Some of them pull in more traffic than the BBC, so this is potentially a very big issue.

"Site operators could put a quick reporting mechanism on their sites to flag up bad ads and other concerns, and ad networks should also take some responsibility here.

"I don't see that happening any time soon, and perhaps the best thing that users of these sites can do is ensure that their machines are up to date."

The owners of XHamster and PornHub are yet to comment on the findings.