PHP2Shell: How to Check If You’re Affected

PHP2Shell: How to Check If You're Affected

A name like php2shell usually arrives before the detail does: a screenshot, a feed post, a client email asking whether you are safe. The question behind it is narrow, and a php2shell check if affected is how you settle it without either panicking or waving it away. It breaks into four parts, in order: what the name actually maps to, which of your internet-facing hosts could be running PHP at all, what the outside world can tell you about them, and what only the host itself can confirm.

There is a fifth part that most coverage skips entirely. Checking whether something already got in.

Before you panic: what the name php2shell actually maps to

Informal names circulate for days before anyone cites an identifier. They are coined on social feeds, repeated by vendor blogs chasing the news, and sometimes they describe a genuine new flaw, sometimes a repackaged old one, and sometimes a proof-of-concept tool rather than a vulnerability at all. So the first job is dull and unavoidable: tie the name to a CVE number or a named vendor advisory, and read the affected version ranges as published, not as summarised in the headline.

Three sources settle it. The PHP release changelog on php.net, which states which versions carry which security fixes; your distribution’s security tracker, which states whether the fix has reached the package you actually installed; and the NCSC advisory feed, which is a reasonable sanity check on whether UK organisations are being told to act. A screenshot of an exploit running on someone’s laptop is not a source.

Then read the affected configuration, because it usually matters more than the product name. PHP running as mod_php inside Apache, PHP-FPM behind nginx, a CGI handler and a FastCGI socket are not equally reachable and not equally exposed. CVE-2024-4577, the PHP-CGI argument injection flaw disclosed in June 2024, is the cleanest worked example: it affected PHP on Windows in CGI configurations (including some default stacks where php.exe was reachable), and it was taken seriously fast, with CISA adding it to its Known Exploited Vulnerabilities catalogue within days of publication. A Linux host running PHP-FPM with the same version number was never in scope. Same version, different answer, because the configuration decided it.

Before you start, agree the three outcomes you are allowed to record: affected, not affected, unproven. Unproven is a real answer. It is also the one people quietly convert into “fine”by Friday afternoon, which is why it needs a named owner and a follow-up date attached the moment you write it down.

Step one: list every internet-facing host that could be running PHP

The host that bites you is almost never the main website. It is a campaign microsite built for a product launch in 2019, an old content management install on a subdomain nobody has logged into since the agency changed, a staging copy left public because someone needed to show a client, or an acquired brand’s estate that still resolves to its original hosting. None of these is exotic. They are the ordinary sediment of an organisation that has existed for a few years and moved quickly, and they are precisely the hosts your internal asset register does not list.

That gap is why a patch sweep across known servers can report complete and still leave the affected box answering on port 443.

Start from a seed domain and expand outwards. Certificate transparency logs will give you hostnames that were issued a certificate at some point, which is a different and usually larger set than the one in your DNS zone. Add DNS records, registration data for domains you own under other names, and any addresses your hosting accounts still hold. What you have at the end is a candidate list, not a finished inventory. The seed-to-inventory discovery process exists to turn one into the other.

Resolve the candidates, then check what answers on 80 and 443. The shape of a typical triage is reassuring once you have done the work: a seed domain might return hundreds of hostnames from certificate logs, a fraction of those resolve, fewer answer on either port, and only a handful fingerprint as PHP at all. The shortlist is small and workable. Getting to it honestly is the hard bit.

Two practical notes. Check the IP as well as the hostname, because one address commonly serves several virtual hosts under different names, and the PHP application may be the one you were not looking for. And mark anything hosted or managed by a third party as you go, because your checking options there are legally and practically different.

Step two: the external signals that make a host likely affected

Passive observation means reading what a host volunteers when you make an ordinary request. It is quiet, it needs no permission, and it is where most of your triage time should go.

