# Security Policy

## Supported Versions

| Version | Supported          |
| ------- | ------------------ |
| 7.7.1   | :white_check_mark: |
| < 7.7.1 | :x:                |

## Reporting a Vulnerability

If you discover a security vulnerability within wpDiscuz, please send an email to info@gvectors.com. All security vulnerabilities will be promptly addressed.

## Security Fixes

### Stored Cross-Site Scripting via Custom Text Area Comment Form Fields (Fixed in 7.7.1)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** Rendering of custom "Text Area" comment form fields (`TextAreaField::frontHtml()` in `forms/wpdFormAttr/Field/TextAreaField.php`), added through the form builder in Comments > Forms; the bundled lity lightbox (`assets/third-party/lity/`)
**Affected Versions:** All released versions with custom comment form fields, up to and including 7.7.0. Only sites where an administrator has added at least one custom Text Area field to a comment form are affected.

**Description:**
The value a commenter typed into a custom Text Area field was rendered on the comment through an HTML allow-list (`wp_kses()` with the "post" rules) instead of being output as plain text. A crafted field value that was accepted when the comment was submitted could therefore be rendered as live markup, including attributes that the bundled lightbox script reacts to. Depending on the field's visibility settings the value could be submitted by a guest without an account. The script ran for everyone viewing the comment once it was displayed, including moderators and administrators.

**Fix Applied:**
1. Custom Text Area field values are now output as text. The stored value is escaped with `esc_html()` before line breaks are converted and before the `wpdiscuz_custom_field_textarea` filter runs, so a field value can no longer become markup. The filter still receives the escaped text, so listeners that add their own trusted markup keep working.
2. The bundled lity lightbox only opens inline targets referenced by a plain element id when triggered from an element attribute, and no longer reads options from the triggering element, so an attribute value can neither reach the lightbox's HTML parser nor make it fall back to framing the page.

**Recommended Action:**
Update to 7.7.1. No settings change or data migration is needed: values already stored by an affected version are rendered safely by the corrected output.

**Files Modified:**
- `forms/wpdFormAttr/Field/TextAreaField.php` - Output the field value as escaped text in `frontHtml()`
- `assets/third-party/lity/lity.js`, `assets/third-party/lity/lity.min.js`, `assets/js/wpdiscuz-combo.min.js`, `assets/js/wpdiscuz-combo-no_quill.min.js` - Restricted attribute-driven lightbox targets to inline element ids and stopped reading options from the triggering element

**Credit:**
Reported through Wordfence.

### Stored Cross-Site Scripting via Crafted Span Ids in Comments (Fixed in 7.7.1)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** The comment HTML allow-list (`WpdiscuzHelper::filterKses()` in `utils/class.WpdiscuzHelper.php`), the user-settings modal opener (`assets/js/wpdiscuz-user-content.js`) and the reply form builder (`getUniqueID()` / `cloneSecondaryForm()` in `assets/js/wpdiscuz.js`)
**Affected Versions:** All released versions up to and including 7.7.0, with guest commenting enabled (the default). Approval of the comment is not required: moderators see pending comments on the post.

**Description:**
The allow-list applied to comments from users without the `unfiltered_html` capability accepted the `id`, `title` and `contenteditable` attributes on `<span>` elements. wpDiscuz's own scripts look up some of their elements by id and by class, so a comment could contain a span with the id of the hidden anchor that is clicked to open the user-settings modal, nested in a fake comment wrapper whose id held HTML. When anyone clicked the user-settings icon, wpDiscuz clicked the crafted span, the reply handler read the fake wrapper's id, and the reply form template built from it was inserted as HTML, which ran the planted script in the viewer's browser.

**Fix Applied:**
1. Comment spans keep `class` and `data-name`. When the comment is saved, the HTML parser decodes class attributes before removing the reserved class names. The prefix list and the classes the editor may keep are filterable through `wpdiscuz_reserved_class_prefixes` and `wpdiscuz_allowed_content_classes`.
2. The scripts accept a comment id only in its own `number_number` form. Any other value, including one coming from a comment stored by an earlier version, is discarded before it reaches a selector or the reply form template.
3. The user-settings modal is opened directly by the script. The hidden footer anchor was removed, so no element is clicked by id any more.

