How does bypassing XSS filters occur, and why is a blacklist of tags not enough?
How did the bypass of the 'XSS Filter' in the security announcement occur? In one sentence: The filter and the browser have inconsistent understanding of the same string of text.The filter judges whether this content is safe according to its own rules, and the browser decides whether to execute it according to a different set of rules. The bypass method is to construct input that has different answers in these two sets of rules - in the eyes of the filter, it is ordinary text, and in the eyes of the browser, it becomes executable code.Joomla's recent two InputFilter announcements correspond to these two types of differences: one involving the handling of whitespace characters in HTML data URIs, and one involving HTML5 entity decoding.
Understanding this, you can answer the second question: why only doing tag blacklist filtering is still bypassed - blacklist checks 'how does this text look', and the browser executes 'how this text is parsed', there is always an interpretation gap between the two
Where does the bypass occur
Content enters the system generally through two processes. At the time of entry, filtering is performed: tags, attributes, and protocols that are not allowed are removed or rewritten; at rendering time, escaping is performed: the content is recoded according to the syntax rules of the target location.
The issue with blacklist filtering is that it must simulate the browser's parsing rules to judge accurately, while the parsing rules themselves are different in different contexts. The same text placed in element content, attribute values, JavaScript strings, or URL parameters has completely different safe writing styles. The filter has only one set of rules, but there are many rendering contexts, and this asymmetry is the location where bypassing occurs.
These two differences between data URI and entity decoding are typical examples: whether whitespace characters are considered valid separators, and what characters entity notation is decoded into, the answers of filters and browsers are different, and the check is as if it were a mere formality.
Three failure scenarios of blacklist filtering
The first is encoding and notation variants. The same character can have multiple writing styles, the filter recognizes several common ones, but the browser accepts all of them. The second is context switching. When content is reused between attributes, scripts, and URLs, the originally safe writing becomes executable in the new context. The third is parsing differences. The parts of the specification that allow browsers to make compatibility handling are exactly the parts that the filter is hardest to cover.
These scenarios have a common point: none of them can be covered by simply adding a few black list rules. The longer the rules become, the higher the cost of judgment, but the probability of missing judgments will not decrease significantly, because the problem lies in the difference between the rules and the parser, not the number of rules.
The division of labor between input filtering and rendering escaping
Duties need to be clarified: input filtering is a content governance method, the purpose of which is to make the stored things basically clean, convenient for display and reuse; rendering escaping is the execution point of preventing injection, because it encodes the content according to the syntax requirements of the output location, so that the data is no longer interpreted as code.
The correct approach is to treat them as two separate processes, not to let the former replace the latter. Any content from user input - comments, messages, custom fields, imported text - must be escaped according to the context in which it is rendered, regardless of whether it has been filtered when stored.
Another boundary is equally important: the protection measures against cross-site scripting and SQL injection are not the same. SQL injection is blocked by parameterized queries, not keyword tables; mixing them into a category of 'sensitive content checking' usually means neither line of defense is established.
Several things should be configured for content security.
Within AnQiCMS's built-in protection, the sensitive word filtering and keyword replacement address how to handle the content of matched rules, content review determines whether this record can be exposed externally, these two belong to content governance and cannot be understood as injection protection. Anti-crawling interference codes are aimed at bulk copying and are unrelated to execution security.
It is necessary to confirm these items one by one: whether there is validation at the entry of forms and messages; whether the submitted content is also escaped in the background list - although the content to be reviewed is not displayed on the front page, it will still be rendered by the browser during the background review, which is the most likely to be overlooked; whether the output of the rich text editor is processed according to the context when rendered; whether the encoding of the output of static pages is unified.
Three-tier responsibility comparison
| Level | Means | Purpose | What cannot be blocked |
|---|---|---|---|
| Entry filtering | Blacklist of tags and attributes, sensitive word filtering, keyword replacement | Keep the stored content relatively clean | Parsing difference bypass |
| Rendering escape | Re-encode according to the output context | Prevent the data from being executed | Defects in the logic itself |
| Parameterization | Query separation from parameters | Block SQL injection | Irrelevant to script execution |
Common questions
Is it necessary to retain the filter? Yes. It can reduce the amount of dirty content entering storage and reduce the processing pressure on the display layer, but the positioning must be clear: content governance, not a security boundary.
How to verify if there is such a risk? Submit a batch of test content containing unconventional notations, encoding variants, and different contextual usage. Check whether it is executed as is during the rendering of the front and back ends. The scope of inspection should include the pending review list, as attackers can deliberately submit and wait to be viewed.
Can the patch upgrade replace the escape? No. The patch fixes specific parsing differences, while the escape covers all output positions.
A criterion for judgment
By looking at how a system treats user-submitted content, you can judge its injection protection level: does it rely on 'the incoming things have been filtered', or does it rely on 'regardless of what comes in, re-encode according to the context when outputting'? The former is probability, and the latter is a mechanism.