If you run or maintain PHP applications, AI has made the security debt in them much cheaper for attackers to find and use. Automated tooling can now scan for PHP-to-shell flaws across thousands of sites quickly, so vulnerabilities that sat unnoticed for years are now actively exploitable by almost anyone.
The catch: this is not just a "PHP problem" you can fix by migrating. The same vulnerability class exists in every server-side language, and AI coding assistants are writing fresh instances of it into new code.
That puts the pressure on small operators. WordPress alone runs a huge share of the web, and most of those installs are managed by solo founders, small agencies, and freelancers with no security team.
How a PHP-to-shell attack works
A PHP-to-shell attack is a form of remote code execution. In its simplest form, an attacker uploads a PHP file disguised as an image or document to a server that doesn't validate file types properly. Once that file can be reached with a web request, the attacker runs shell commands on the host. Your web app becomes a remote control for the server underneath.
The weak points are well documented. They include missing MIME type checks on upload endpoints, file extension checks that can be bypassed, loose temporary directory permissions, and misconfigured open_basedir restrictions. Legacy code also tends to rely on system, exec, shell_exec, and passthru.
The "40 years" in the debt goes back further than PHP. Unix permissions were designed before multi-tenant hosting existed. C string handling assumed trusted input. SQL injection patterns spread through early tutorial culture.
PHP apps, often written fast by developers learning on the job, built those assumptions straight into production code. AI scanning doesn't care which era a flaw comes from. It finds all of them.
Why AI changes the economics of PHP technical debt
Until recently, obscurity offered real protection. Scanning a large set of sites thoroughly took enough effort that attackers focused on high-value targets or the most obvious vectors.
That has changed in two ways at once.
Attack tooling got cheap. Language models paired with automated scanners can generate webshell payloads and spot likely upload endpoints by analysing JavaScript bundles. They can also match server fingerprints to known vulnerable plugin and framework versions. Work that once took days now takes minutes. Security researchers have publicly shown LLM-assisted exploit development cutting multi-day research down to about an hour.
AI assistants are writing new debt. Developers using coding assistants ship PHP handlers that work and pass tests. Some of that code still contains move_uploaded_file calls without extension checks, unvalidated file type handling, or an inline eval that looked clever when it was generated. These assistants learned from millions of repositories, including vulnerable ones. So the same tools that help find old debt are adding new debt to the same codebases.
The window between a public vulnerability disclosure and attacks in the wild has shrunk with it. Regulators are moving the same direction. EU data protection rules and US state laws expect "reasonable technical measures" that reflect current threats. Running unsupported PHP on a server holding customer data is hard to defend under that standard.
Where legacy PHP risk sits for agencies, freelancers and founders
The exposure looks different depending on how you came to own the code.
Agencies maintaining client builds. This is probably the highest-risk group. Custom PHP apps built between 2008 and 2018 often follow PHP 5.x conventions and now sit on maintenance retainers.
Nobody wants to quote a "security overhaul," and clients resist paying for one, so the code stays as it is. The question is no longer whether someone finds the hole but when a scanner does. A webshell can pivot into other systems, pull credentials, and on shared hosting reach neighbouring accounts. The agency carries the reputational and possibly legal fallout.
Freelancers running their own tools. Invoicing systems, client portals, and project trackers built around 2015–2020 have often never had a security review. They usually sit on cheap shared hosting with no WAF, using the host's default PHP config. Many of those defaults still enable allow_url_fopen and allow_url_include. You may not control those settings, which leaves you partly dependent on your host's hygiene.
Solo founders shipping on PHP or WordPress. If the product has users, their data is your liability. If you use Copilot, Cursor, or a similar assistant for ongoing work, there may be generated code nobody has reviewed. Most founders review their own code by instinct but don't apply the same scrutiny to code the assistant wrote. That gap is where the problems slip in.
Teams buying or inheriting an app. Small SaaS deals, through Acquire.com or directly, often involve PHP codebases. Buyers check the financials and skip the technical review, or do one too shallow to catch shell injection in an edge-case upload handler.
DNS and hosting changes around an acquisition show up in passive DNS data. That makes the weeks after a handover a riskier period. A security scan should be a standard due diligence step.
A four-step plan for paying down PHP security debt
The order of these steps matters.
1. Inventory, this week. List every PHP application you run or are responsible for. Record the PHP version, the date it was last updated, whether it accepts file uploads, whether it has user logins, and what data it handles. For most small teams this takes about two hours, and the worst offenders become obvious immediately.
PHP version is a rough but useful first filter. PHP 7.x reached end-of-life in late 2022, so anything on 7.4 or older gets no security patches.
2. Static analysis, this week. Run Semgrep with its PHP security rules on any codebase you have source access to. It's free, runs locally, and doesn't send your code anywhere. It flags dangerous function calls and user input that reaches file operations without sanitising.
Snyk has a free tier with GitHub, GitLab, and Bitbucket integration. If you're on GitHub, CodeQL in GitHub Advanced Security traces data flow from user input to dangerous functions. That is the analysis that finds shell injection paths a manual skim would miss.
Don't try to fix everything in one pass. A system call with hardcoded arguments is a different risk from one fed unvalidated input. Sort findings by how easy they are to exploit and start with the worst.
3. Configuration hardening, this week to this month. Configuration often decides whether a vulnerability is theoretical or exploitable. In php.ini:
disable_functions = system, exec, shell_exec, passthru, popen, proc_openif the app never needs to spawn processes. This limits the damage even if a webshell gets uploaded.allow_url_fopen = Offandallow_url_include = Offto block remote file inclusion.open_basedirto restrict PHP's file access to the app's own directories.
For WordPress, Wordfence adds a WAF and file integrity monitoring on its free tier. It doesn't replace code fixes, but it costs nothing.
4. Ongoing monitoring, from this month on. A one-time audit isn't enough when plugin and framework vulnerabilities keep appearing and get exploited faster. Aikido Security is aimed at small teams that need continuous SCA, SAST, and cloud posture checks without a security hire. WPScan provides automated plugin vulnerability scanning for WordPress sites.
PHP security scanning tools compared
| Tool | Best for | Free plan | Key differentiator |
|---|---|---|---|
| Semgrep | Custom PHP static analysis, CI | Yes | Runs locally, no code upload |
| Snyk | Dependency + code scanning on Git hosts | Yes | Deep dependency graph analysis |
| GitHub Advanced Security | Teams already on GitHub | No | CodeQL data-flow tracing |
| Aikido Security | All-in-one for small teams | Yes | SAST, SCA, cloud and secrets in one dashboard |
| SonarQube | Self-hosted rule library | Yes (community) | Long-standing PHP rules, strong CI support |
| OWASP ZAP | Dynamic black-box scanning | Yes (open source) | Finds runtime issues static tools miss |
| Wordfence | WordPress sites | Yes | WAF plus scanner with threat intelligence |
| Socket.dev | Supply chain risk | Yes | Flags malicious or compromised packages |
My take: if you're a freelancer or small shop, start with Semgrep, and add Wordfence if you run WordPress. That costs nothing and covers the most common gaps. An all-in-one platform like Aikido starts to earn its keep once you're juggling five or six apps and triage time becomes the real cost.
Where you can, prefer tools that export findings in a standard format such as SARIF. Some scanners are moving toward platforms where your security data lives only in their dashboard, and that dependency is hard to undo later.
PHP security traps that outlast the first scan
Scan and forget. A single scan treated as "done" can be worse than no scan, because it creates false confidence. A plugin that was clean in January can be under attack by March. Static analysis belongs in your CI pipeline, not in a PDF report.
Treating AI output as trusted. Review AI-generated PHP the way you'd review code from a junior developer who writes clean syntax but hasn't learned security habits. Specifically, check where user input ends up. Semgrep and CodeQL data-flow rules are built for exactly this, so wire them into CI.
Assuming migration solves it. Remote code execution through bad file handling isn't unique to PHP. Django upload handling can have similar issues, and so can a Node app with unsandboxed child_process calls. PHP gets the attention because it has the largest legacy footprint. A rushed migration driven by anxiety will probably introduce more bugs than it removes. Modern PHP 8.x has good security tooling.
Shared hosting you don't control. On budget hosts with stale PHP configs, one compromised tenant can sometimes affect others. If you can't change the config, factor that into where client work lives.
Frequently asked questions
Does this matter for a simple WordPress blog? Less than for a custom app with upload handlers, but the risk isn't zero. Many themes and plugins enable uploads, and automated scanning means low traffic no longer hides you. Keep plugins current and run Wordfence's free tier while you deal with higher-risk sites first.
Will disabling file uploads close the hole? It removes the most common entry point but not all of them. Local and remote file inclusion, SQL injection chains that end in file writes, and deserialisation flaws can reach the same result. Disable uploads where you don't need them, and treat that as one layer of defence.
Is a professional penetration test worth it? For a medium-sized PHP app it can cost $5,000–$15,000, which most small teams can't justify. Free scanners plus a focused manual review of upload handlers, auth logic, and anywhere input reaches queries or the filesystem gets you most of the way. Expect a weekend's work if you know what to look for, longer if you're learning.
What should I do if I think a webshell is already on my server? Put the app into maintenance mode and preserve the logs before you clean anything. Look for recently modified files, odd permissions, and unexpected child processes. If customer data is involved, you may have breach notification duties. Find out which vulnerability was used before you restore, or expect to be compromised again within days.