**Recommended Action:**
Update to 7.7.1. Comments stored by an earlier version are handled safely by the corrected scripts; no data migration is needed.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Removed `id`, `title` and `contenteditable` from the span allow-list; strip reserved class names from comment markup (`stripReservedClasses()`)
- `assets/js/wpdiscuz.js`, `assets/js/wpdiscuz.min.js` - Validate the comment id read from the markup before it is used
- `assets/js/wpdiscuz-user-content.js`, `assets/js/wpdiscuz-user-content.min.js`, `class.WpdiscuzCore.php` - Open the modal directly and drop the footer anchor
- `assets/js/wpdiscuz-combo.min.js`, `assets/js/wpdiscuz-combo-no_quill.min.js` - Rebuilt bundles

**Credit:**
Reported through Wordfence.

### Stored Cross-Site Scripting via the Attachment Lightbox Title in Comments (Fixed in 7.7.1)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** Media Uploader lightbox initialisation (`assets/js/wpdiscuz-mu-frontend.js`, `assets/js/wpdiscuz-mu-backend.js`, `assets/js/wpdiscuz-options.js`) with the bundled Colorbox library; the comment HTML allow-list
**Affected Versions:** All released versions up to and including 7.7.0, with Media Uploader and its "Lightbox" option enabled (the default).

**Description:**
The lightbox was bound to every element carrying the `wmu-lightbox` class anywhere on the page, and the comment allow-list accepted a `title` attribute on `<span>` elements. Colorbox prints an element's title into the lightbox as HTML. A comment containing a span with that class and a title holding HTML therefore ran the planted script in the browser of anyone who clicked the span, including moderators and administrators.

**Fix Applied:**
1. The lightbox is bound only to the image links inside wpDiscuz's own attachment markup, never to a class written into a comment.
2. The lightbox prints no title.
3. The `title` attribute is no longer accepted on comment spans (see the previous entry).

**Recommended Action:**
Update to 7.7.1. No settings change is needed.

**Files Modified:**
- `assets/js/wpdiscuz-mu-frontend.js`, `assets/js/wpdiscuz-mu-frontend.min.js`, `assets/js/wpdiscuz-mu-backend.js`, `assets/js/wpdiscuz-options.js` - Scoped the lightbox selector and disabled the title
- `assets/js/wpdiscuz-combo.min.js`, `assets/js/wpdiscuz-combo-no_quill.min.js` - Rebuilt bundles

**Credit:**
Reported through Wordfence.

### Shortcode Execution in Comments (Fixed in 7.7.1)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS) through shortcode output; execution of arbitrary registered shortcodes
**Affected Component:** The comment shortcode filter (`WpdiscuzHelper::doShortcode()` in `utils/class.WpdiscuzHelper.php`)
**Affected Versions:** All released versions up to and including 7.7.0, when the "Enable WordPress Shortcodes in Comment Content" option is on (it is off by default). The comment has to be approved.

**Description:**
With the option on, wpDiscuz ran `do_shortcode()` over every comment it rendered. The comment HTML allow-list removes tags but leaves `[shortcode]` text untouched, so a guest could place any shortcode registered by any plugin or theme in a comment. Once a moderator approved the comment, the shortcode ran for every visitor, and whatever HTML it produced was printed without further filtering. A shortcode that prints HTML built from its attributes, or one that executes administrator-defined code snippets, therefore let a guest run script in every visitor's browser.

**Fix Applied:**
1. Unrestricted expansion requires a body hash recorded on save with both the comment author and the person who wrote that revision. Both users must have the `unfiltered_html` capability on save and display.
2. For other comment revisions, only shortcodes allowed by the `wpdiscuz_comment_shortcodes` filter expand. The default list is empty. `wp_kses_post()` filters the assembled HTML, including output from shortcode hooks.
3. The option's description now states this.

**Recommended Action:**
Update to 7.7.1. Existing comments without a saved writer record use the same filtered allowlist as other restricted comments. Sites can allow individual tags through `wpdiscuz_comment_shortcodes` when they need them. When an allowed shortcode expands, the whole comment is filtered like post content, so an administrator comment saved before 7.7.1 that mixes such a shortcode with an iframe or other post-only markup loses that markup until it is saved again.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Record the saved body and writer, check capabilities, apply the allowlist and filter the output
- `class.WpdiscuzCore.php`, `themes/default/class.WpdiscuzWalker.php` - Identify the saved body before formatting
- `options/class.WpdiscuzOptions.php` - Option description

