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

Security: Doesn't encode urls with punycode #395

Open
SamuelScheit opened this issue Feb 2, 2022 · 4 comments
Open

Security: Doesn't encode urls with punycode #395

SamuelScheit opened this issue Feb 2, 2022 · 4 comments

Comments

@SamuelScheit
Copy link

Malicious actors could trick victims into click phishing links, because they look exactly like the valid original domain.
E.g. the original apple.com url could be converted using the cyrillic alphabet to аррlе.com which looks identical to the original url.
That's why the browser encodes urls with special characters using punycode to xn--l-7sbq6ba.com
You can check it, if you enter this in the browser console:

new URL("https://аррlе.com").href

this should result in

'https://xn--l-7sbq6ba.com/'

However this react-native-url-polyfill library doesn't encode urls using punycode which results in a huge security risk for the end user.

@SamuelScheit SamuelScheit changed the title Security: Doesn't encode with punycode Security: Doesn't encode urls with punycode Feb 2, 2022
@charpeni
Copy link
Owner

charpeni commented Feb 2, 2022

Thanks for bringing this concern.

I think this is still better than React Native's implementation, but still not perfect.

What would you suggest in order to address this issue while remaining lightweight? Should we try to encode them with a lightweight library? Should we throw on URLs with special characters?

@SamuelScheit
Copy link
Author

I'm not sure, but it looks like you are using whatwg-url-without-unicode and I don't know if it can encode those urls.
Maybe the package whatwg-url does support it

@charpeni
Copy link
Owner

charpeni commented Feb 2, 2022

Yes. I'm the author of whatwg-url-without-unicode and it doesn't support unicode so we can use URL and URLSearchParams with a smaller footprint (372 KB to 40.9 KB).

@SamuelScheit
Copy link
Author

Wow thats a lot, I appreciate the effort, maybe there is a lightweight punycode lib to handle this issue.

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

No branches or pull requests

2 participants