Why should the validation of reading and writing data be separated when a second injection occurs in the exported file?

📅 2026-10-13 👁️ 12

The reason why second-order injection is easily overlooked is that it does not occur at the moment of 'writing data'. In the official security fix of WordPress 7.1.3, there is such an item: There is a second-order SQL injection (second-Order SQL injection) in the WXR export process. The danger does not lie in how malicious the data is when it comes in, but in the fact that this data is stored and then reused as a trusted value in the next link, which is then pieced into the query. This is the fundamental reason why the verification of reading and writing data needs to be separated.

What is meant by being triggered for the second time

Common injection is blocked at the submission entry: the user input contains the intention to concatenate SQL, and the validation layer rejects it. The second injection changes its approach - the data coming in looks harmless to humans and animals, even having passed a surface check, quietly lying in the database. The real problem occurs in the second instance: a function takes out the value from the database as is, combines it into a new statement or exports it to a file. At this point, it no longer goes through the original entry validation, and the malicious structure is 'activated' in a new position.

The keyword is 'No longer goes through original verification'. The defense line set on the write path assumes that the data is clean by default, so the read path, export path, and then import path often skip checks. The attacker is exploiting this trust gap.

Why is the import phase a high-risk exit?

Export and import are the most typical secondary entry points on this chain. Export organizes data from the library into files, seemingly just moving, but actually it is 're-arranging'——if the assembly is done by directly concatenating trusted values, dirty data will enter the file with its original malicious structure. The next part is even more dangerous: if this file is re-imported into the system or imported into another system, it is treated as 'user-provided batch data' at this point. If the new system does not perform escape-level decoding, injection will occur in the import step.

WXR is the format used by WordPress to export content and data, the fact that it is listed separately in security fixes just shows that data migration interfaces are a common entry point for such problems: its responsibility is to read out the contents of the library and write them out again, naturally stepping on the second use step.

What do the entry check and exit check check?

Split the two checks into different responsibilities in order to cover the complete path of secondary injection.

The check for entering the data is whether「This data is legally valid according to its type」:field length, character set, enumeration range, whether it is unauthorized to write columns that should not be decided by the user. It manages the shape of the incoming data. The check for exiting the data is whether「This data is about to be拼进 into which syntax」:bind parameters or escape according to SQL syntax when拼进 SQL, encode output when拼进 HTML, and reorganize according to the target format when written into an export file instead of transmitting it as is.

One sentence: Check by type for entry, escape by target grammar for output. The same data is not necessarily clean when entering, it does not mean it is clean when reused by other statements, so the check at the exit cannot be omitted.

How to implement on-site batch import and collection?

AnQiCMS batch import supports ZIP compressed packages and Excel tables as carriers. Content collection is to move content from other sites. Both of these paths are typical 'external content entering the library', and they may also become secondary entry points. The processing principle is consistent: treat all incoming content as untrusted input.

There are three points in the implementation. **, The import and collection are checked according to the field type and length when entering the database, and not relaxed because 'it comes from the file'. Second, when the data is read, combined, or exported by subsequent functions, escape at the output level, and do not assume that the things in the library are always clean.Third, the rules for preventing SQL injection should cover sorting and filtering parameters, not just the text content - the list sorting parameters are directly inserted into the query, which is also a second use of the data in the tiger's mouth.AnQiCMS built-in SQL injection and XSS defense receives this kind of untrusted input,配合sensitive word filtering and interference codes, the entry, storage, and exit segments are all passed through once.

Common questions

Ask: The data has been verified when it was stored, why does the export need to be processed again? Answer: The entry verification only guarantees compliance at that moment, when the data is re-read and combined, it no longer goes through it, and it needs to be escaped again according to the target syntax at the exit.

Ask: What should be paid attention to when importing external files in batches? Answer: Treat the content in ZIP or Excel as untrusted input, verify according to the field type, and go through the exit for escaping when reading and using it.