**Credit:**
Reported through Wordfence.

### Guest Comment Edit Authorization Bypass (Fixed in 7.7.1)

**Severity:** Medium
**Type:** Insecure Direct Object Reference (IDOR) / authorization bypass through a user-controlled key
**Affected Component:** Guest comment ownership check (`WpdiscuzHelper::canUserEditComment()` in `utils/class.WpdiscuzHelper.php`), used by the `wpdEditComment` and `wpdSaveEditedComment` AJAX actions and by attachment removal
**Affected Versions:** All released versions up to and including 7.7.0, with guest commenting and comment editing enabled (both default; the edit window is 15 minutes by default).

**Description:**
A guest was recognised as the author of a comment when the `comment_author_email_<hash>` cookie matched the comment's email address and the request came from the comment's IP address. The cookie is plain text the browser can set to any value, and the address is shared by everyone behind the same router, office network, campus network or carrier NAT. Anyone on such a network who knew a commenter's email address could open that guest's comment in the edit form and overwrite it while the edit window was open.

**Fix Applied:**
1. When a guest comment is posted, wpDiscuz generates a random secret, stores its keyed hash with the comment and gives the secret to the commenter's browser in an `HttpOnly`, `SameSite=Lax` cookie (`wpdiscuz_guest_edit_<hash>`, 30 days, filterable through `wpdiscuz_guest_edit_cookie_lifetime`). Scripts on the page cannot read it, and other visitors never receive it.
2. Editing a guest comment, and removing its attachments, now requires that secret in addition to the email cookie and the matching IP address.
3. A guest who declines cookies through the Cookies Consent form field does not receive the secret: the field clears the cookie and stops the secret from being issued for that comment through the `wpdiscuz_remember_guest_comment` filter. A secret already present in the browser is reused only when it already proves a comment with the same email address, so a value planted by someone else never becomes the commenter's secret.

**Recommended Action:**
Update to 7.7.1. Guest comments posted before the update carry no secret and can no longer be edited by their guest authors; moderators can still edit them.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Issue the secret on `comment_post` (`rememberGuestComment()`) and require it in `canUserEditComment()`
- `includes/interface.WpDiscuzConstants.php` - New comment meta key
- `forms/wpdFormAttr/Field/CookiesConsent.php` - Drop the secret cookie when cookies are declined

**Credit:**
Reported through Wordfence.

### Guest Identity Spoofing through the Email Cookie (Fixed in 7.7.1)

**Severity:** Medium
**Type:** Improper authentication of guests / information disclosure / unsolicited email
**Affected Component:** `WpdiscuzHelper::wpdGetInfo()`, `getActivityPage()`, `getSubscriptionsPage()`, `WpdiscuzHelperAjax::guestAction()` and the subscription page template, which read the guest's identity from the `comment_author_email_<hash>` cookie
**Affected Versions:** All released versions up to and including 7.7.0.

**Description:**
The "My Content and Settings" window treated the plain-text `comment_author_email_<hash>` cookie as proof of who the guest was. Anyone could set that cookie to another person's address and then read that guest's comment activity, including comments still awaiting moderation, and their subscription list, and ask the site to email deletion links to that address, which let an anonymous visitor make the site send mail to any address at will.

**Fix Applied:**
Guest Activity queries and counts require the hash attached to each comment from the browser's comment token. Email-wide actions require a separate mailbox session. wpDiscuz emails a rate-limited, single-use link that expires after 15 minutes. Confirming it issues a one-day session in the confirming browser. The verification, confirmation and "clear my data" forms are accepted only from same-origin requests, because the nonce of a logged-out visitor is shared by every visitor. `WpdiscuzHelper::getVerifiedGuestEmail()` and `getMailboxVerifiedGuestEmail()` return the email from that session.

**Recommended Action:**
Update to 7.7.1 and the matching releases of add-ons that read the email cookie. Guests can confirm their email in My Content and Settings to view subscriptions and request deletion links. Activity uses comments saved with the token in the current browser. Existing unsubscribe links in notification emails still work. The comment thread's pending-comment behavior follows WordPress core separately from Activity.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Mailbox sessions and guest Activity scope
- `utils/layouts/activity/`, `utils/layouts/guest-settings.php` - Comment-token Activity and guest verification forms
- `utils/class.WpdiscuzHelperAjax.php` - `guestAction()`
- `utils/class.WpdiscuzHelperEmail.php`, `themes/unsubscription.php` - Guest email confirmation and email-wide actions