The signals worth collecting:

  • A Server header naming Apache, nginx or IIS, and any module detail alongside it.
  • An X-Powered-By header such as PHP/7.4.33, which is the most direct version signal you will get for free.
  • A PHPSESSID cookie in the response, which says PHP is in play even when the version is hidden.
  • A default PHP error page, or.php extensions and handler paths visible in links, forms and redirects.
  • Response behaviour that distinguishes mod_php from PHP-FPM behind nginx from a CGI handler, such as which paths return 404 against 403 against a PHP-generated error.

Now the part that trips people up. A missing version string is not reassurance. With expose_php off in php.ini, a reverse proxy stripping headers, or a CDN sitting in front rewriting them, external observation returns nothing useful about what is installed. The honest status for that host is unproven, with a date. Silence is not safety; it is just silence.

Version-string matching on its own is the biggest source of false positives in this kind of work. Debian, Ubuntu and Red Hat all backport security fixes into their packaged builds while keeping the upstream version number unchanged, so a host cheerfully reporting PHP 8.1.2 may carry a patch released months later. Judge it on the distribution package version and its changelog entry, not on the number php -v prints. Several organisations have spent a weekend upgrading hosts that were already fixed.

Finally, weigh reachability as heavily as version. Where a flaw depends on a specific handler or request path, establish whether that route answers from the internet before you escalate the host. A box with an affected PHP build and no CGI handler exposed is a lower priority than a box one version behind with the vulnerable path wide open. That distinction between likely and definitely is the whole of passive versus active vulnerability detection, and it is worth being precise about which one you are reporting.

Step three: prove it, or disprove it

External signals narrow the list. Host-side evidence settles it.

On a box you control, four things give you an answer you can defend: the installed package version and the changelog entry for that specific package; the active SAPI (what php -i or phpinfo reports as Server API, which tells you whether you are running FPM, CGI, mod_php or CLI); the web server’s handler configuration, meaning what actually maps requests to PHP; and any vendor hotfix flag where a control panel or managed stack applies its own fixes. Record the output, not your conclusion about it.

Active external testing is the other route, and there is a clear line in it. A request that confirms a handler exists and responds is a safe confirmation. Running a public exploit against production to see whether it pops a shell is not triage, it is an incident you caused yourself. If you need that level of proof, do it against a staging copy, or get it done under a proper scope with authorisation in writing.

For agency and shared hosting, ask for two specific things in writing: the exact PHP package version running on your site, and the date the relevant fix was applied. “We are fully patched”is not an answer; a version string and a date is. And get written permission before you test anything you do not own, because the Computer Misuse Act 1990 does not care that you were being helpful.

Write the evidence against each host as you go. A version, a source, a date, an owner. Keeping a small set of fields per internet-facing asset is what turns next month’s version of this question from a lost morning into a ten-minute check.

Step four: check whether something already got in

If a flaw has been publicly exploited for a while and your host was exposed for any part of that window, patching answers tomorrow’s question and ignores yesterday’s. Look for a webshell before you close the ticket.

Webshells land in predictable places: writable upload directories, theme and plugin folders, cache and temp paths, and anywhere a deployment process does not overwrite. The cheapest signal is timestamps. Any.php file whose modification time does not match a deployment you can account for deserves a look, and a file hiding in an images directory deserves two.

In the logs, four patterns are worth the time: POST requests to.php paths that your application does not expose; requests carrying long base64 or URL-encoded query strings; bursts from a single source address hitting many paths in sequence; and outbound connections from a web server that should only ever be answering inbound traffic. The last one is the strongest, because it is hard to explain away.

Preserve before you clean. Take a disk image or a full copy, keep the logs off the host, note the timestamps you found. A rebuild destroys exactly the evidence an insurer, a client or a regulator will ask for a fortnight later.

If personal data may be involved, the UK GDPR clock applies: a notifiable personal data breach must be reported to the ICO within 72 hours of becoming aware, where the breach is likely to result in a risk to people’s rights and freedoms. Significant cyber incidents can also be reported to the NCSC. Both routes assume you still have the evidence.

Fixing it, and making the next scare a ten-minute job

