Security Fundamentals

Threat Modeling for PHP Web Applications

Identify assets, entry points, trust boundaries, and realistic threats before implementing PHP application security controls.

Identify what you need to protect

List the assets your application handles: user accounts, personal information, administrative functions, uploaded files, API credentials, and database records.

Map entry points

Common entry points include URL parameters, form fields, uploaded files, cookies, session identifiers, JSON bodies, webhooks, and scheduled jobs. Treat values crossing a trust boundary as untrusted.

Identify trust boundaries

Trace requests from the browser through PHP routes, controllers, services, databases, file storage, and external services. Ask where authentication, validation, authorization, and output encoding occur.

Prioritize threats

Consider SQL injection, cross-site scripting, CSRF, broken access control, insecure uploads, credential theft, and server-side request forgery. Prioritize based on likelihood and impact.

Keep the model current

Review it whenever you add endpoints, integrations, upload features, or administrative capabilities. Security is an ongoing design activity.