Web security

Malware

Definition

Malware (malicious software) is a program or piece of code introduced into a system to harm its owner or users: stealing data, taking control, encrypting files, sending spam or redirecting visitors. Viruses, worms, Trojans and ransomware are all forms of malware.

Malware, Web security

Malware is short for malicious software. The NIST glossary defines it, in essence, as software or code inserted into a system, usually covertly, to compromise the confidentiality, integrity or availability of its data and functions. The term covers both a virus on a personal computer and a few lines of PHP slipped into a WordPress theme.

The main families

  • Virus: code that attaches itself to a file or program and spreads when that file or program runs.
  • Worm: a program that spreads on its own from one machine to another over the network.
  • Trojan horse: software that looks useful but hides a malicious function. Pirated themes and plugins are the textbook example on WordPress.
  • Spyware: collects information (keystrokes, credentials, browsing) without the user's knowledge.
  • Ransomware: encrypts or locks data and demands a ransom.
  • Backdoor and web shell: hidden access that lets the attacker come back.
Video: “What is Malware?” (Kaspersky)

Malware on a website

On a website, malware rarely takes the form of an executable file. It consists of PHP or JavaScript scripts added to files, or content injected into the database. It gets in through an unpatched plugin vulnerability, a stolen password, a “nulled” plugin downloaded outside official channels, or, more rarely, through a supply chain attack that booby-traps a legitimate update.

Three-column table of the effects of malware on a WordPress site: against visitors with redirects, injected scripts and fake payment forms; against SEO with hidden spam pages, injected links and the site being flagged as dangerous; on the server with backdoors, added administrator accounts and outgoing spam
Website malware rarely targets the owner directly: it exploits the site's visitors, its search rankings and its server.

Pirated versions of themes and plugins deserve a special mention: our article on “nulled” plugins and their backdoors sums up what researchers have found in them.

Signs of an infection

  • visitors, especially on mobile, redirected to another site, while you see nothing when logged in;
  • unknown pages in search results, often in another language;
  • a warning from the browser or from Search Console;
  • an administrator nobody created, PHP files in the media folder.

Our guide Has my WordPress site been hacked? lists the checks to run, and the step-by-step cleanup procedure explains how to get back to a clean slate.

For WordPress: reducing the risk

  • Only install themes and plugins from the official directory or from their developer, and keep them up to date.
  • Disable the Dashboard file editor with define( 'DISALLOW_FILE_EDIT', true ); in wp-config.php.
  • Apply strict permissions: the WordPress documentation suggests 755 for directories and 644 for files.
  • Keep regular backups, of both files and database, so you can restore a clean version.

WP Masquerade is not an antivirus and does not clean up an infected site. Its integrity check compares the WordPress core files against the official list every day and reports modified files or unknown PHP files; it does not check plugins, themes or media.

Further reading

  • Article Has my WordPress site been hacked? Signs, checks and tools
  • Article Cleaning up a hacked WordPress site: the step-by-step procedure
  • Page WordPress file integrity check

Sources

  1. NIST CSRC Glossary: malware (external link, opens in a new tab)
  2. MITRE ATT&CK T1505.003: Server Software Component, Web Shell (external link, opens in a new tab)
  3. WordPress Advanced Administration: Hardening WordPress (external link, opens in a new tab)

All definitions

WordPress security, without the noise

One e-mail when something matters: new attacks seen in the wild, plugin updates and practical guides. No spam, unsubscribe in one click.

Start free, go Pro when you’re ready

The free version already hides WordPress and moves the login page. Pro adds aliases, two-factor authentication and monitoring.