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

No longer able to debug flutter web app behind reverse proxy due to "Unexpected sender" #2375

Open
woprandi opened this issue Feb 20, 2024 · 21 comments
Labels
dart-debug-extension P1 A high priority bug; for example, a single project is unusable or has many test failures triaged

Comments

@woprandi
Copy link

I'm trying to develop a flutter web app behind a nginx server. It worked few weeks ago but now I got this notification :

displayNotification(
'Unexpected sender ${sender.origin}. Please file a bug at go/dde-bug or https://github.com/dart-lang/webdev',
isError: true,
);

My nginx conf

server {
    server_name <REMOTE_HOST>
    location /api {
        proxy_pass <API>
    }   

    location / { 
        proxy_pass http://localhost:9020;

        # FOR DEVELOPMENT                                                                                                                                                                                                                     
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }   
}

The 9020 port is a remote docker container with the flutter app

@elliette
Copy link
Contributor

Hi @woprandi - we've tightened the security on the Dart Debug Extension to only allow localhost origins, see: #2287

I'm not to familiar with nginx, what is the host name for your Flutter app? We could potentially add a setting to the extension that would let you specify your host.

@woprandi
Copy link
Author

woprandi commented Feb 26, 2024

The flutter app is developped on a remote machine. We should be able to disable this security. The host is not reachable from internet

@elliette
Copy link
Contributor

elliette commented Mar 4, 2024

Would specifying the host be sufficient in this case? As described above, we could add a setting to the extension that would let you specify your host.

@NDevTK
Copy link

NDevTK commented Mar 5, 2024

If you can use the hostname something.googlers.com that should work.

@woprandi
Copy link
Author

woprandi commented Mar 8, 2024

@elliette Yes if I can specify several hosts or a wildcard such as *.something it would be enough I think

@NDevTK
Copy link

NDevTK commented Mar 8, 2024

Problem is with https://bugs.chromium.org/p/chromium/issues/detail?id=1227410 it's hard to store the hostname safely while having a content script on every website.

Maybe something generic could work like: .local or a local IP address.

@woprandi
Copy link
Author

HTTPS is not even enough...

@NDevTK
Copy link

NDevTK commented Mar 14, 2024

Yeah the patch only checks the hostname.
Since the debugger API allows for a UXSS its not enough to just have a safe connection.

There are ways to safely store the hostname https://developer.chrome.com/docs/extensions/develop/concepts/storage-and-cookies#storage-in-service-workers

@quyenlv-unicloud
Copy link

@NDevTK Hi, do you known any way to test dev website on other mobile devices same lan without using something.googlers.com?

Before:

  • running flutter webs-server --web-hostname=10.50.10.10 --web-port=4200
  • open in chrome and click Dart extension
  • then all other mobile devices on same lan can access dev website at 10.50.10.10:4200

Now:

  • "unexpected sender" because not localhost
  • other mobile devices not understand "localhost"
  • the only way is change android hosts (required root?) or using customize dns server (required many work/setup)

@NDevTK
Copy link

NDevTK commented Mar 18, 2024 via email

@woprandi
Copy link
Author

@NDevTK By spoof, you means add entry to /etc/hosts file ?

@NDevTK
Copy link

NDevTK commented Mar 18, 2024 via email

@woprandi
Copy link
Author

I built the extension with the security disabled. Fortunately the patch is trivial.

@NDevTK
Copy link

NDevTK commented Mar 18, 2024 via email

@woprandi
Copy link
Author

It's supposed to be temporary until it's fixed upstream. I could try to implement the UI to add hosts on whitelist but I have no knowledge on extension development

@Zekfad
Copy link

Zekfad commented Mar 31, 2024

Why not add settings page and whitelist: https://developer.chrome.com/docs/extensions/develop/ui/options-page

@NDevTK
Copy link

NDevTK commented Mar 31, 2024 via email

@Zekfad
Copy link

Zekfad commented Apr 5, 2024

If you want to avoid chrome.storage, what about using in-memory variable from background worker?
Add button to popup that would add current tab host to whitelist until browser is restarted.
User anyway need to press open devtools to start debug session, it wont be so much of inconvenience, at least it's better than patching extension to test your app in prod environment (in our case we use external authentication provider).

@NDevTK
Copy link

NDevTK commented Apr 5, 2024

Yeah if a dialog came up when clicking on the extension icon that said "Do you want to allow origin access to all websites" that would be fine.

@Kludgy4
Copy link

Kludgy4 commented Jul 24, 2024

+1 trying to develop behind a local kong server and am getting this error as well

@woprandi
Copy link
Author

@Kludgy4 You can patch the extension to disable sender check as workaround

@bkonyi bkonyi added P1 A high priority bug; for example, a single project is unusable or has many test failures triaged and removed waiting-for-customer-response labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart-debug-extension P1 A high priority bug; for example, a single project is unusable or has many test failures triaged
Projects
None yet
Development

No branches or pull requests

7 participants