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

📅 October 12, 2026 👁️ 19

Why does the login lock and IP blacklist recognize the wrong source address when the website is hosted behind a reverse proxy, the root cause is that two layers of addresses are treated as one layer.When connected directly, the program reads the visitor's address from the connection itself, the two layers overlap, and no problem can be seen. After adding a layer of proxy or gateway in front, the endpoint of the connection becomes the proxy, and the real visitor's address can only be passed through by the proxy written into the forwarding header.These two clues are one that is determined during the handshake and cannot be altered by the other party, and one that is transmitted in text form, whatever the person making the request wants to write. Once the code treats them as the same type of information, the object begins to misalign.

The two levels of addresses are not the same thing to begin with

The first layer is the connection layer source. It is determined by the transport layer, and the program receives the 'who established this TCP connection with me'. After attaching a proxy, this value steadily points to the address of the proxy itself, and the same source in the logs comes from this. The second layer is the claimed layer source, commonly in the form of headers like X-Forwarded-For, whose content is appended by the front-end node to describe 'where did the initial request come from'. It can be used, but its availability depends on whether the link is trustworthy: if the request passes through an attacker-controlled node before entering the site, then this claim can completely be forged.

The judgment logic needs to distinguish between these two things: the source of the connection layer is evidence, and the source of the claim layer is testimony. Using testimony as evidence is equivalent to allowing the visitor to fill in their identity themselves.

What will happen if we unconditionally trust the source head?

The code that causes problems is straightforward: when the program retrieves the address, it first looks at the forwarding header and uses whatever is in it, without checking if this jump is the proxy of its own, nor does it care how many segments have been chained. PbootCMS has fixed this type of problem in the update records of V3.2.25 - the address retrieval function unconditionally trusts X-Forwarded-For, leading to IP whitelist and login lock bypass, and the same version added the configurable item of trusted proxy.

The consequences are specifically in two places. Login locking is based on the cumulative number of failed attempts from the source address, the address can be self-reported, and the attacker changes a value each time, so the count never falls on the same person, and the lock is as good as none. The blacklist is the opposite, a means of banning, banning the real endpoint, but the field used for judgment is伪造的, so the real address is still used, and the false address is mistakenly injured. The common defect of the two is the same: using an editable field as an identity identifier.

Only take the most可信 value in the可信 chain.

The common practice is to declare the trusted proxy segment first, and then decide from which segment to take values. When a request goes through multiple proxy levels, multiple addresses will be stringed out in the forwarding header, with the ones on the leftmost likely being filled in by the visitor, and the ones on the rightmost being closer to the control of the next hop. Therefore, the rule for taking values should be from right to left, with the first address that does not belong to the trusted proxy segment being the source. Any content written by the jump not on the trusted list should not be trusted at all, and the address at the connection layer should be returned.

The premise of this rule is to configure 'Who is my proxy' as an explicit fact, rather than by inference. The configuration item may appear in the program, in the gateway, and both places need to be changed to be considered complete; if only one layer is changed, the other layer will still be valued according to the old rules, and the divergence between the log and the judgment will continue.

Which layer should be used for speed limit and lock?

The function of penalizing according to the source, the address level used depends on the target of the penalty. Limiting brute force attempts, banning misuse of sources, the target is the real initiators, therefore, the address after the credible link is restored should be used; For the overall throttling of a certain entrance, the object is this channel entering the site, and using the connection layer address is more stable. Mixing the two types in a switch often results in mistakenly locking a large number of normal users from the same source, while the actual high-frequency attempts recover after changing a self-reported value.

The same address also depends on which layer the field is written to in the log. During troubleshooting, only the address at the connection layer is considered, but it is determined using the claimed layer address, which does not match on both sides, causing distortion in both reproduction and statistics.

Common questions

Question: Isn't it more convenient to delete the entire forwarding header?Answer: After deleting it, only the address at the connection layer remains, and the determination will degrade to 'collectively handling by proxy address', which will cause greater damage. The correct approach is to retain and configure a trusted network segment, rather than canceling this layer of information.

Question: If there is only one self-built proxy layer, do you still need to configure a trusted network segment?Answer: Yes. The role of the trusted segment is to confirm that this hop is worth trusting, regardless of the number of layers. After configuration, the rules for taking values have a basis, and it does not need to be rederived when adding a cache or gateway layer in the future.

Question: If the program is changed, do we need to make changes to the gateway?Answer: Yes. The address is written by the front-end node and read by the program, and the agreement at both ends needs to be changed before it takes effect. When only the program is changed, whether the front-end node needs to be appended and how the appending format is still in the old state.

Related articles

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

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

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

The image processing library decodes the binary content uploaded by users on the server, and remote code execution often occurs at the decoder layer rather than the business code. PbootCMS added the dangerous coder gate, input format whitelist, and resource limit to the security hardening in the V3.2.22 version record, and fixed the misjudgment of legal images. This article explains the three gates of entry for the site upload link, as well as why it would hurt normal images if it is too tight.

2026-10-11

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

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

After the user logs out, old data still remains in the browser, how to require the response header to be cleared.

When logging out, the cache and local storage left in the browser will not disappear automatically. The Clear-Site-Data response header is a clear signal for the client, which can clear cache, credentials, storage, and execution contexts item by item, and it only takes effect in encrypted connections: credentials are cleared for the entire registration domain, and storage is only cleared for the current source. The login status within the site is carried by JWT, and the local data at this client layer relies on it to complete the cleanup. It is especially worth adding on public devices.

2026-10-12

The browser will mark whether the request is from this site or an external site, and how the server can prevent cross-site requests based on this.

The browser adds several Sec-Fetch request headers that indicate the source relationship, which frontend scripts cannot change. The values distinguish between same-origin, same-site, cross-site, and no-origin, and the server decides whether to allow or deny based on these relationships, thereby providing a complementary defense against cross-site request forgery; these headers are only sent in requests from trusted addresses. This article discusses the meanings of the four values, the way to allow based on context, and what they each manage in round-level operation approval.

2026-10-12

When the content does not change, the server only returns a status code, and conditional requests rely on which identifier to judge.

The cache expiration does not mean that you need to download the entire content again. ETag is the identifier of a version of the resource, and a new value must be generated when the resource content changes; the client uses If-None-Match to return the old value during a revisit, and if the server compares it and finds it consistent, it will only return a status code without the body. This article talks about what this identifier represents, the difference between strong verification and weak verification, why the weak identifier can affect segmented requests, and how sites with frequently changing content can use it to reduce duplicate transmission.

2026-10-12