This article describes the work without publishing client details or the plugin's internal identifier. The focus is on the coding practices involved, rather than on a particular installation.

1. Cross-site scripting (XSS)

What we found

User-controlled values were being included in HTML without suitable output escaping. This affected values carried by a request and values stored for later display. Depending on the output location, attacker-controlled markup could run in another user's browser.

How we addressed it

We reviewed the affected output paths and applied WordPress functions appropriate to each context:

  • esc_html() for plain text in an HTML element.
  • esc_attr() for values inside quoted HTML attributes.
  • esc_url() for URLs used in links.
  • wp_kses_post() where a limited set of HTML is intentionally allowed.

Input validation and sanitisation are separate steps. Functions such as sanitize_text_field() help normalise appropriate inputs, but they do not replace escaping at the point of output. The output context determines the protection required.

Verification

We retested the affected fields with script markup and event-handler attributes. The relevant check was that the input no longer executed as script: it was displayed as text or disallowed markup was removed, depending on the intended output. Verification should also confirm that legitimate text and permitted HTML continue to work.

2. Cross-site request forgery (CSRF)

What we found

An administrative action did not adequately verify that a request was intentionally made through the application. A malicious page could attempt to make a logged-in administrator send an unwanted request using their existing browser session.

How we addressed it

We added an action-specific nonce to the form with wp_nonce_field() and verified it in the handler with check_admin_referer() before making changes. The handler also checks current_user_can() for the capability required by that action.

These checks serve different purposes: the nonce helps protect against forged requests, while the capability check determines whether the user is permitted to perform the operation. A WordPress nonce has a limited lifetime; it is not a single-use token and is not, by itself, an authorisation or replay-prevention mechanism.

Verification

We checked that requests without a valid nonce were rejected and did not perform the action. Verification should also cover a user without the required capability and a valid, authorised request, so protection does not come at the expense of the intended workflow.

3. Legacy PHP code

What we reviewed

The review also covered older PHP code, including deprecated functions and patterns that could make database access or dynamic code execution unsafe. Deprecation is a compatibility signal; it does not mean that every deprecated function is a security vulnerability. Each use needs to be examined in context.

How we approached the changes

We updated legacy code to use supported APIs and safer patterns. The general review principles are:

  • For database queries containing variable values, use WordPress's database APIs appropriately, including $wpdb->prepare() with placeholders rather than concatenating untrusted values into SQL.
  • Use ordinary functions or closures where a callback is needed, rather than constructing executable code from strings.
  • Replace obsolete iteration or other language features with supported equivalents, checking for changes in behaviour.

These are review principles, rather than a claim that every pattern above occurred in this plugin.

Verification

Compatibility checks need to match the PHP version used by the deployment. Code review, static analysis and runtime checks address different kinds of problems; a passing result from one does not replace the others. During testing, WP_DEBUG can help reveal warnings and deprecations, with error details kept out of public pages.

For a remediation to be complete, the original security behaviour and the legitimate workflow both need to be checked again. This applies to a small output fix as well as to a change in an older API.

What we take into future reviews

The recurring checks are straightforward: escape output for its actual context, pair request verification with permission checks, and review legacy code against the target runtime. Applying these habits consistently addresses common causes of WordPress plugin vulnerabilities, while leaving room for checks specific to each application's behaviour.

Ongoing updates and verification sit within our wider WordPress and PHP vulnerability management process.

Technical references

FROM PRACTICE TO SUPPORT

Cybersecurity at 創遊株式会社

We work exclusively by referral. To learn about our penetration testing work, agreed testing conditions and reporting, visit our service overview.

Cybersecurity services (Japanese)