**Credit:**
Found during the internal review that followed the Wordfence reports.

### Stored Cross-Site Scripting via User Mentions in Comments (Fixed in 7.7.1)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** Render-time user mention expansion (`WpdiscuzHelper::userMentioning()` in `utils/class.WpdiscuzHelper.php`), setting Comments > Settings > Subscription and Postmatic > "Enable @mentioning" (`enableUserMentioning`)
**Affected Versions:** All released versions with the user mention feature, up to and including 7.7.0.

**Description:**
When a comment is rendered, `userMentioning()` looks for `@nicename` tokens in the already-sanitized comment HTML and replaces each one with a link to the mentioned user's profile that shows the user's display name. The display name and the profile URL were inserted without escaping, and the replacement ran over the whole HTML, including attribute values. WordPress stores display names with angle brackets encoded but leaves quotes intact, so a user who put a quote and an event-handler attribute in their display name, and was then mentioned inside an attribute value, could close that attribute and add live attributes to the surrounding element. A mention ends up inside an attribute whenever a comment contains a link whose URL has the `@nicename` in it; WordPress itself turns a bare URL into such a link before the mention expansion runs, so no HTML in the comment was needed.

The display name could be set by any logged-in user who can edit their own profile (Subscriber). The script ran for moderators and administrators viewing the comment while it was pending, and for every visitor once it was approved.

**Fix Applied:**
1. The mentioned user's display name is now escaped with `esc_html()` and the profile URL with `esc_url()` in every variant of the generated markup (profile link, and the plain `<span>` fallbacks).
2. Mentions are no longer expanded inside HTML markup. The comment HTML is split into tags and text with `wp_html_split()`, and the replacement runs over the text parts only, so a `@nicename` inside an attribute value such as `href`, `title` or `cite` is left as it is.
3. The replacement uses `preg_replace_callback()` with a `preg_quote()`-escaped pattern, so neither the nicename nor the display name is interpreted as a regular expression or as a replacement back-reference.

**Recommended Action:**
Update to 7.7.1. No settings change or data migration is needed: existing comments are rendered safely by the corrected expansion. Sites that ran an affected version may want to review the display names of recently registered users for quote characters and attribute-like text.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Escaped the mention markup and limited the expansion to text nodes in `userMentioning()`

**Credit:**
Reported through Patchstack.

### Stored Cross-Site Scripting via Image URL Conversion in Comments (Fixed in 7.7.0)

**Severity:** High
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** Render-time "Image URL Conversion" (`WpdiscuzHelper::makeClickable()` in `utils/class.WpdiscuzHelper.php`), setting Comments > Settings > Content > "Convert links to images" (`enableImageConversion`, on by default)
**Affected Versions:** All released versions that include the Image URL Conversion feature, up to and including 7.6.75. Fixed in 7.7.0 before its public release.

**Description:**
When a comment is rendered, `makeClickable()` runs a regular expression over the already-sanitized comment HTML to turn links that end in an image extension into `<img>` tags. The expression could match a link past the boundary of the attribute value it was written in, and the conversion's replacement then left the surrounding markup in a state where text from elsewhere in the comment parsed as live attributes, including an event handler, on a rendered element. The conversion runs after sanitization and its output is not re-filtered, so the result reached the browser intact.

The comment could be submitted by an unauthenticated guest. The script ran without interaction for moderators and administrators viewing the comment while it was pending, and for every visitor once it was approved.

**Fix Applied:**
1. The URL body of the image-conversion expression is now bounded by `[^\s\"'<>]+`, so a matched link can never cross a quote or an angle bracket and can never consume another tag's delimiters.
2. The conversion no longer runs inside HTML tags at all. A lookahead (`(?![^<>]*>)`) skips any candidate URL that sits before a tag's closing `>`, so a link written inside an attribute value, whether double-quoted, single-quoted or unquoted, is left untouched instead of having the replacement markup injected into the attribute.
3. The leading character class, which consumed and silently deleted the character before every converted link, was replaced with a lookbehind (`(?<![\"'])`). The character before a converted link is now preserved, and a link immediately preceded by a quote is still not converted.
4. Legitimate bare image links in comment text still convert: a plain URL ending in `.jpg`, `.jpeg`, `.png`, `.gif` or `.bmp` becomes an image as before. Two intentional behavior changes: a URL containing a literal apostrophe no longer converts (it stays a plain link), and a URL followed later on the same text run by a bare `>` is skipped; both degrade to showing the link as text.

