The image processing library is listed as an attack surface, what door locks should the site upload process have?

📅 2026-10-11 👁️ 23

The image processing library is listed as an attack surface because it decodes the binary content uploaded by users on the server: thumbnails, transcoding, watermarking, every operation must go through the decoder, and historically, many remote code execution incidents have occurred at this decoding layer, not in the business code.The mouth closing ideas given by the same CMS are worth comparing - PbootCMS made security hardening for Imagick in the update record of V3.2.22: added three items together, including dangerous coder access control, input format whitelist, and resource limit, and also fixed the misjudgment of legitimate images.The upload process of the site can be received with three access controls according to this framework.

Why is the image processing library considered an attack surface

Three conditions叠加:Input is not trusted (anyone can upload files), high parsing cost (image decoding requires memory and computing power), and wide format range (the encoding formats supported by the image library are much more than the actual needs of the business). Attackers have opportunities in the second phase - constructing malformed files to make the decoding process exceed the bounds, or exploiting the parsing defects of obscure formats. The upload entry looks the most 'harmless to animals and humans', just because it is trusted by default: pictures, look at it, nothing happens.

Dangerous decoders need to be turned off separately

The internal image library is divided into modules by format (coder), and modules with rare formats are high-risk areas for accidents: graphic exchange types, legacy vector and multi-frame formats, and components that can be invoked by the internal delegation mechanism. The approach to access control is to explicitly disable unnecessary modules, leaving only the coding supported by the business, rather than retaining all of them and filtering them at the upper level. This step ensures that 'format-based attacks' cannot enter the coding process at all, and the configuration is effective for a long time.

Input format is received according to the whitelist.

The second access control checks the input statement: File types are accepted based on the whitelist, only three or four image formats are commonly needed for business; at the same time, check the consistency of the actual file header with the declaration, reject if not consistent. The whitelist is more stable than the blacklist, with the same logic and extension name filtering - allow known, reject unknown. Note that the whitelist manages what is allowed to come in, while the coder access control manages how to decode what is allowed, each blocking a dimension, and missing one will have a gap.

Set resource limits for decoding

The third security door prevents cost abuse: limit the size of a single frame and total pixels, limit file size and memory usage, and set decoding timeout. Without a limit, a small file can decompress into a huge image that exhausts memory, which is the form of 'decompression bomb'; multi-frame format can also amplify processing time by several tens of times. The upper limit value is determined according to the distribution of normal business images, leaving some room but not an order of magnitude of room. The peer system lists the three items and resource limits together during the same hardening, because any one of them is missing, the other two will be bypassed.

Overly strict security doors may hurt legitimate images

The side effect of fully pulling up the three gates is misjudgment: Atypical images generated by edge browsers and ultra-large-size original photographs may be blocked by resource limits, and a too narrow whitelist may reject the required format for business. PbootCMS specifically fixed the misjudgment of legitimate images in the same record, indicating that this is not a one-time setup. The approach is to make the rejected items observable: record the distribution of reasons for rejection, review regularly, confirm whether it is an attack sample or normal content, and then fine-tune the limits and list.

Gate What to intercept Commonly mistaken injury
Disable dangerous decoding module Parsing defects of obscure formats Rare, just confirm the business format
Input format whitelist upload in disguise type rejecting legitimate new format due to narrow list
decoding resource limit unzipping bomb and ultra-large image high-resolution original rejected due to size limit

internal check of the station: AnQiCMS automatically assigns pictures according to the title, does not introduce external decoding components in the request path; when deploying with Baota panel or Docker image, it is recommended to check the upload directory and processing components according to these three security gates.

Common questions

Is it enough to only accept JPG, PNG, and WEBP in three formats?Most content is sufficient. Add animated graphics and documents as needed, for each format added, it opens up a new decoding path, and more can be added if a business reason can be provided.

How much should the resource limit be set to?Reverse engineer from the distribution of pictures on the current network: take the maximum side and total pixels of the normally uploaded pictures, and then add one to two times the extra amount. Relaxing to the level of quantity is equivalent to not setting it.

