Skip to content

[HttpFoundation] IPv4-mapped IPv6 addresses incorrectly rejected #48421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2022
Merged

[HttpFoundation] IPv4-mapped IPv6 addresses incorrectly rejected #48421

merged 1 commit into from
Dec 9, 2022

Conversation

bonroyage
Copy link
Contributor

@bonroyage bonroyage commented Dec 1, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #48420
License MIT

I've based it on 4.4 because that's where #48050 was merged into, but I guess I'm 1 day too late with a fix for that version

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.3 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Oh no, it looks like you have made this PR towards a branch that is not maintained anymore. :/
Could you update the PR base branch to target one of these branches instead? 5.4, 6.0, 6.1, 6.2, 6.3.

Cheers!

Carsonbot

@bonroyage bonroyage changed the base branch from 4.4 to 5.4 December 1, 2022 11:09
@bonroyage
Copy link
Contributor Author

Tests seem to be failing on unrelated issues in the Serializer component

@carsonbot
Copy link

Hey!

I think @PhilETaylor has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@PhilETaylor
Copy link
Contributor

Interesting. I have never seen a "IPv4-mapped IPv6 address" in the wild. I had never heard of them until today. Sorry if my previous PR caused you issues.

@bonroyage
Copy link
Contributor Author

bonroyage commented Dec 6, 2022

Interesting. I have never seen a "IPv4-mapped IPv6 address" in the wild. I had never heard of them until today. Sorry if my previous PR caused you issues.

I hadn't seen them used anywhere until Azure when my regular IPv4 trusted proxies didn't work without converting them to IPv6 first ($ip6 = "::ffff:{$ip4}"). Fortunately, we managed to detect the issue early and lock to 6.1.7 for now.

There is a potential other discussion to be had about the expected behaviour of these methods, one I'm not familiar enough with IP to offer an educated opinion on. The question of whether IPv4-mapped IPv6 addresses should be compared against IPv4 addresses/CIDR and vice versa. Given the naming of these methods, it would seem wrong to return true in my opinion. Concretely in code samples:

checkIp4('10.0.0.123', '::ffff:10.0.0.0/8')
checkIp6('::ffff:10.0.0.123', '10.0.0.0/8')

@emielmolenaar
Copy link

emielmolenaar commented Dec 6, 2022

I have just tested this, and this fixes the issue for us. We are dealing with IPv4-mapped addresses like ::ffff:172.28.0.1. I have not tested this PR using subnets.

@fabpot fabpot modified the milestones: 4.4, 5.4 Dec 9, 2022
@fabpot
Copy link
Member

fabpot commented Dec 9, 2022

Thank you @bonroyage.

@fabpot fabpot merged commit 5ac1693 into symfony:5.4 Dec 9, 2022
@bonroyage bonroyage deleted the fix-ipv6-check branch December 13, 2022 12:12
@fabpot fabpot mentioned this pull request Dec 16, 2022
This was referenced Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants