-
Notifications
You must be signed in to change notification settings - Fork 5k
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
[Bug]: Weird behavior for SIWE requests on localhost #18188
Comments
Update from @seaona : |
@bschorchit is there an ETA on this issue? |
@bschorchit - I opened a pr for a fix |
Thanks for that, @yonigoldberg ! We rolled out a hotfix (v10.26.2) yesterday. Is the current behavior on 10.26.2 on localhost still an issue for you? |
Thanks @yonigoldberg! LGTM! I'm adding this to our internal list of PR reviews. will try to get this in the next release I didn't realize you can't comment in the PR. To confirm, you could comment on the main thread, but not an individual comment? |
Thanks @digiwand - yheaa I can't comment there. |
[Sadly I can not comment on my PR]
|
@yonigoldberg I don't have full context so I'm making assumptions from my webapp security background. This might be wrong. That said, I think port being optional might mean it defaults to 80? I'll take a closer look. Or maybe someone more familiar with the Origin guarantees in SIWE can chime in. |
Fair point. |
@yonigoldberg the PR is unblocked now and is available to comment now. I'm up for merging in @naugtur's suggestion if that sounds good with you too |
edit: see below comments curious to learn more about the port use cases here and why this may or may not be a concern outside of localhost. |
Summarizing relevant parts of EIP-4361:
(as noted above,
CommentMy interpretation of the above:
So for #18296, my takeaway would be:
This allows the authority to decide "how wide their identity" is. Local dev/testing dapps can specify |
But other than that, being stricter and having checks for domain validation that are not part of the spec should also be non-violating. So in general it should be OK for MetaMask to add its own restrictions around "domain binding" (which may make special cases for |
FactsERC-4361, by referencing For the purpose of RFC-3986 ERC-4361 would have to define I think the lack of a field defining the also, ERC-4361 "Out of scope" section says:
In the current shape of ERC-4361 the burden of defining what Unless ERC-4361 is updated to explicitly define Our implementation has the following obligations as per ERC-4361:Obligation 1:
Obligation 2:
InterpretationExamplesWhat should we do in these situations?
Situation 1A: A page hosted at Situation 1B: A page hosted at Situation 1C: A page hosted at
Situation 2A: A local privileged service is operating on Situation 2B: A builder wants to test their application and the test setup runs it on different ports on Situation 2C: A local privileged service is operating on
Context: A hosting provider offers public IP4 and free domains, but each user on the shared hosting gets just 5 random ports. Situation 3A: A phishing page posing as usercontent.hosting.com:1973 hosted at Situation 3B: A phishing page posing as usercontent.hosting.com:1973 hosted at Situation 3A: A phishing page posing as usercontent.hosting.com:1973 hosted at DiscussionObligation 2 says we must check the Obligation 1 suggests there's a point at which we sould no longer try to block the request and let the user make the decision while providing enough context for them to understand their choice. Note that we cannot use the presence of the port in To address situations 2A and 3A without relying on users we would need to implement strict checking of the port and if Depending on how much we rely on the user's decision, these are possible behaviors to implement: ❌ - mismatch error, API returns an error, the user never get exposed to that UI. Port checking behaviors in situations above:
ConclusionsThis section includes author's opinions. We need to decide between implementing strict checking with all of the friction it introduces or a less strict behavior that's more desirable while requiring user to decide and UI to help them make the right decision.
Ensuring that UI is helping the user understand port mismatch to make up for the security tradeoff and making port checking optional with behavior 2 (optional check) seems the most promising outcome for this issue. Without changes to the UI behavior 2 may be risky and we can only go as far as behavior 3 or 4. Thanks to @legobeat for convincing me to do a deep dive into ERC,RFC,etc. cc @digiwand and @holantonela for thoughts on UI more competent than mine. |
Thanks for this analysis @naugtur! I think it makes sense to use the patters that we already have in place but reflecting the heuristics presented in your table:
|
Related issues are gathered in #18471. Looking at opened issues, a popular interpretation seems to be that no explicit port in (as per ABNF scheme-less) As noted there are some UX subtleties arising around how this is communicated regardless of which choice is made here. MetaMask/core#1163 has been updated according to the above. |
After sleeping on it I now think the most secure option for the end user would be to:
One argument against enforcing https by default is that https in the browser introduces reliance on centralized authority and not all SIWE use cases might want that. |
@legobeat and @naugtur - great analysis of the specs. Thank you 🙏 I am also convinced that the optional port should only be allowed when it is not provided. Otherwise, it should be enforced. With that, I am going to close the PR. We have updated Dynamic.xyz to always provide and validate the port in our SIWE. @naugtur - one exception about enforcing https is |
many thanks @legobeat and @naugtur! These examples are useful and I'd like to propose a couple more examples. I agree with most of them except I have a concern with 1A. 1AI see ❌ now under the "warn only" session. Was this meant to be One scenario for the mismatched domain was explained in the related ticket #17707. from @HeyFloM 's usecase #17707 (comment):
they did figure out a solution for production, but it continues to cause friction for development:
Additional Examples** [edited] Situation 1D**: A page hosted at [maybe] Situation 1E: A page hosted at Implementing strict mode alongside a developer mode setting sounds good to me. If we enforce strict mode for any of these situations, we'll need to inform developers of this change and give them time to make updates if needed. |
@digiwand My answer to the On the other hand, I'd say for your I think there's a way forward which maintains safe and compliant defaults without causing hindrance for local dev or requiring an "unsafe dev mode" (completely disable domain-binding validation? maybe a feature that could be enabled only in flask and beta), it can still be considered as a plan b. |
I think that makes sense. Distributing TLS certificates to the CDN will allow the appropriate domains to host those servers. Thanks for the advice @legobeat! okay, I agree 1A no longer needs a change. I do still believe blocking the request entirely should be communicated before implementing this situation. |
For 1A anything other than rejection would be against the spec. It's the only thing ERC is clearly requiting us to do. Note that it's not a subdomain issue but a totally different domain. I'm ok with allowing http for localhost regardless of how strict we decide to be. |
okay, that makes sense. maybe my communication was confusing. I think it's a good idea to block 1A once we have a developer setting. Even more so with the setup @legobeat mentioned above.
@naugtur when you mentioned allowing these cases, were you thinking with or without the warning modal? Just read the updated comment now @legobeat and responding to 1D comment re: 1D. okay, I see I missed this earlier. I agree and updated the comment with 👍. Snippet from EIP-4361 spec:
Good idea to include a specific setting to disable domain-binding in Flash/beta as a plan B. I've linked this comment in the PR to implement the developer mode setting #18191 (comment) p.s
|
@bschorchit I think this issue should be fixed in #18518 , which is merged to There are some hypothetical further improvements/changes mentioned in the thread - anything we want to distill to new issue(s) or we close this off once #18529 makes it to release? |
I've just checked and #18518 is part of 10.31 release - which should be rolling out soon (next week I think) to users. I don't think we need to wait to ship #18529 before closing this off. We can track and discuss anything related to planning/communicating and blocking mismatched domains directly on that issue (and other related issues) and come back to this one for reference even if closed. |
Oh, I somehow missed that it was indeed part of the release - that's great and sounds good to me - thanks @bschorchit. |
Describe the bug
This was originally reported to us here on Slack and here #17707 (comment).
This is not an issue if you don't append http:// to localhost in the URI in the message (see recording below).
Steps to reproduce
Here is a example of message to sign that was reported to cause this while on localhost : #17707 (comment)
Error messages or log output
No response
Version
10.26.1
Build type
None
Browser
Other (please elaborate in the "Additional Context" section)
Operating system
Other (please elaborate in the "Additional Context" section)
Hardware wallet
No response
Additional context
Not sure on browser and OS info.
Recording:
https://user-images.githubusercontent.com/34968356/225613863-783e9066-d1a4-4626-b5be-c358e31818ab.mp4
The text was updated successfully, but these errors were encountered: