When /127 Quietly Became /124
Apigee's AccessControl policy built IPv6 allow-list ranges by walking the address four bits at a time, so any prefix length not divisible by four was silently rounded down to the previous nibble boundary. An attacker with an IPv6 address in the widened part of the range could reach a proxy route the owner believed was restricted to a much narrower network.
Published on bugs.exposed
Apigee has separate implementations for IPv4 and IPv6 ranges in its AccessControl policy. The IPv4 version looked exactly as boring as an IP allow-list should: build a mask, calculate the lower and upper bounds, compare the address.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Apigee is Google Cloud's API management platform, and its AccessControl policy is the component that decides whether a request is allowed to reach an API proxy based on the caller's IP address. In practice it is an allow-list (or deny-list) mechanism: you configure one or more IP ranges, and the policy compares the incoming address against them.
Internally, Apigee keeps separate implementations for IPv4 and IPv6 ranges. The IPv4 path is unremarkable: it builds a mask, calculates the lower and upper bounds, and compares the address. The IPv6 path does something different, and that difference is where this bug lived.
The affected version was v1-15-0-apigee-1. The issue was reported on 27 April 2025, has since been patched, and earned a USD 7,500 bounty.
Setup
Two equivalent proxy flows were built:
/acl/124, with an allow rule for2001:db8::/124./acl/127, with an allow rule for2001:db8::/127.
Both policies read the candidate client address from a custom ip header rather than from the real connection. That was purely a test harness convenience: it allowed switching addresses without arranging several IPv6 network interfaces on the client side. As the report notes, a normally configured policy evaluates the requester's actual IPv6 source address, so the header trick is not a precondition for exploitation.
Before touching a live proxy, the researcher reproduced the range calculation in a standalone Java program, comparing Apigee's nibble-based loop against a bit-level mask implementation.
Finding it
The IPv6 constructor walked through the address four bits at a time. That is not automatically suspicious: IPv6 is written in hexadecimal, and one hex digit is exactly four bits, so a nibble-oriented loop is a natural way to read the textual form.
The problem was in the two conditions repeated for every byte:
if (mask >= 4) {
mask -= 4;
} else {
}
There was no case for one, two or three remaining network bits. A valid IPv6 prefix can end after any of the 128 bits, so the question was what Apigee would do with a prefix such as /127, which leaves three bits after the last complete nibble.
Exploitation
Step 1: Read the constructor
IP6AddressRange represented each configured network as two BigInteger values, low and high. It parsed the IPv6 address into sixteen bytes and then handled the high and low nibble of every byte separately. The complete constructor branch was:
if (mask >= 4) {
mask -= 4;
BigInteger higherBits = BigInteger.valueOf(b & 240);
this.low = this.low.or(higherBits.shiftLeft(order));
this.high = this.high.or(higherBits.shiftLeft(order));
} else {
this.high = this.high.or(BigInteger.valueOf(240L).shiftLeft(order));
}
if (mask >= 4) {
mask -= 4;
BigInteger lowerBits = BigInteger.valueOf(b & 15);
this.low = this.low.or(lowerBits.shiftLeft(order));
this.high = this.high.or(lowerBits.shiftLeft(order));
} else {
this.high = this.high.or(BigInteger.valueOf(15L).shiftLeft(order));
}
With at least four mask bits remaining, the constructor copies the complete nibble from the address into both bounds and subtracts four. Otherwise it copies nothing: low keeps four zeroes and high receives four ones. In other words, a partial nibble is treated as fully wildcarded.
Step 2: Work through /127 by hand
Take 2001:db8::/127. After fifteen complete bytes, seven mask bits remain for the final byte. The first branch copies its high nibble and reduces the mask to three. The second mask >= 4 check then fails, so the final three network bits disappear together with the one actual host bit.
The result is a much larger interval:
configured: 2001:db8::/127
intended: 2001:db8::0 - 2001:db8::1
constructed: 2001:db8::0 - 2001:db8::f
The constructed range is effectively /124. The hypothesis was now concrete: Apigee would treat /127 and /124 as the same allow-list.
Step 3: Confirm the arithmetic in isolation
A standalone Java program implemented the range calculation twice: once following Apigee's nibble loop, once building the bounds with a bit-level mask. Both were asked whether 2001:db8::f belongs to 2001:db8::/127:
Apigee-style range (2001:db8::/127):
low = [redacted]
high = [redacted]
Bitmask range (2001:db8::/127):
low = [redacted]
high = [redacted]
Test address 2001:db8::f:
Apigee-style match: true
Bitmask match: false
The calculation behaved exactly as the branch suggested. One question remained: did the surrounding AccessControl policy validate, normalise or reject the range before using it?
The Apigee documentation accepts IPv6 masks from 1 through 128, and even notes that values outside the tidy hexadecimal boundaries can be used for finer control. /127 was therefore valid configuration, not an unsupported input forced into an internal class.
Step 4: Test the live policy
Two equivalent proxy flows were deployed. /acl/124 used an allow rule for 2001:db8::/124; /acl/127 used 2001:db8::/127. Both read the candidate client address from the custom ip header.
First, 2001:db8::f was sent to /acl/124. Apigee returned HTTP 200, as expected, because ::f is the last address in that range.
Then the same value was sent to /acl/127:
GET /acl/127 HTTP/1.1
Host: <test Apigee host>
ip: [redacted]
A correct /127 contains only ::0 and ::1, so this request should have missed the allow rule and returned HTTP 403. It returned HTTP 200. The policy had not repaired or rejected the constructor's range; it had used it directly for the authorization decision.
Step 5: Note the real-world reach
The custom header was only part of the test harness. A normally configured policy can evaluate the requester's actual IPv6 source address, so an attacker did not need to spoof a forwarding header: an address from the widened part of the configured network was enough.
Root cause
The nibble loop assumed that a prefix always ends on a four-bit boundary. When fewer than four mask bits remain, the else branches copy nothing from the address and instead set the remaining bits of high to ones, widening the range to the end of the current nibble. The effective prefix is rounded down to the preceding nibble boundary:
effective prefix = floor(configured prefix / 4) * 4
One discarded network bit doubles the range, two bits make it four times larger, and three bits make it eight times larger. /65, /73, /125 and /126 all follow the same pattern.
The policy layer did not catch it: the documentation permits masks from 1 to 128, and the policy used the constructor's range for the decision. The mismatch is between two models of the same value: the code followed the printed hexadecimal digits, while the policy contract is measured in bits.
Impact
For an ALLOW rule, the extra addresses in the widened range became authorised. A proxy developer could believe that an internal API or administrative route was restricted to a narrow IPv6 network while Apigee admitted clients from the surrounding range.
Exploitation required knowledge of the configured allow-list and control of an IPv6 address inside the added portion. It did not require membership in the proxy owner's Google Cloud organisation merely to call a public proxy.
The same arithmetic widened DENY rules as well, but in that direction it blocked more clients than intended rather than producing an authorization bypass.
Fix
The report does not describe the patch itself.
Variants to test
- Other prefix lengths not divisible by four. Try
/65,/73,/125and/126against an allow rule and request an address just outside the intended range but inside the rounded-down nibble boundary. A positive result is HTTP 200 where a correct implementation would return 403. - Other products with separate IPv4 and IPv6 range parsers. Compare the two code paths; a nibble-oriented IPv6 loop next to a bit-level IPv4 loop is the pattern to look for. A positive result is a range whose computed
highbound ends inffor a prefix that should not. - Documented-but-unusual masks. Where documentation permits masks outside tidy hexadecimal boundaries, check whether the parser silently rounds them. A positive result is a configured
/nbehaving likefloor(n/4)*4. - Deny rules. Check whether a widened
DENYrule blocks legitimate clients from the surrounding range, which confirms the same rounding without needing an allow-list bypass.
What happened, in plain words
Google Cloud has a product called Apigee. Apigee sits in front of an organisation's APIs and decides which requests are allowed through. An API is the doorway that software uses to talk to other software: when a mobile app shows you a weather forecast, it is calling a weather API behind the scenes. Apigee is the guard at that doorway.
One of the guard's tools is the AccessControl policy. A policy is a small set of rules you attach to the doorway. This particular policy looks at the address of the computer making the request and checks it against a list of allowed addresses. You write down one or more ranges of addresses, and the policy lets in callers from those ranges and turns away everyone else. This kind of list is called an allow-list. The opposite, a list of addresses to keep out, is a deny-list.
Addresses on the internet come in two flavours. The older one, IPv4, looks like [redacted]. The newer one, IPv6, looks like 2001:db8::1 and is much longer. Apigee had two separate pieces of code for checking these two flavours. The IPv4 piece did the obvious thing: it turned the range into a mask, worked out the lowest and highest address in the range, and compared the caller's address against those two bounds. The IPv6 piece did something different, and that difference is where the bug lived.
The affected version was v1-15-0-apigee-1. The issue was reported on 27 April 2025, has since been patched, and earned a USD 7,500 bounty.
Setting up the test
A proxy here is the Apigee configuration that receives a request and forwards it to the real API behind it; think of it as the reception desk that checks your name before letting you into the building.
Two equivalent proxy flows were built:
/acl/124, with an allow rule for2001:db8::/124./acl/127, with an allow rule for2001:db8::/127.
Both policies read the candidate client address from a custom ip header rather than from the real connection. A header is a small labelled line that travels with every web request, like the address label on an envelope. Normally the server reads the sender's address from the network connection itself; here the test deliberately told the policy to read it from a header instead. That was purely a test harness convenience: it allowed switching addresses without arranging several IPv6 network interfaces on the client side. As the report notes, a normally configured policy evaluates the requester's actual IPv6 source address, so the header trick is not a precondition for exploitation.
Before touching a live proxy, the researcher reproduced the range calculation in a standalone Java program, comparing Apigee's nibble-based loop against a bit-level mask implementation. Java is a programming language; a standalone program is one you run on your own machine, outside the product, to check a piece of logic in isolation.
Finding it
The IPv6 constructor walked through the address four bits at a time. A constructor is the part of a program that builds an object from the values you give it; here it builds the range object from the configured network. A bit is the smallest unit of computer data, a single zero or one. Four bits together are called a nibble, and one hexadecimal digit (0 to 9, then a to f) is exactly one nibble. That is why walking four bits at a time is not automatically suspicious: IPv6 is written in hexadecimal, so a nibble-oriented loop is a natural way to read the textual form.
The problem was in the two conditions repeated for every byte:
if (mask >= 4) {
mask -= 4;
} else {
}
Line by line: if (mask >= 4) asks whether at least four bits of the network prefix are still left to process. mask -= 4; takes four of them off the count. The else branch is empty, meaning that when fewer than four bits remain, nothing happens at all. There was no case for one, two or three remaining network bits. A valid IPv6 prefix can end after any of the 128 bits, so the question was what Apigee would do with a prefix such as /127, which leaves three bits after the last complete nibble.
Exploitation
Step 1: Read the constructor
IP6AddressRange represented each configured network as two BigInteger values, low and high. BigInteger is a Java type for very large whole numbers, needed because an IPv6 address is a 128-bit number, far bigger than an ordinary integer can hold. low is the first address in the range and high is the last. It parsed the IPv6 address into sixteen bytes and then handled the high and low nibble of every byte separately. A byte is eight bits, so it holds exactly two nibbles. The complete constructor branch was:
if (mask >= 4) {
mask -= 4;
BigInteger higherBits = BigInteger.valueOf(b & 240);
this.low = this.low.or(higherBits.shiftLeft(order));
this.high = this.high.or(higherBits.shiftLeft(order));
} else {
this.high = this.high.or(BigInteger.valueOf(240L).shiftLeft(order));
}
if (mask >= 4) {
mask -= 4;
BigInteger lowerBits = BigInteger.valueOf(b & 15);
this.low = this.low.or(lowerBits.shiftLeft(order));
this.high = this.high.or(lowerBits.shiftLeft(order));
} else {
this.high = this.high.or(BigInteger.valueOf(15L).shiftLeft(order));
}
Line by line. The first block handles the high nibble of the current byte. if (mask >= 4) checks that at least four prefix bits remain. mask -= 4; uses up four of them. BigInteger.valueOf(b & 240) keeps only the top four bits of the byte: 240 is binary 11110000, so the AND operation masks off the lower half. this.low = this.low.or(...) and this.high = this.high.or(...) copy those four bits into both the lower and the upper bound, shifted into the right position by shiftLeft(order). The else branch runs when fewer than four bits remain: it copies nothing from the address into low, and instead sets the same four positions in high to ones, using 240 again.
The second block does the same for the low nibble of the byte. b & 15 keeps only the bottom four bits, because 15 is binary 00001111. The else branch again copies nothing into low and sets those four positions in high to ones, this time with 15.
With at least four mask bits remaining, the constructor copies the complete nibble from the address into both bounds and subtracts four. Otherwise it copies nothing: low keeps four zeroes and high receives four ones. In other words, a partial nibble is treated as fully wildcarded. A wildcard is the same idea as a joker in a card game: it stands for any value.
Step 2: Work through /127 by hand
Take 2001:db8::/127. The /127 is the prefix length: it says that the first 127 bits of the address are fixed and only the last bit is free. After fifteen complete bytes, seven mask bits remain for the final byte. The first branch copies its high nibble and reduces the mask to three. The second mask >= 4 check then fails, so the final three network bits disappear together with the one actual host bit. A host bit is the part of the address that identifies an individual machine rather than the network.
The result is a much larger interval:
configured: 2001:db8::/127
intended: 2001:db8::0 - 2001:db8::1
constructed: 2001:db8::0 - 2001:db8::f
Line by line: the first line is what the administrator wrote in the policy. The second line is what a correct implementation should produce, two addresses only, ::0 and ::1. The third line is what Apigee actually built, sixteen addresses from ::0 to ::f. The constructed range is effectively /124. The hypothesis was now concrete: Apigee would treat /127 and /124 as the same allow-list.
Step 3: Confirm the arithmetic in isolation
A standalone Java program implemented the range calculation twice: once following Apigee's nibble loop, once building the bounds with a bit-level mask. Both were asked whether 2001:db8::f belongs to 2001:db8::/127:
Apigee-style range (2001:db8::/127):
low = [redacted]
high = [redacted]
Bitmask range (2001:db8::/127):
low = [redacted]
high = [redacted]
Test address 2001:db8::f:
Apigee-style match: true
Bitmask match: false
Line by line: the first two lines show the lower and upper bound produced by Apigee's logic, written as one long hexadecimal number. The upper bound ends in f, the last value of a nibble. The next two lines show the bounds produced by the correct bit-level logic, where the upper bound ends in 1. The last two lines ask the same question of both: does the test address 2001:db8::f fall inside? The Apigee-style answer is true, the correct answer is false.
The calculation behaved exactly as the branch suggested. One question remained: did the surrounding AccessControl policy validate, normalise or reject the range before using it? To validate means to check that a value is acceptable; to normalise means to rewrite it into a standard form.
The Apigee documentation accepts IPv6 masks from 1 through 128, and even notes that values outside the tidy hexadecimal boundaries can be used for finer control. /127 was therefore valid configuration, not an unsupported input forced into an internal class.
Step 4: Test the live policy
Two equivalent proxy flows were deployed. /acl/124 used an allow rule for 2001:db8::/124; /acl/127 used 2001:db8::/127. Both read the candidate client address from the custom ip header.
First, 2001:db8::f was sent to /acl/124. Apigee returned HTTP 200, as expected, because ::f is the last address in that range. HTTP 200 is the standard status code for success; HTTP 403 means forbidden.
Then the same value was sent to /acl/127:
GET /acl/127 HTTP/1.1
Host: <test Apigee host>
ip: [redacted]
Line by line: GET /acl/127 HTTP/1.1 is the request line, asking for the path /acl/127 using the GET method, which is the ordinary method for fetching something, over version 1.1 of HTTP, the protocol browsers and servers use to talk. Host: <test Apigee host> names the server being contacted. ip: [redacted] is the custom header carrying the address to be tested, written out in full with leading zeroes; it is the same address as 2001:db8::f.
A correct /127 contains only ::0 and ::1, so this request should have missed the allow rule and returned HTTP 403. It returned HTTP 200. The policy had not repaired or rejected the constructor's range; it had used it directly for the authorization decision. Authorization is the act of deciding whether a caller is permitted to do what it is asking.
Step 5: Note the real-world reach
The custom header was only part of the test harness. A normally configured policy can evaluate the requester's actual IPv6 source address, so an attacker did not need to spoof a forwarding header: an address from the widened part of the configured network was enough. To spoof means to pretend to be something you are not.
Root cause
The nibble loop assumed that a prefix always ends on a four-bit boundary. When fewer than four mask bits remain, the else branches copy nothing from the address and instead set the remaining bits of high to ones, widening the range to the end of the current nibble. The effective prefix is rounded down to the preceding nibble boundary:
effective prefix = floor(configured prefix / 4) * 4
Line by line: configured prefix is the number after the slash, for example 127. Dividing by 4 and rounding down with floor gives the number of complete nibbles, here 31. Multiplying back by 4 gives 124. So a configured /127 behaves like /124.
One discarded network bit doubles the range, two bits make it four times larger, and three bits make it eight times larger. /65, /73, /125 and /126 all follow the same pattern.
The policy layer did not catch it: the documentation permits masks from 1 to 128, and the policy used the constructor's range for the decision. The mismatch is between two models of the same value: the code followed the printed hexadecimal digits, while the policy contract is measured in bits.
Impact
For an ALLOW rule, the extra addresses in the widened range became authorised. A proxy developer could believe that an internal API or administrative route was restricted to a narrow IPv6 network while Apigee admitted clients from the surrounding range.
Exploitation required knowledge of the configured allow-list and control of an IPv6 address inside the added portion. It did not require membership in the proxy owner's Google Cloud organisation merely to call a public proxy.
The same arithmetic widened DENY rules as well, but in that direction it blocked more clients than intended rather than producing an authorization bypass.
Fix
The report does not describe the patch itself.
Variants to test
- Other prefix lengths not divisible by four. Try
/65,/73,/125and/126against an allow rule and request an address just outside the intended range but inside the rounded-down nibble boundary. A positive result is HTTP 200 where a correct implementation would return 403. - Other products with separate IPv4 and IPv6 range parsers. Compare the two code paths; a nibble-oriented IPv6 loop next to a bit-level IPv4 loop is the pattern to look for. A positive result is a range whose computed
highbound ends inffor a prefix that should not. - Documented-but-unusual masks. Where documentation permits masks outside tidy hexadecimal boundaries, check whether the parser silently rounds them. A positive result is a configured
/nbehaving likefloor(n/4)*4. - Deny rules. Check whether a widened
DENYrule blocks legitimate clients from the surrounding range, which confirms the same rounding without needing an allow-list bypass.
Glossary
- API: the doorway software uses to talk to other software, for example a weather service an app calls.
- AccessControl policy: an Apigee rule that allows or blocks requests based on the caller's IP address.
- Allow-list: a list of things that are permitted; everything not on it is refused.
- Deny-list: a list of things that are refused; everything not on it is permitted.
- IPv4: the older internet address format, such as
[redacted]. - IPv6: the newer, longer internet address format, such as
2001:db8::1. - Proxy: the Apigee configuration that receives a request and forwards it to the real API behind it.
- Header: a labelled line sent with a web request, like the address label on an envelope.
- Test harness: the setup built purely to run a test, not part of the product itself.
- Java: a programming language.
- Constructor: the part of a program that builds an object from the values you give it.
- Bit: the smallest unit of computer data, a single zero or one.
- Nibble: four bits together, equal to one hexadecimal digit.
- Byte: eight bits, equal to two nibbles.
- Hexadecimal: a number system with sixteen digits, 0 to 9 then a to f, used to write IPv6 addresses.
- BigInteger: a Java type for very large whole numbers.
- Mask: a pattern of bits used to keep some bits of a value and discard others.
- Wildcard: a symbol that stands for any value, like a joker in a card game.
- Prefix length: the number after the slash in an address range, saying how many leading bits are fixed.
- Host bit: the part of an address that identifies an individual machine rather than the network.
- Validate: to check that a value is acceptable.
- Normalise: to rewrite a value into a standard form.
- HTTP 200: the standard status code for a successful request.
- HTTP 403: the standard status code for a forbidden request.
- GET: the ordinary HTTP method for fetching something.
- HTTP: the protocol browsers and servers use to talk to each other.
- Authorization: the act of deciding whether a caller is permitted to do what it is asking.
- Spoof: to pretend to be something you are not.
- Authorization bypass: getting access that the rules were meant to refuse.
- Parser: the part of a program that reads a written value and turns it into an internal form.
- Bounty: a payment made for reporting a security bug.