**Recommended Action:**
Update to 7.7.0. No settings change or data migration is needed: existing comments are rendered safely by the corrected conversion. Sites that ran an affected version may want to review pending and approved comments that contain a link ending in an image extension inside markup.

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Bounded the URL body in the image-conversion regular expression in `makeClickable()`

**Credit:**
Reported by an external security researcher.

### Comment, User and Metadata Cache Files Readable by Unauthenticated Visitors (Fixed in 7.6.75)

**Severity:** High
**Type:** Sensitive Information Disclosure
**Affected Component:** Built-in comment cache (`utils/class.WpdiscuzCache.php`), setting Comments > Settings > General > "Enable caching" (on by default)
**Affected Versions:** Up to and including 7.6.74.

**Description:**
The comment cache was written to `wp-content/uploads/wpdiscuz/cache/comments/<post_id>/<name>`, the comment author cache to `wp-content/uploads/wpdiscuz/cache/users/<name>`, and the extra cache to `wp-content/uploads/wpdiscuz/cache/comments/<post_id>/extra/<name>`. These examples assume the standard uploads directory; the cache follows each site's uploads directory on multisite or with custom upload settings. The only access control was an `.htaccess` file containing `Deny from all`. Servers serving these files directly without reading `.htaccess`, such as nginx or Apache with `AllowOverride None`, could expose them. Apache 2.4 without `mod_access_compat`, when reading this rule, returned a server error rather than serving the file.

