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

Chrome may loose session #1779

Closed
DL6ER opened this issue Nov 23, 2023 · 5 comments · Fixed by #1786
Closed

Chrome may loose session #1779

DL6ER opened this issue Nov 23, 2023 · 5 comments · Fixed by #1786

Comments

@DL6ER
Copy link
Member

DL6ER commented Nov 23, 2023

I received a report I was able to reproduce but which is pretty hard to reproduce: You will also have to have a dual-stack network, i.e., your Pi-hole is reachable both via IPv4 and IPv6, for this to happen.

  1. Log in to your Pi-hole using it's hostname (not via IP!), e.g., https://pi.hole/admin
  2. Browse around the web interface
  3. Eventually get logged out - it may also happen on the dashboard without doing anything

Taking a close look at the Network tab in the Developer Tools didn't reveal anything odd, but checking out the debug logs of FTL told us what happens here: When browsing to your Pi-hole via hostname, Chrome prefers to picks IPv6 to connect - and sessions are tied to IP addresses for extra safety in FTL.

It can now happen - completely randomly and all out of sudden, that Chrome instead decides that connecting via IPv4 is a brilliant idea. However, the session obtained during login is only valid for fda2:45fe:... and not 192.168.0.3 so the API replied with 403 Unauthorized causing the entire web interface to show you the login page.

What do we do about this?

My ideas:

  1. Waive adding session protection by fixing it to an IP. This will make it possible to steal sessions from other computers on your network when you can either record network traffic and manage to somehow otherwise get the cookie and CSRF token. This is anyway impossible when HTTPS is used.
  2. FTL can only know the IP address used when authenticating for sure. We could use the network table to get correlated IPv4 addresses but this is error-prone especially with sequential DHCP servers that may have handed out the address to another device meanwhile.
  3. Somehow try to get IPv4 and IPv6 address via Javascript and include them in the login process. My idea would be to define new special hostnames like v4.pi.hole and v6.pi.hole which will only reply over said protocol. We can then get the client's IP address from /api/info/client ({"remote_addr":"fd29:...."}, etc.). This is a lot of effort and will still fail if a host has multiple IPv4 addresses in the same network (e.g. one over Ethernet and one over WiFi).
@rdwebdesign
Copy link
Member

I think option 1 is the most common way to handle sessions.

@yubiuser
Copy link
Member

I also think option 1 is the way to go, esp. you already listed the caveats of the other two options

but this is error-prone especially with sequential DHCP servers that may have handed out the address to another device meanwhile.

This is a lot of effort and will still fail if a host has multiple IPv4 addresses in the same network (e.g. one over Ethernet and one over WiFi).

@DL6ER DL6ER linked a pull request Nov 27, 2023 that will close this issue
5 tasks
Copy link

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

@github-actions github-actions bot added the stale label Dec 27, 2023
@yubiuser
Copy link
Member

Fixed by the linked PR

@github-actions github-actions bot removed the stale label Dec 27, 2023
@pralor-bot
Copy link

This issue has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/webui-behind-lighttpd-reverse-proxy/71239/6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants