Storage XSS appears on the comment management page, how did the script get into the background in the pending review comments.
A stored XSS appears on the comment management page, relying on the
Why unreviewed content can trigger
Many people think that 'review' is a wall: content that does not pass the review will not take effect externally. This wall blocks the front-end display, but not the back-end rendering. The role of the comment management page is precisely to let administrators preview the content to be reviewed so that they can decide whether to allow it or not. Since previewing, the system must display it, and if the 'display' step is not escaped, it is equivalent to executing the user's submitted content as part of the interface.
So the triggering path is: a visitor submits a comment with a script, the status is pending review, and it quietly lies in the list; the administrator opens the comment management page to deal with the backlog, and the browser executes the script when rendering this record. Throughout the process, the comment is always 'pending review', but XSS has already occurred. 'Pending review' describes whether the content can be published, not whether it will be read and displayed by the background - these two things have been confused, leaving a gap.
The danger lies in the background treating it as trustworthy data.
The same comment data has different trust levels in the foreground and background. The foreground is controlled by the review status, and the ones not passed will not appear; the background must be displayed exactly for people to be able to judge. The danger lies in the default display in the background, where it is directly stitched into the page as 'This is my own management interface, and the data is reliable.'
The feature of storage is here: the script is first stored in the database, and then executed again each time someone opens the relevant page, not triggered once. To close the mouth, it cannot only be checked at the moment of submission, but also to ensure that no matter which interface this data is opened later or by whom, it is not treated as executable content when output.
The two layers of closing the mouth: check-in verification and output escaping
The truly stable approach is to stack the two checkpoints, any one of which is not enough when used alone
| Level | What is done | What to prevent |
|---|---|---|
| Check-in verification | Filter out dangerous tags and script fragments at the time of submission, and refuse obvious malicious structures | Block most direct attacks and reduce dirty data falling into the database |
| Output escaping | Escape content as plain text when displaying, and the background list should also be handled in the same way | Even if dirty data has been stored, it will not be executed on the page |
Relying solely on storage validation will still leak, because there are always new ways to bypass filtering; relying solely on output escaping is also not enough, because once dirty data is concatenated in other scenarios, it may still cause problems. Only by doing both together can the 'storage-rendering' chain be truly cut off. Methods like front-end pop-up interception cannot be counted as this layer, as what it intercepts cannot be replaced by server-side and template escaping.
Where are the three layers of protection placed within the site
Compare the design of AnQiCMS, and you can see that similar problems are divided into three sections with each section responsible for a part of the protection, rather than piled together.
**The process of filtering sensitive words and keyword replacement,配合内容审核,to control whether the content can enter and whether it needs to be processed when entering. This is the implementation of the entry inspection. The second line is the built-in XSS protection and SQL injection defense, which controls that the data is not executed as code during storage and query, and belongs to a lower-level input control. The third line is the reCAPTCHA verification code integrated into the form, which does not judge whether the content is dangerous, but raises the cost of batch submission, making it difficult for attackers to inject a large number of comments to be reviewed by scripts.
Three different positions are stuck at submission, storage, and rendering, and there is still a backup for any one that is bypassed. This is much more stable than relying on the assumption that 'since it hasn't been reviewed, it won't be displayed'.
Common questions
Q: The comments have always been in the review state, not displayed on the front end, does that count as being affected? A: Yes. The back-end comment management page will render the pending review content, and the script can be executed when the administrator opens it.
Q: Can it be considered as completed if only the malicious comment is deleted? A: No. Storage XSS needs to be upgraded to the official fixed version, and deleting a single comment does not solve the root cause of the unescaped rendering.
Ask: Is the front-end intercept enough? Answer: Not enough. Both the server-side check-in and template output escaping need to be done, and the front-end can be bypassed.
Ask: Is sensitive word filtering and content review redundant? Answer: No. Filtering deals with the surface words, and review decides whether to allow or not, both of which are responsible for XSS output escaping.