The comment and extra cache file names were derived with `md5()` from values a visitor already knows (the viewer's role set, the sort order, the page number and the parent comment ID), so for a guest with default settings the name was the same on every site. The comment cache held serialized `WP_Comment` objects, including email addresses, IP addresses and user agents for cached comments. The extra cache held comment metadata, including metadata stored by other plugins.

The author cache held serialized `WP_User` objects, including usernames, email addresses and `user_activation_key` data. Its file name was derived from the user ID, comment email address and comment author name, all available in the comment cache. In affected releases before 7.6.31, the author cache could contain password hashes regardless of avatar settings. From 7.6.31 through 7.6.74, wpDiscuz removed `user_pass` only when avatars were enabled in both wpDiscuz and WordPress. That avatar path also placed the comment object, including its IP address, in the author cache. Exposure was limited to data present in generated cache files; it does not establish that a particular site was accessed or exploited.

**Fix Applied:**
1. Cache files are now stored under `wp-content/uploads/wpdiscuz/cache/<key>/`, where `<key>` is 32 hex characters derived with HMAC-SHA256 from the site's authentication salt. The path can no longer be guessed, and it changes when the salts are rotated.
2. Cache file contents are encrypted with AES-256-CBC under a key derived from the same salt, with a random IV and an HMAC-SHA256 tag that is verified before the data is unserialized. A file obtained over the web, from an uploads-only backup or from an offloaded uploads bucket cannot be read without the site's salts, and a tampered file is treated as a cache miss. A full-site backup may contain those salts and must be protected separately.
3. The password hash and activation-key data are removed from both user references in the author cache, including the avatar arguments.
4. The parent `.htaccess` file supports both Apache 2.4 (`Require all denied`) and Apache 2.2 (`Deny from all`) and is verified before any in-place deletion at a predictable legacy path. These rules require Apache to permit the corresponding overrides. Empty `index.html` files in `cache/` and `cache/<key>/` suppress directory listings where the server's directory-index configuration includes that file. Encryption protects new cache contents independently of these server settings.
5. Each request that initializes wpDiscuz checks for the old `cache/comments/` and `cache/users/` directories, even when caching is disabled or the installed version is already current. Each tree is renamed to a `cache/legacy-comments-<random>/` or `cache/legacy-users-<random>/` directory with 128 bits of randomness, immediately removing its predictable URL without traversing its contents. Its own access rules move with it. Cleanup writes protection only in the existing cache parent, without creating the live cache-key directory under a command-line user's ownership.
6. WordPress cron deletes retired trees in batches limited to 250 entries and a two-second time budget, scheduling further batches while files remain. Retired trees can be deleted even when the parent access rule is unwritable; each tree's own `.htaccess` is retained until its other contents have been removed. If a rename fails, the job retries it and can remove the original tree in the same bounded batches, only after verifying the parent access rule. Failed frontend attempts are throttled to once per hour and show an administrator notice while predictable paths remain. An hourly check of retired directory names recovers missing jobs after reactivation or a restore. Its next scan time is kept in an autoloaded option to avoid a permanent transient lookup query, and cache contents are never walked during this check.

7. (7.7.1) On hosts such as WordPress VIP, the uploads filesystem cannot list or rename folders. wpDiscuz retires the old cleanup jobs on those hosts and runs a partial cleanup in short background batches. Files from deleted or changed records, older settings or other views may remain. The notice asks the administrator to contact the host for full cleanup and reports how many deletion requests returned success. Dismissing the notice leaves the pass running. Each checkpoint stores the stage and cursor together, and the pass and its notice are scoped to the uploads path and the VIP environment, where applicable. Repeated database errors cause the pass to retry hourly. From 7.7.1 on, wpDiscuz records the earliest version it knows for the site: the installed version on a new site, otherwise the version updated from. Uninstalling keeps that record, because the cache folder cannot be removed on such hosts and a later reinstall must not pass for a new site. A record of 7.7.1 or later skips the pass, a record older than 7.6.75 requires it, and for 7.6.75 or 7.7.0, which wrote no plaintext caches but may have followed a version that did, as for sites without a record, wpDiscuz checks the age of the oldest form and whether any comment predates 7.6.75. An update directly from a version older than 7.6.75 still requires the pass on hosts without folder listing. A site created on a pinned pre-7.6.75 release and upgraded through 7.6.75 or 7.7.0 may be skipped if its forms and comments are newer than the release. Ask the host to check such sites too. wpDiscuz turns off its file cache on remote stream-wrapper uploads. For directory-based cleanup, the per-minute job falls back to hourly retries after ten passes without a deletion.

**Recommended Action:**
Update to 7.6.75 and make a request that loads WordPress on each affected site; a response served entirely from a page cache does not run cleanup. No caching setting change is needed. Keep WordPress cron running so files moved out of their predictable locations are deleted in the background. If wpDiscuz reports that old files could not be removed, ask the hosting provider to remove the legacy directories from that site's uploads directory. Also remove any publicly accessible legacy copies in offloaded storage or a CDN.

On sites that served the cache files publicly, cached commenters' email addresses, IP addresses, user agents, registered usernames and comment metadata may have been exposed. Password hashes of cached registered commenters may also have been exposed if the files were generated on an affected release before 7.6.31, or on 7.6.31 through 7.6.74 with avatars disabled in either wpDiscuz or WordPress. Consider asking those users to change their passwords. This report does not establish that any particular site's files were downloaded.

On WordPress VIP and other hosts that keep uploads in a remote object store, update to 7.7.1 or later. Ask VIP Support or your hosting provider to remove the legacy `wpdiscuz/cache/comments` and `wpdiscuz/cache/users` folders from the site's uploads storage and purge any copies cached at the CDN edge. Ask the host as soon as you learn that the site may have legacy files, and again after a restore that may bring those files back. The automatic pass may take days or weeks on a large site and covers only a subset of the legacy files.

On nginx, also deny web access to the cache directory in the server configuration. For a site using the standard uploads URL:

```
location ^~ /wp-content/uploads/wpdiscuz/cache/ { deny all; }
```

Replace the URL prefix with the actual public uploads path. Multisite subsites commonly use `/wp-content/uploads/sites/<site_id>/wpdiscuz/cache/`; add an appropriate block for each uploads location. The rule must be applied to whichever server or storage service actually serves the files.

**Files Modified:**
- `utils/class.WpdiscuzCache.php` - Salt-derived cache directory, encrypted and authenticated cache files, sanitized user references, hardened `.htaccess` and `index.html`, legacy quarantine and bounded background cleanup
- `includes/interface.WpDiscuzConstants.php` - Constants for cache sub-directories, cleanup retry transient, scan option and background action
- `class.WpdiscuzCore.php` - Legacy retirement during initialization, background job registration and an administrator notice on failure
- `languages/wpdiscuz.pot` - Translation template entry for the cleanup notice

**Credit:**
Reported by an external security researcher.

### Stored Cross-Site Scripting via Template Placeholders in the Comment Author Name (Fixed in 7.6.74)

**Severity:** High (CVSS 7.1)
**Type:** Stored Cross-Site Scripting (XSS)
**Affected Component:** Front-end comment rendering (`themes/default/class.WpdiscuzWalker.php`) and the guest Name field
**Affected Versions:** Up to and including 7.6.73.

**Description:**
The comment renderer collected all template placeholders (`{AVATAR}`, `{AUTHOR}`, `{TEXT}`, ...) and their values into two arrays and resolved them with a single array `str_replace()`. PHP applies such replacements one pair after another over the whole string, so a placeholder that appeared inside an already inserted value was expanded again. The avatar markup, whose `alt` attribute holds the escaped author name, was inserted before the comment body. An author name containing the literal text `{TEXT}` therefore had the raw comment HTML expanded into the `alt` attribute after escaping had already run. A body consisting of a straight quote and event-handler text inside a `<code>` element passes `wp_kses` and is not touched by `wptexturize`, so the quote closed the attribute and `onerror`/`onload` became live attributes on the avatar `<img>`.

The name could be supplied by an unauthenticated guest through the Name field, or by any registered user through the display name of their profile. The script ran without interaction for moderators and administrators viewing the comment while it was pending, and for every visitor once it was approved.

**Fix Applied:**
1. The renderer now resolves placeholders with `strtr()` and a single map, which performs one pass and never rescans inserted values. The comment templates themselves are unchanged, so custom layouts in child themes keep working.
2. Added `WpdiscuzHelper::neutralizeTemplateBraces()`, which encodes `{` and `}` as HTML entities. The guest Name field passes through it before the name is stored.
3. The name shown in the "last edited by" note, the only user value concatenated into the template before the final pass, goes through the same helper.
4. The parent author name in the "Reply to" block is now escaped with `esc_html()`, matching the author name in the comment header.

**Recommended Action:**
Update to 7.6.74. No settings change or data migration is needed: comments whose author name already contains braces are rendered safely by the new renderer. Sites that were on an affected version may want to review pending and approved comments whose author name contains `{` or `}`.

**Files Modified:**
- `themes/default/class.WpdiscuzWalker.php` - Single-pass placeholder substitution; escaped the parent author name and the "last edited by" name
- `utils/class.WpdiscuzHelper.php` - Added `neutralizeTemplateBraces()`
- `forms/wpdFormAttr/Field/DefaultField/Name.php` - Braces in the guest name are encoded before the name is stored

**Credit:**
Reported through Patchstack.

### Facebook Login Authentication Bypass (Fixed in 7.6.73)

**Severity:** High
**Type:** Authentication Bypass / Account Takeover
**Affected Setting:** Comments > Settings > Social Login and Share > Facebook (legacy flow, "Use Facebook OAuth2" disabled — the default)
**Affected Versions:** Up to and including 7.6.72.

**Description:**
The legacy client-side Facebook login flow passed a Facebook user ID received with the request straight into a Facebook Graph lookup, without confirming that the ID belonged to the owner of the access token the request arrived with. When Facebook returned no email for that profile, the account's email address was synthesized from the profile ID, and an existing account was then matched by that email. Because a Facebook account's ID is public and was used to derive both the user name and the fallback email, a request could be signed in as another visitor's account. Where the matched account was an administrator, this led to full site compromise.

The server-side OAuth2 flow was never affected: it reads the account from the token's own owner via the Graph `/me` node.

**Fix Applied:**
1. Removed the legacy client-side Facebook flow entirely; Facebook login now always uses the server-side OAuth2 flow (`facebookLoginPHP()` / `facebookLoginPHPCallBack()`), which reads the profile of the access token's owner.
2. Removed the `facebookLogin()` method that trusted the client-supplied user ID.
3. Social accounts are now matched by their verified provider user ID (stored in user meta) first, falling back to email only for a real provider email.
4. Removed the "Use Facebook OAuth2" setting; the server-side flow is the only path. Stored option values are untouched and no reconfiguration of wpDiscuz settings is required.

**Recommended Action:**
Sites that used the legacy flow must add their site's OAuth redirect URI, `wp-admin/admin-ajax.php?action=wpd_login_callback&provider=facebook`, to the "Valid OAuth Redirect URIs" of their Facebook app for the Facebook button to keep working. Administrators should review user accounts that originated from Facebook login for any that were not created by their legitimate owner.

**Files Modified:**
- `forms/wpdFormAttr/Login/SocialLogin.php` - Removed `facebookLogin()`; Facebook login always uses the OAuth2 flow
- `forms/wpdFormAttr/Login/Utils.php` - Match social accounts by verified provider user ID, always store the social user ID
- `options/class.WpdiscuzOptions.php` and `options/options-layouts/html-social.php` - Removed the `fbUseOAuth2` option and its setting
- `assets/js/wpdiscuz-social.js`, `assets/js/wpdiscuz-social.min.js`, `assets/js/wpdiscuz-combo.min.js`, `assets/js/wpdiscuz-combo-no_quill.min.js` - Removed the client-side Facebook login flow (Facebook share is unchanged)

### Google Client Secret Exposure (Fixed in 7.6.68)

**Severity:** Medium
**Type:** Sensitive Data Exposure
**Affected Setting:** Comments > Settings > Social Login and Share > Google Client Secret
**Affected Versions:** Up to and including 7.6.67. The exposure was present continuously from June 2019, when the Google Login options were added, until 7.6.68.

**Description:**
The Google Client Secret and Client ID were added to the `$jsArgs` array in `WpdiscuzOptions`, which is localized to the front end as `wpdiscuzAjaxObj`. On any site that had those settings filled in, both values were readable in the HTML source of every front-end page, by any visitor.

Neither value was used by the front-end JavaScript. The Google OAuth flow runs entirely server-side in `forms/wpdFormAttr/Login/SocialLogin.php`, which reads the options directly. The Client ID is public by design and carries no risk on its own; the Client Secret is not meant to leave the server.

**Fix Applied:**
1. Removed `googleClientSecret` from the `$jsArgs` array
2. Removed the unused `googleClientID` from the same array
3. Stored option values are untouched, and Google Login continues to work with no reconfiguration

**Recommended Action:**
Sites that had Google Login configured on an affected version should generate a new Client Secret in the Google Cloud Console and save it under Comments > Settings > Social Login and Share. The redirect URIs registered for the Google app limit what a third party can do with the old secret, but it should no longer be treated as private.

**Files Modified:**
- `options/class.WpdiscuzOptions.php` - Removed `googleClientSecret` and `googleClientID` from `$jsArgs`

### CVE-2025-68997 - IDOR Vulnerability (Fixed in 7.6.44)

**Severity:** Medium
**Type:** Insecure Direct Object Reference (IDOR)
**Affected Actions:** `wpdVoteOnComment`, `wpdUserRate`, `wpdFollowUser`, `wpdAddSubscription`

**Description:**
AJAX actions exposed via `admin-ajax.php` were vulnerable to:
1. Authorization bypass - voting on comments from private/restricted posts
2. Mass abuse through direct HTTP requests bypassing frontend protections

**Fix Applied:**
1. **Authorization Check** (IDOR fix):
   - Added post access validation to `voteOnComment()`
   - Verifies post exists and is published
   - Checks user has permission for private posts
   - Blocks access to password-protected post comments for guests
   - Uses `$comment->comment_post_ID` (actual post from DB) for authorization, not user-supplied `postId` parameter - prevents bypass via parameter manipulation

2. **Rate Limiting** (Abuse prevention):
   - Server-side rate limiting on all sensitive AJAX actions
   - Rate limits: vote (20/min), rate (10/min), follow (15/min), subscribe (10/min)
   - Enhanced client fingerprinting (IP + User-Agent + Accept-Language)
   - Rate limiting executes BEFORE nonce validation for maximum protection

**Files Modified:**
- `utils/class.WpdiscuzHelper.php` - Added `checkRateLimit()` and `getClientFingerprint()`
- `utils/class.WpdiscuzHelperAjax.php` - Authorization check + rate limiting on `voteOnComment()`, `userRate()`, `followUser()`
- `utils/class.WpdiscuzHelperEmail.php` - Rate limiting on `addSubscription()`
- `options/class.WpdiscuzOptions.php` - Added `wc_rate_limit_exceeded` phrase

**Verification:**
Security fix can be verified by checking for `@security-fix CVE-2025-68997` annotations in the source code.

## Security Best Practices

1. Always keep wpDiscuz updated to the latest version
2. Use HTTPS on your website
3. Keep WordPress core and other plugins updated
4. Use strong passwords for admin accounts
5. Consider using a Web Application Firewall (WAF)