How to appeal for pictures that have been misjudged?Do not put in the hole after passing: record samples, analyze the reasons for rejection, adjust the parameters of the corresponding gate, check back with logs to confirm that the new parameters no longer hurt, this is the meaning of 'Observable Rejection'.

Related articles

The announcement removes the example function section to fix the resource allocation problem. Should the production site keep the demonstration code?

The rating of Drupal announcement SA-CONTRIB-2026-215 is only Less critical, but the handling method has completely removed the email example function, because the example has an issue with unbounded resource allocation. Should the demonstration code be retained on the production site, the criterion should be the exposure surface rather than the risk rating. This article analyzes the three types of risks brought out by the example code, the cleanup checklist at the deployment stage, and the restrictions when retaining the demonstration entry.

2026-10-11

After the cache expires, the old content is provided first, and then the update is performed in the background. What does this cache instruction solve?

Cache-Control's stale-while-revalidate allows the reuse of old content responses within the window period after expiration, while also revalidating with the origin server in the background, hiding the validation delay from the user's response. This article explains its division of labor with request directives max-stale, no-cache, and must-revalidate according to the MDN documentation, and provides suggestions for separating page documents and static resources for separate settings.

2026-10-11

What are the differences in the capabilities of the government portal and marketing website content management system?

The government portal content management system prioritizes content review, sensitive word filtering, and user group permissions, while the marketing website pays more attention to keyword libraries, anchor text, and form human verification; robots configuration and site map generation are the common foundations for both types of sites. This article breaks down the capabilities according to constraints and provides two configuration orientations within the same system to help choose based on the nature of the site rather than the length of the function list.

2026-10-11

The formula rendering module is found to be cross-site scripting, why do we need to check the rendering path together with rich text filtering?

The Drupal community announcement SA-CONTRIB-2026-195 labels the TeX rendering of MathJax module's unescaped JavaScript as Critical cross-site scripting, affecting versions below 4.1.2. Rich text, even with HTML tag whitelist, may still execute data as code for non-HTML parsing paths such as formulas, Markdown, and charts. This article explains how to read the version range and rating of the announcement, and provides a self-check list for escaping based on output context.

2026-10-11

The template tag outputs the opening tag of the script, how can the content be executed as code?

PbootCMS has fixed the risk of script tag output in site tag output script and enhanced tag page parameter filtering - when editable content enters the template engine with opening tags, the data will be treated as code. This article explains where the step of data becoming code occurs, why the tag output position needs to be filtered, and why HTML, attributes, scripts, and URLs need to be escaped separately, as well as why filtering earlier saves time and has a layered closing effect.

2026-10-11

How should the deletion range be verified for the batch deletion interface of background messages according to parameter concatenation?

If the batch deletion of background messages directly concatenates the number list sent from the front-end into the deletion conditions, it may delete out-of-range content in one request. PbootCMS has fixed this kind of parameter injection in the update records of V3.2.18, strictly checking the id list to be deleted. This article explains why the batch interface has expanded the impact range, how to verify the type and existence of the number, why the deletion range needs to be recalculated on the server side, and what the recycle bin can accommodate after accidental deletion.

2026-10-12

Why does the login lock and blacklist on the website behind the proxy recognize the source address incorrectly?

When a website is behind a reverse proxy, the program often reads the connection source as the proxy address, and the content of the forwarding header is controlled by the client. Confusing the two layers can lead to login locking and incorrect objects in the blacklist. PbootCMS has fixed the issue of unconditional trust in the source forwarding header in the update records of V3.2.25. This article discusses the origin of the two layers of addresses, the practice of taking the most right可信 value in the trusted link, and which layer to use for throttling and locking.

2026-10-12

When embedding third-party videos on a page, what authorization is used for iframe's capability to pass through?

The page embeds third-party videos with two levels of restrictions: source domain names are allowed to pass based on the whitelist, and capabilities such as camera, location, and automatic playback are authorized in the minimum set item by item. In the update records of PbootCMS V3.2.18, the default source strategy for trusted video domains is retained, and the token whitelist is set for the allow attribute. This article explains why the embedded frame carries scripts and media capabilities at the same time, how to differentiate between precise domain and subdomain wildcard, and why the release and authorization should be configured separately.

2026-10-12