openwisp / openwisp/docker-openwisp

[bug] Using an IP address or local hostname as DASHBOARD_DOMAIN silently breaks CSRF, sessions, and login

Open
#569 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
209
Forks
125
Avg merge
1d 4h
Merged PRs (30d)
24

Description

Describe the bug
When DASHBOARD_DOMAIN is set to an IP address (e.g. 192.168.1.22) or a local hostname without a real TLD (e.g. dharmikhomelab), the dashboard appears to load but login is completely broken. Every form submission returns a CSRF verification failure with no useful indication of why.

This affects anyone running docker-openwisp on a homelab, internal server, or any setup without a public domain name.

In settings.py inside the dashboard image, the following code runs at startup:

ROOT_DOMAIN = "." + tldextract.extract(os.environ["DASHBOARD_DOMAIN"]).registered_domain
CSRF_COOKIE_DOMAIN = ROOT_DOMAIN
SESSION_COOKIE_DOMAIN = ROOT_DOMAIN

tldextract is designed to parse real public TLDs. When given a raw IP or a local hostname, registered_domain returns an empty string, so ROOT_DOMAIN becomes ".".

There are no errors in any logs pointing to this. The dashboard loads, the login page renders, but every login attempt fails with CSRF verification failed. Request aborted.

Steps To Reproduce

  1. Set DASHBOARD_DOMAIN=192.168.1.22 (or any raw IP / local hostname)
    in .env
  2. Run make start
  3. Navigate to https://192.168.1.22/admin/login/
  4. Try to log in and it gives CSRF error every time

You can confirm the issue by running inside the dashboard container:

docker exec docker-openwisp-dashboard-1 bash -c \
  "DJANGO_SETTINGS_MODULE=openwisp.settings python3 -c \
  'from django.conf import settings; print(settings.CSRF_COOKIE_DOMAIN)'"

It will print . instead of a real domain.

Expected behavior
When DASHBOARD_DOMAIN is a raw IP or local hostname, OpenWISP should either fall back gracefully so login still works, or raise a clear error at startup explaining the domain is invalid, not silently corrupt cookie
settings and make the whole dashboard unusable.

System Informatioon:

  • docker-openwisp: latest / edge
  • Deployed on: Ubuntu 24.04 homelab server running CasaOS
  • DASHBOARD_DOMAIN values tested: raw IP 192.168.1.22, local
    hostname dharmikhomelab

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with settings.py in the dashboard image and reproduce the reported DASHBOARD_DOMAIN values using the provided docker exec command. Trace how ROOT_DOMAIN feeds CSRF_COOKIE_DOMAIN and SESSION_COOKIE_DOMAIN, then verify that the chosen invalid-domain behavior preserves or clearly rejects dashboard login for both an IP address and a local hostname.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, docker, python
Domain
authentication, backend, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.