Why should directory upload be prohibited from type sniffing, and what are the differences in configuration methods between the two types of web servers?

📅 2026-10-11 👁️ 12

Why should the upload directory prohibit the browser from guessing the type based on content: because the default behavior is that 'when the declared type is unclear or does not match, the browser will guess one itself'. In a static directory, files are uploaded by visitors, and there may be a discrepancy between the type declaration and the actual content of the files. If the guessed result is executed as a script, an upload directory can become an executable entry point. After adding the header to prohibit sniffing, the browser only processes according to the given type and no longer checks the content to infer; for requests targeting scripts or styles, if the type does not match the expectation, the response will be blocked directly.

Among them, PbootCMS has made this into a version change: The release notes of V3.2.22 specify the addition of MIME and nosniff rules for the upload directory, automatic deployment under Apache, and manual introduction of a static upload directory configuration snippet under Nginx. This difference is not in the rules themselves, but in the boundary of

At which step does the default sniffing occur?

It happens after the browser receives the response and before deciding how to render. The type declaration has no effect when it is normal; once the file type uploaded does not match the actual content, the sniffing will give an explanation inconsistent with the site's intention. The two types of risk points are scripts and styles: the browser's type checking for them is already strict, and prohibiting sniffing will directly block mismatches, which is actually a protection.

It should be distinguished that blocking sniffing does not change what the server returns, but how the browser interprets it. Therefore, it cannot prevent the step of being mistakenly interpreted as executable content, and does not replace the type checking and directory execution permission checks during upload.

Why is the upload directory at higher risk?

Because it meets three conditions: the file is provided externally, the path can be directly accessed, and the content does not participate in the rendering of the in-site template. The first two conditions allow the attacker to place selected content on a public address, and the third one allows it to affect the interpretation method without going through template injection.

When uploading attachments through the internal interface, the file content will enter the request body in base64 encoding form, and this type of entry is usually judged by the program type; while accessing static files directly in the upload directory, the program is not passed through, and the rules can only be issued by the server layer. This is why this header needs to be added separately at the directory level, as adding one for the entire site is easy to miss subdirectories, or to limit normal download responses together.

Differences in the distribution of two types of servers

Dimension Apache Nginx
Location of the rules Configuration files within the directory, which can be deployed with the program Site configuration or configuration fragments introduced
生效方式 Directory-level configuration can be automatically deployed Manually import the corresponding segment and reload
Scope of action Cover at the directory granularity Cover the segment that matches the path
Pay attention when upgrading Leave a backup before overwriting the directory configuration Confirm the reload after importing the segment

The difference is focused on 'Who puts the rules in that layer.' The advantage of configuration within the directory is that it follows the site, making it easier to take with reinstallation or migration; while the other type needs to explicitly introduce a segment in the site configuration, it is easy to miss the new site without version control of configuration management. That change of PbootCMS separately wrote the two cases into the release record, which is a reminder that the latter is not automatically completed.

The order of verification during deployment

Deploy these rules in four steps. **Step confirm that the access path of the directory matches the actual physical path, it is easiest to configure to an empty path when rewriting the rules. Second step confirm whether the header is really issued: request a file in the directory once, and see if that statement is in the response. Third step confirm that the download function is not restricted, and it needs to be checked separately when downloading attachments depending on the type declaration. Fourth step keep a rollback configuration, in case it is broken, the site can return to the original issuance status.

The on-site backup capability will take data and static files together, check the upload directory configuration while confirming that this layer is included in the backup range, the rules can be restored if deleted by mistake, and there is no need to rewrite it from memory.

Common questions

Can adding禁止嗅探replace the upload verification?No, it only changes the way the browser interprets the response, and type and extension name verification still needs to be done when stored.

Add to the entire site or directory?Adding to the entire site is a more common starting point, but the paths of dynamic content return or download entry need to be returned separately, to avoid resources being blocked from loading when type declarations are not standardized.

Why didn't the configuration take effect after it was written?Three reasons at most: path mismatch, rules added at unrequested locations, and service not reloaded after changes.

Do both types of servers need to be configured?Only configure the link that actually handles static files; when both are connected, the layer that sends the static response is the standard.

Related articles

The scoring criteria has been upgraded to a major version, can the severity of the two announcements be compared directly.

The vulnerability scoring criteria changed from 3.1 to 4.0, and the scores given by the two announcements cannot be simply compared horizontally. The qualitative grading intervals are compatible between versions, still divided into four grades from zero to ten, but the scope of assessment does not include economic losses. This article explains what the score and grading are compared to across versions and falls into the follow-up action for a high-risk fix at home once.

2026-10-11

The support scope of the security announcement only lists the main program, and the issues extended out are whose responsibility.

The scope of support for the security announcement of the content system is often only written for the main program, framework, and official site, and the vulnerabilities of third-party extensions are not on this list. The Joomla Security Center explicitly states that it only provides support for these types. This article explains which channel to publish extension issues and the two gaps within the site: content review before entry and permission control according to roles.

2026-10-11

The SQL injection announcement states that it only affects one database configuration, can other sites not be scheduled?

High-risk SQL injection announcement states that it only affects a certain database configuration, but sites using other engines are indeed not directly hit, but the schedule cannot only look at this line. The rating, whether it can be exploited anonymously, the affected configuration conditions, and the repair version given by the branch are four different dimensions. This article explains how to read these four points, as well as the backup and verification before the upgrade.

2026-10-11

Before installing the content system, check the database and script language versions first, and what it means to write the compatibility limit as discontinued maintenance.

Check two things before installing the content system: the recommended runtime version by the official, and the compatibility lower limit written as 'Also usable.' The official requirements page for WordPress recommends newer scripting languages and database versions, and also states that older versions have entered the maintenance phase and may pose security risks. This article discusses which tier to configure, where the risk falls when the lower limit hits the maintenance phase, and compares the deployment differences when running one level less.

2026-10-11

What are the entry requirements for taking back the mandatory jump to HTTPS after joining the preload list?

To bring back the mandatory jump to HTTPS of the site, it is necessary to distinguish between two layers: the response header only takes effect for browsers that have already visited, and after entering the preloading whitelist, the threshold is a validity period of at least one year and must include subdomains. This article explains the criteria for both, why it is necessary to go through a secure request when撤销ing, and which layer to change when modifying the configuration within the site.

2026-10-11

What's the difference between returning 451 when a page is taken down due to compliance requirements and directly giving a 404?

Pages taken down due to compliance requirements should return 451 or 404? The difference is not in whether the page is accessible, but in which layer the reason for unavailability is written in the status code. This article explains the semantic boundaries of 451, the responsibility party's explanation of where it should be written in the response body or link, and the handling of taken-down pages in the site map and content review process.

2026-10-11

How to turn off camera and location capabilities by default in the response header for web pages that do not need them?

Using the Permissions-Policy response header to turn off camera, microphone, and location capabilities not used by the page, the core is that the default allowed list values only have three: asterisk, same-origin, and empty. This article explains the scope of this header, why the nested frame must appear in the parent page list at the same time, and the boundary that the allow attribute can only be narrowed but not broadened.

2026-10-11

What request header is used for resuming a large file download, and what will the server return if it does not support it?

Resuming a file download depends on the Range header in the request, combined with the Accept-Ranges header in the response to determine if the server supports range requests. The server returns 206 for valid ranges and 416 for invalid ranges; servers that do not support range requests will simply ignore this header and return the entire 200 response. This article explains the method of judgment, byte offset notation, and the additional benefits of a single segment range.

2026-10-11