The XSS triggered when the comment is opened in the background, where should the content system prevent it?
XSS triggered only when comments are opened in the admin backend, where should the content system prevent it? It should be prevented at the rendering layer, not the submission layer. The reason is that such defects belong to secondary context: malicious content quietly lies in the pending queue first, not displayed on the front end, and when the admin opens that line in the backend list, the page renders the comment content as part of the page structure, and the script gets an opportunity to execute. The filtering at the time of entry only covers the moment of submission, and does not manage this subsequent rendering.
Recently, the WordPress 7.1.3 security release provided an example: This version contains 7 security fixes, one of which is on the comment management page, which can trigger stored cross-site scripting through pending comments. This type of fix is worth looking at separately because it clearly states that the 'review interface itself is also an attack surface.'
Why does the attack occur on the back end instead of the front end?
The pending content naturally has a contradiction: to determine whether it should pass, the administrator must see it in a form close to the original. The front-end display goes through the filtering and escaping of the release process, while the back-end list strives for 'presentation as it is,' using different rendering paths, and the attack surface appears in the latter.
Three kinds of performance correspond to three causes.
| Performance | Trigger condition | Cause location | Effective protection |
|---|---|---|---|
| Pop-up window when the back-end comment line is opened | Content is directly spliced into the page | Unescaped output | Escaped by context |
| The list is rewritten by scripts or hijacks the session. | Execute login status inheritance in the background | Boundary between permissions and sessions | Minimum permissions with same-origin verification |
| Triggered only in preview functionality | Preview goes through another rendering branch | Filtering rules are inconsistent | Both branches have the same escaping rules |
The key judgment is: the security requirements of the same data in different contexts are different. It is treated as content when put into the text, as attributes when put into the list title, and as a template when put into the preview. It can only be cleaned once when stored, and it cannot meet all three contexts at the same time.
Why is the filtering in storage not enough
The filtering of sensitive words solves the issue of content compliance, replacing or blocking hit words without understanding the script semantics. Attackers can choose not to violate the construction of the word list, or let the malicious segments wait until the field concatenation takes effect. Therefore, content review and injection protection are two different things that cannot be replaced by each other.
The output escaping is effective because it acts at the moment of rendering: no matter where the data comes from or how it is stored, when outputting as HTML, it is re-constrained according to the current context. It is also配合 with the rendering method itself - inserting the content as a text node, which is safer than concatenating it into a tag string, as the former does not interpret the script.
The third is the permission boundary. After the back-end is hit by the script, the amount of loss depends on what the session can do. If the audit action requires explicit confirmation, and the write interface does not accept a way that can be triggered solely by address access, then the script execution can only read the list at most, and cannot change the site configuration. JWT authentication and role permissions play a role here: they determine the scope of impact after the script is triggered.
The corresponding control point within the site
AnQiCMS has corresponding mechanisms in these areas. The content security settings provide sensitive word filtering and keyword replacement, content review, to control the content entering the display; anti-crawling interference codes and comment anti-spam control the behavior of bulk content extraction and灌写; The security side is built-in JWT authentication and places SQL injection and XSS defense on the same chain. The interface layer also has an important principle: interfaces for high-risk operations such as backup, upgrade, and multi-site are not open by default, and need to be explicitly enabled to be used, which is equivalent to preemptively limiting how far the script can go after being triggered.
The recommended order of implementation on the configuration is as follows: First, confirm that the background list and preview rendering paths follow the same output rules, then check if the write action requires explicit confirmation and source verification, and finally check if the review interface requires complete session permissions. The reason for this order is very practical - issues with the rendering layer will directly affect the administrator's operations, while issues with the permission layer will determine the radius of loss after the problem occurs, both layers need to be collected.
How to self-inspect?
A low-cost self-check method: submit a message on the test station with a pair of tags that do not produce any actual effect, and then open it in three positions: front-end, back-end list, and preview. If it is displayed as is in all three positions, it means that the rendering layer is safe; if it is only parsed in the back-end, it means that the rendering path of the back-end is not consistent with the front-end, and this is the layer that needs to be repaired.
The same type of check should also cover entries like nicknames, field names, and attachment filenames that are not often changed. Their common point is that the content is not updated for a long time, but it is re-rendered every time the list is opened, which belongs to the easiest to miss persistent input surface. For sites that have installed old versions, the follow-up method is not to delete comments, but to upgrade to a version containing fixes first, and then clean up the long-stayed pending entries in the queue - keeping them is equivalent to keeping a batch of inputs that may be re-rendered at any time.
Common questions
Question: Isn't it more stable to only display the number of pending comments without displaying the content?
Answer: It can reduce the risk, but the content needs to be reviewed. A compromise is to only display plain text summaries without retaining the original markings.
Question: Isn't the sensitive word filtering enough?
Answer: Not enough. It targets the word list, not the script construction, and their targets are different.
Question: Can changing the back-end address alone prevent such problems?
Answer: Changing the address only reduces the chance of being automatically scanned, but the rendering layer issue still exists, and administrators will trigger it during normal operations.