yireo / magento2-salesblock2-by-ip
Block transactions based on IP matching
Yireo SalesBlock2ByIp for Magento 2
This module is a helper-module for the Yireo_SalesBlock2 extension, that allows you to block orders from being placed, based on specific rules defined in the Magento Admin Panel.
This specific module allows you to match by a specific IP pattern. The following patterns are supported:
192.168.1.1or2001:db8::1= Direct IP matches (IPv4 and IPv6, in any notation)192.168.1.0/24or2001:db8::/32= IP ranges in CIDR notation192.168.1.1 - 192.168.1.10= Explicit IP ranges*= Every visitor
Be careful with *: a rule with this pattern blocks orders from every visitor of the store. Partial wildcards like 192.168.1.* are not supported and never match. Use a CIDR range like 192.168.1.0/24 instead. Invalid patterns (like 192.168.1.0/33) are skipped and never match.
Installation
To install this module, use the following commands. First, install this module using composer. Note that this step will fail if the Yireo_SalesBlock2 is not installed yet.
composer require yireo/magento2-salesblock2-by-ip
Once this module is installed via composer, you can enable it:
./bin/magento module:enable Yireo_SalesBlock2ByIp
There are no further steps to take. The Yireo_SalesBlock2 module automatically picks up on things.
Client IP detection and reverse proxies
This module reads the client IP from REMOTE_ADDR only. The X-Forwarded-For header can be set to any value by a client, so it is ignored by default.
When Magento runs behind a reverse proxy (load balancer, CDN, Varnish), add the IP addresses of your proxies to the setting Trusted proxies under Stores > Configuration > Yireo > Yireo SalesBlock. When a request comes from a trusted proxy, the rightmost IP in the X-Forwarded-For header that is not a trusted proxy is used as the client IP.
Upgrading to 2.1.3
Versions 2.1.1 and 2.1.2 configured Magento's RemoteAddress globally to trust the X-Forwarded-For header, which allowed visitors to fake their IP (see security advisory YIREO-SALESBLOCK2-BY-IP-2026-001). Version 2.1.3 removes this override. If your store is behind a reverse proxy, configure the Trusted proxies setting after upgrading. If other parts of your store relied on Magento core reading X-Forwarded-For, configure the alternativeHeaders argument of Magento\Framework\HTTP\PhpEnvironment\RemoteAddress in your own project, preferably with a header that your proxy overwrites.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog,
and this project adheres to Semantic Versioning.
[Unreleased]
[2.1.3] - 26 November 2026
Security
- Backport of security advisory YIREO-SALESBLOCK2-BY-IP-2026-001 from 3.0.0
Fixed
- Visitors could bypass IP rules by faking the X-Forwarded-For header: the global RemoteAddress override is removed, which also restores Magento core features relying on RemoteAddress (maintenance allowlist, CAPTCHA, rate limits); stores behind a reverse proxy must configure the new "Trusted proxies" setting (see README)
- An invalid IP range (like 10.0.0.0/33) caused an exception on add-to-cart and checkout for every visitor
- The customer message revealed the configured blocklist pattern; it now shows a generic message with the visitor's own IP
- A cached IP could be reused across requests on long-running app servers, and any code could overwrite the detected IP via setIp()
Added
- New "Trusted proxies" setting: X-Forwarded-For is only used when the request comes from a listed proxy IP, read from the right
- IPv6 range matching and recognition of alternative notations of the same IP
[2.1.2] - 21 November 2025
Fixed
- Switch from wikimedia/ip-set to wikimedia/ip-utils [#3 @Krinkle]
[2.1.1] - 10 April 2024
Fixed
- Rename RuleMatch namespace because of compat PHP 8.2
[2.1.0] - 25 April 2022
Added
- This CHANGELOG
Removed
- Removed unneeded module version
[2.1.0] - 16 April 2022
Fixed
- Remove PHP dep from composer
- PHP 8 compatibility (and therefore Magento 2.4.4)
Previous versions were not added to CHANGELOG
| Version | Stability | QA Status | Compatibility | Released |
|---|---|---|---|---|
| 2.1.3 | stable | Not tested | Not yet tested Details | 2026-11-26 01:03:59 |
| 3.0.0 | stable | Fail | Magento 2.4.7-2.4.9 Details | 2026-11-25 16:53:16 |
| 2.1.2 | stable | Fail | Magento 2.4.8 Details | 2025-11-21 08:01:18 |
| 2.1.1 | stable | Not tested | Not yet tested Details | 2024-04-10 10:15:27 |
| 2.1.0 | stable | Not tested | Not yet tested Details | 2022-04-16 13:17:26 |
| 2.0.0 | stable | Not tested | Not yet tested Details | 2021-02-17 16:10:54 |
Requires 5
| Package | Constraint |
|---|---|
| ext-pcre | * |
| magento/framework | ^101.0|^102.0|^103.0 |
| php | >=8.2 <8.6 |
| wikimedia/ip-utils | ^4.0.1 || ^5.0 |
| yireo/magento2-salesblock2 | ^2.2 |
Requires-dev 2
| Package | Constraint |
|---|---|
| phpunit/phpunit | ^10.0 |
| yireo/magento2-integration-test-helper | ~0.0 |
No QA results yet
QA pipelines haven't run for this version. Compatibility and quality results appear here once the vendor publishes a tagged release that gets ingested.
More from yireo
View vendorReplace bundled third party packages from Magento
N/A
Turn an existing module into recurring revenue.
If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.