Ask: Will content collection amplify the risk? Answer: Yes, the collected content is large in volume and diverse in source, both entry and exit verifications must be done, and cannot be skipped because of batch processing.

Ask: Is it enough to correct the text injection? Answer: No, sorting, filtering and other parameters are also common junctions that need to be included in the prevention of SQL injection checks.

Related articles

Storage XSS appears on the comment management page, how did the script get into the background in the pending review comments.

WordPress 7.1.3 fixed a stored XSS vulnerability that could be triggered by pending review comments in the comment management page. This article explains why unreviewed content can still be rendered and executed in the background, the danger lies in treating comments as trusted data output, and the closing should be based on input verification and output escaping, and corresponding to the site's sensitive word filtering, content review and verification code protection.

2026-10-13

Can WordPress minor versions be directly updated automatically with 11 security fixes in one go?

This is a minor security update for WordPress 7.1.1 that includes 11 security fixes. The official recommendation is to update immediately, and sites that support automatic background updates will start updating automatically. This article explains which steps of the automatic update can be covered, and which situations require manual scheduling of the upgrade window, as well as the backup and credential rotation confirmation to be done before and after the update.

2026-10-13

The backend user deletion has been changed to POST submission and form credential verification, preventing which type of attack?

The content system has changed the user deletion and status switching to POST submission and form security credential verification in the version announcement to prevent cross-site request forgery from causing users to be mistakenly deleted or their status changed. This change blocks cross-site request forgery - attackers take advantage of the browser automatically carrying the login state. Moving the status change from GET to POST is just a **layer, and the real barrier to forgery is the credential verification that comes with the form.

2026-10-12

Before the release of the major version, how many weeks of security support are left for the old branch, and how should the upgrade window be arranged?

At the same time, only a few branches usually receive security fixes, and there will be no official patches for new vulnerabilities from the day the support is discontinued. Taking the release plan of a certain content system as an example, the security release window covers only a few specific branches, and the old branches will end support in the week of the new major version release. The upgrade window should be arranged in reverse order: first determine the day of discontinuing support, then leave time for verification and rollback, data backup must be done within the window, and login credentials must be processed as described in the upgrade instructions for the home version.

2026-10-12

Comments on private articles are read without authorization, and the permissions should be blocked at the list level or the detail level.

WordPress 7.1.3 fixed the issue where unauthorized users could read private and unpublished article comments. Unauthorized access often occurs in附属资源 such as comments and attachments, because the visibility of the main object does not automatically pass to the child set. This article explains that permissions must be checked at both the list and detail levels, and how the scope of visibility is implemented within the site based on document status and user groups.

2026-10-13

One update fixes seven security issues, should you upgrade first or check if you have been hacked first?

WordPress 7.1.3 brings 7 security fixes and recommends an immediate update. The sequence of handling depends on whether there are any signs of intrusion: if there are no signs, directly proceed to the upgrade window, if there are signs, only close the entry during the upgrade, and also handle the sessions and credentials that the attacker has obtained. This article takes the upgrade prompt of AnQiCMS v3.6.6 as an example to explain why it is necessary to rotate the keys and change the password together.

2026-10-13

Fixing only one severe vulnerability also requires a separate release, how does reading a local file escalate to remote code execution?

WordPress 7.1.2 is a separate release just to fix a severe level vulnerability: An unauthenticated attacker can allow the page template to parse any local PHP file outside the theme directory under certain conditions, and it becomes remote code execution when the server and theme prerequisites are met. This article analyzes the few steps from reading the file to executing the code, and corresponds to the on-site prevention of injection, backup, and credential rotation after upgrade.

2026-10-13

The page builder component can upload any file, and how the site is completely taken over step by step.

Singapore CSA Notice AL-2026-085 points out that two types of Joomla page builder components have high-risk arbitrary file upload vulnerabilities, which can lead to remote code execution and complete control of the site. This article analyzes the steps from uploading to taking control, and corresponds to the site's content review, anti-injection, and backup rollback, explaining the differences in handling component vulnerabilities and core vulnerabilities.

2026-10-13