Skip to content
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

Fixes url parsing for .888 hosts #14588

Closed
wants to merge 3 commits into from
Closed

Conversation

supermassive
Copy link
Collaborator

@supermassive supermassive commented Aug 11, 2022

Resolves brave/brave-browser#24585
Sec review: https://github.com/brave/security/issues/981

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

const char* cases[] = {
"test.888", // Non-ipv4 component case.
"test1.test2.888", // Non-ipv4 component case.
"1.2.3.4.888", // Too many components case.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add 1.2.3.888 to check that it's a valid URL but not a valid IPv4 URL.

Copy link
Collaborator Author

@supermassive supermassive Aug 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in a6ecf5c
It actually didn't pass as I didn't cover residual bits case in parse(I wrongly assumed that was not .888 case)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now DoIPv4AddressToNumber never reports BROKEN when last component is .888

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now DoIPv4AddressToNumber never reports BROKEN when last component is .888

Is that the right behavior? I mean if you have 1.2.3.888, which is not a valid IPv4 and try to convert this IPv4 URL to a number, it seems like it should fail because the input was not an IPv4 address in the first place, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For correct IPv4 address parser should say that it is exactly IPv4 address, so we don't break it
For Url parser now says it is not a broken ipv4 address, but something else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, so we now have this?

  • 1.2.3.4 -> valid URL, valid IPv4
  • 1.2.3.889 -> invalid URL, invalid IPv4
  • 1.2.3.888 -> valid URL, but not an IPv4 at all

It might be worth adding 1.2.3.889 as a test case too just to make sure that we don't change that one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added 692c0ff
also now checking for 888 ending being an exact string to avoid 888 in hex or oct form.

@supermassive
Copy link
Collaborator Author

I originally thought it was an implementation detail to forbid such urls, but now it appears it is explicitly specified behavior for url parsing:
whatwg/url#619
and
https://chromium-review.googlesource.com/c/chromium/src/+/3111118

Actually appearance of .888 tld in UD contracts happened around same time, so that was a technically legal tld when they were designing it:
unstoppabledomains/uns@b93edf3

While with this PR browser is able to handle 'something.888' and redirect to resolved content hash link I'm concerned now if is a stable solution. Chromium may always enforce this specification requirements in some other place.

@kdenhartog @diracdeltas @yrliou

@diracdeltas
Copy link
Member

While with this PR browser is able to handle 'something.888' and redirect to resolved content hash link I'm concerned now if is a stable solution. Chromium may always enforce this specification requirements in some other place.

my opinion is that it's not the risk for us to support this feature if it both goes against the whatwg spec and chromium's implementation. we should instead encourage folks to deprecate this TLD.

seems very fragile otherwise; and also the URL parsers that many web developers use like NodeJS's probably won't understand .888

@fmarier
Copy link
Member

fmarier commented Aug 22, 2022

https://github.com/brave/brave-browser/wiki/Resolve-Methods-for-Unstoppable-Domains claims that we support .888 since 1.40, that's not the case, right? This has never worked in Brave (and was meant to be fixed in this PR)?

@yrliou
Copy link
Member

yrliou commented Aug 22, 2022

@fmarier I believe so, we can resolve wallet address but URL bar resolution was never working correctly. We should update our wiki and messaging in the code, and communicate with UD that we can't support .888 due to security.

@iefremov
Copy link
Contributor

should we close this one, @supermassive ?

@yrliou
Copy link
Member

yrliou commented Aug 24, 2022

Closing as we decided not to support .888.

@yrliou yrliou closed this Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix handling of .888 tld for UD
5 participants