Order of work: patch or upgrade first; disable handlers and SAPIs you do not use, because an unused CGI route is pure exposure; add a rule at the edge only as a stopgap while the patch is scheduled, never as the fix; then retest externally and confirm the signal actually changed. A WAF rule that nobody removes becomes the reason the host is still unpatched in 2027.

Where the answer is “that application was retired years ago”, removing the server is only half the job. Remove the DNS record too. A CNAME pointing at decommissioned hosting is a dangling record: a pointer to nothing, and a candidate for subdomain takeover rather than a PHP problem. You cannot patch what you no longer control.

Then set change detection, so a newly exposed PHP host is flagged the day it appears rather than the day a researcher emails you. External observation and internal vulnerability management answer different questions: one tells you what the internet can see of your exposed services on a public IP, the other tells you what is installed on the machines you know about. Run both, and accept that neither covers the other’s blind spot.

The six-check triage list, in order

  1. Confirm the advisory, the identifier and the affected configuration, not just the product name.
  2. Enumerate candidate PHP hosts from a seed domain using certificate transparency, DNS and registration data.
  3. Fingerprint externally: headers, cookies, error pages, handler paths, and the IP as well as the name.
  4. Prove or disprove on the host, using package version and changelog, SAPI and handler configuration, or permitted active testing.
  5. Check for existing compromise before you patch, and preserve evidence before you clean.
  6. Remediate, then retest and confirm the external signal has changed.

Record each host as affected, not affected or unproven, with an owner and a review date against it. Unproven with a date next Tuesday is a working answer. Unproven with nothing after it is just a gap you have written down.

The Short Version

Tie the name to an identifier before you do anything else, and read the affected configuration as carefully as the version range. Find every host that could be running PHP, including the ones no register lists, because that is usually where the exposure sits. Treat external fingerprinting as evidence of likelihood, not proof, and treat a hidden version banner as unproven rather than safe. Check the distribution package and its changelog, not php -v, before you declare a host vulnerable. And look for a webshell before you patch. A php2shell check if affected is mostly a discovery problem wearing a vulnerability problem’s clothes; once the host list is honest, the checking itself is quick.

Frequently Asked Questions

What does php2shell refer to, and is it a real vulnerability name?

Treat it as an informal label rather than an official identifier. Names like this circulate on social feeds and vendor blogs before anyone cites a CVE, and they sometimes describe a genuine flaw, sometimes a tool, sometimes a rehash of an older issue. Your first step is to find the CVE number or vendor advisory the name is being used for, then work from the published affected versions and configurations.

How do I check if I am affected by php2shell without running an exploit against my own site?

Combine passive external observation with host-side evidence. Externally, read the Server and X-Powered-By headers, look for a PHPSESSID cookie and default PHP error pages, and establish which paths and handlers answer from the internet. On the host, check the installed package version and its changelog, the active SAPI and the web server’s handler configuration. That pairing gives you an answer without sending a single exploit payload.

My server hides its PHP version. Does that mean I am not affected?

No. With expose_php off, a stripping reverse proxy or a CDN in front, external observation returns nothing useful about what is installed. The correct status is unproven, with a named owner and a date to resolve it. Silence from a host tells you about its configuration, not its patch level.

My site is run by an agency or on shared hosting. How do I get a straight answer on patch status?

Ask for the exact PHP package version running on your site and the date the relevant fix was applied, in writing. Reassurance without a version string and a date is not evidence you can record. If you want independent confirmation through testing, get written permission from the host first, because scanning infrastructure you do not own without authorisation is an offence in the UK.

I think I have found a webshell on a PHP host. What should I do first?

Preserve, then contain. Take a disk image or full copy and move the logs somewhere safe before you delete anything, because a rebuild destroys the evidence you will be asked for. Note file timestamps and the requests around them, isolate the host from the internet rather than wiping it, and if personal data may be involved, start the UK GDPR clock: notifiable breaches go to the ICO within 72 hours of becoming aware.