Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. The Vulnerabilities That Actually Get Exploited
PHP Development

The Vulnerabilities That Actually Get Exploited

PHP application security in practice: prepared statements, output escaping, framework-managed sessions, strict upload handling and current dependencies.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Prepared statements, proper output escaping, framework-managed sessions, strict file upload handling and current dependencies. Those five prevent nearly every PHP compromise we have investigated.

The same handful of problems

Despite the variety of attacks discussed in security literature, the PHP applications we are asked to investigate have been compromised through a small and consistent set of causes.

Getting five things right eliminates the overwhelming majority of practical risk.

Database access

  • Prepared statements with bound parameters, always — never string concatenation
  • That includes ORDER BY and LIMIT clauses, which are commonly overlooked
  • Least-privilege database credentials, not a superuser
  • No database errors displayed to users, ever
Injection through a search box or a sort parameter remains the most common way a PHP application is compromised, and prepared statements make it impossible.

Output escaping

Anything that came from a user and is rendered into a page must be escaped for its context. HTML, attributes, JavaScript and URLs each need different treatment.

Modern template engines escape by default, which is one of the strongest arguments for using one rather than writing raw PHP templates.

Authentication and sessions

  1. Use the framework's authentication rather than writing your own
  2. Password hashing with the language's current recommended function
  3. Session identifiers regenerated on privilege change
  4. Secure and HttpOnly flags on session cookies
  5. Rate limiting on login attempts

File uploads and dependencies

RiskControl
Uploaded files executedStore outside the web root, always
Type spoofingValidate content, not the extension
Path traversalNever use user input in a file path
Vulnerable dependenciesAutomated auditing on every build
Outdated PHP versionStay on a supported release

File uploads stored inside the web root is the second most common compromise route we find, after injection.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

Do frameworks make applications secure?

They make the common vulnerabilities harder to introduce. They do not prevent bad code, and they are a substantial improvement over hand-rolled equivalents.

How often should dependencies be updated?

Security releases within days. Others on a regular schedule with tests. Automated auditing should run on every build.

What about legacy applications?

Audit for the five causes above first. Those are usually where the actual exposure is, rather than in anything exotic.

Is a web application firewall worth it?

As an additional layer, yes. It is not a substitute for fixing the code, and it should not be treated as one.

Keep reading

More on PHP Development

PHP Development

Why PHP Is Still a Sensible Choice

Is PHP still a good choice for business applications? Where modern, typed PHP fits, where another language is better, and the hosting and hiring arguments.

PHP Development

Improving Old Code Without a Rewrite

Modernising a legacy PHP application without a rewrite: move to a supported PHP version, add tests around what matters, then strangle rather than replace.

PHP Development

Framework, Micro-Framework or Neither

Choosing a PHP framework for a business application: when a full framework, a micro-framework or no framework fits, and why business logic stays separate.

Start here

Not sure whether an old PHP application is safe?

The five common causes are quick to check. Happy to audit what you are running.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →