-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Invalid Token if run in IFrame #537
Comments
https://snappymail.eu/tests/iframe.html works Problem might be application.ini
|
Thank you for your quick response, highly appreciated! :-) I tried
Also:
I might add that Snappymail has been working with the settings shown in the ticket until maybe v2.17 or so (not 100% sure). Since then it stopped working. I am a bit suspicious about the cookie: the login page loads successfully, leading me to think the CSRF settings are ok; however logging in does not work showing the Invalid Token error. I am trying some more things over here, too, maybe I find something useful. |
Hmmm sounds more like cookie issues. Or do you have a second (never used) browser and use its incognito window? |
Yep, working on a new incognito tab on Firefox. Edit: Just to triple-check: Same thing on new incognito tab on Edge. |
Sorry, i don't have Windows OS anywhere, so i can't check Edge |
Hating Edge too, just used it to triple-check. I use Firefox. :-) Thank you for pointing me to the console - should have thought for that for myself ...
mydomain.tld edited for anonymity. Ok, I am stuck here as I am not so familiar with CSRF: If I am very grateful for a hint or link so I can educate myself... |
I've just simplified the code with the release of v2.18.3 as So, to get what you want, you need to set the CSP in application.ini
else try
|
Thank you for the new release and your explanations/examples. I installed v.2.18.3 on my server. However, the error persists as described in my first post. Snippet of application.ini
I tried both content_security_policy variations. Firefox Inspector Console reads
I only see warnings in the Firefox Console, no errors. Apache2 log reads
|
Right, there the security kicks in. Say, someone creates an iframe for your webmail on I've made a small change to the code so that you can change P.S. keep in mind that |
I applied the diffs of commit 69ae65b. Furthermore, I added
I can confirm that now everything works fine, no more Invalid Token error occurs. Thank you very much! :-) |
Hi, could it be that #719 changed the behavior of the After updating to 2.24.3 login via an I-Frame again is not longer possible. Firefox Console says: Config says: |
Any news on this issue? |
Looking into it |
Thank you, unfortunately it did not solve my issue. When trying to log in in an IFrame I still get "Unknown Error". Browser Console says Cookies successufully set are |
When |
Just double checked:
Here the HTTP answer of calling /snappymail/ (Domain name edited by me for anonymity)
Request header:
|
Try again. |
Log
|
I am having the same problem, although Snappymail opens in an iFrame, when run on localhost. I have it integrated in a Yii2 application and with Sso. It is in Dutch, but translated it sounds like something: Some cookies abuse the recommended "SameSite" Does this sound as something that is solvable? |
As in my example above: |
Is your Then currently it is not possible due to cross-domain security. You are on the right path with |
I have the |
|
I can confirm that manually editing the cookie What I did:
However, whatever I do editing v/X.X.X/static/js/boot.js, e.g
it DOES not work, @the-djmaze Another thing: Setting
disallows any other site that www.site1.tld to embed snappymail (www.site2.tld). |
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-src
So this controls iframes on site2.tld are allowed, but does not control if site1.tld is allowed as parent. For what you want read: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors |
I see, thank you for pointing that out! Good sources! So I should better change
to
Thank you @the-djmaze :-) |
Ha, that was actually also the problem with setting the cookie
Thank you, @the-djmaze, you are my hero! And I really love how actively and reliably you maintain this wonderful project. Thank you so much! |
Same here! Have changed everything backed and made only the changes mentioned by @sonnyka . |
Describe the bug
When run in an iframe (in my case in organizr) snappymail refuses to login. The error shown is "invalid token".
Login w/o an iframe works.
To Reproduce
Steps to reproduce the behavior:
Please complete the following information:
Debug/logging information
(I substituted my domain name with [mydomain.tld] for security reasons)
[Fri Sep 30 11:46:22.274836 2022] [php7:notice] [pid 117628] [client 2a02:8071:XXX:71a6:ee5b:56771] TOKENS DEBUG: New SESSION_TOKEN
[Fri Sep 30 11:46:22.328075 2022] [php7:notice] [pid 117628] [client 2a02:8071:XXX:71a6:ee5b:56771] SERVICE WARNING: InvalidToken[101]\r\n#0 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/Actions/UserAuth.php(195): RainLoop\Actions->getMainAccountFromToken()\n#1 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/Actions.php(1238): RainLoop\Actions->getAccountFromToken()\n#2 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/Actions/Folders.php(55): RainLoop\Actions->initMailClientConnection()\n#3 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/ServiceActions.php(155): RainLoop\Actions->DoFolders()\n#4 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/Service.php(133): RainLoop\ServiceActions->ServiceJson()\n#5 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/app/libraries/RainLoop/Service.php(15): RainLoop\Service::RunResult()\n#6 /var/www/[mydomain.tld]/snappymail/snappymail/v/2.18.2/include.php(169): RainLoop\Service::Handle()\n#7 /var/www/[mydomain.tld]/snappymail/index.php(11): include('/var/www/...')\n#8 {main}
Additional context
-- Snippet from application.ini --
[security]
; Enable CSRF protection (http://en.wikipedia.org/wiki/Cross-site_request_forgery)
csrf_protection = On
custom_server_signature = "SnappyMail"
x_frame_options_header = "ancestors 'self' https://*.[mydomain.tld]"
x_xss_protection_header = "1; mode=block"
openpgp = Off
Does not matter if I set csrf_protection = Off
The text was updated successfully, but these errors were encountered: