[Django] #33976: HTTP_HOST does not allow an ipv6 not enclosed in []

8 views
Skip to first unread message

Django

unread,
Sep 2, 2022, 5:18:02 AM9/2/22
to django-...@googlegroups.com
#33976: HTTP_HOST does not allow an ipv6 not enclosed in []
---------------------------------------+------------------------
Reporter: eburghar | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 3.2
Severity: Normal | Keywords: ipv6
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
Hi,

If I'm not mistaken, brackets are optional for an ipv6 address without
port number. The problem is that it confuses django. In `asgi.py` we have

```
Invalid HTTP_HOST header: '2001:x:y:z:0:0:0:1'. The domain name provided
is not valid according to RFC 1034/1035.
```

which can be fixed by changing `django.http.request.host_validation_re` to
`_lazy_re_compile(r"[a-zA-z0-9.:]*")`

but it also triggers an exception with `asgi.py`

```
2022/09/02 07:57:10 [alert] 422#422 [unit] Python failed to call
'loop.call_soon'
Traceback (most recent call last):
File "/usr/lib/python3.10/asyncio/base_events.py", line 750, in
call_soon
self._check_closed()
ValueError: invalid literal for int() with base 10: 'x:y:z:0:0:0:1'
2022/09/02 07:57:25 [alert] 422#422 [unit] #23: Python failed to create
'client' pair
```

--
Ticket URL: <https://code.djangoproject.com/ticket/33976>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 2, 2022, 5:19:59 AM9/2/22
to django-...@googlegroups.com
#33976: HTTP_HOST does not allow an ipv6 not enclosed in []
-----------------------------+--------------------------------------

Reporter: eburghar | Owner: nobody
Type: Bug | Status: new
Component: Core (URLs) | Version: 3.2
Severity: Normal | Resolution:

Keywords: ipv6 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Description changed by eburghar:

Old description:

> Hi,
>
> If I'm not mistaken, brackets are optional for an ipv6 address without
> port number. The problem is that it confuses django. In `asgi.py` we have
>
> ```
> Invalid HTTP_HOST header: '2001:x:y:z:0:0:0:1'. The domain name provided
> is not valid according to RFC 1034/1035.
> ```
>
> which can be fixed by changing `django.http.request.host_validation_re`
> to `_lazy_re_compile(r"[a-zA-z0-9.:]*")`
>
> but it also triggers an exception with `asgi.py`
>
> ```
> 2022/09/02 07:57:10 [alert] 422#422 [unit] Python failed to call
> 'loop.call_soon'
> Traceback (most recent call last):
> File "/usr/lib/python3.10/asyncio/base_events.py", line 750, in
> call_soon
> self._check_closed()
> ValueError: invalid literal for int() with base 10: 'x:y:z:0:0:0:1'
> 2022/09/02 07:57:25 [alert] 422#422 [unit] #23: Python failed to create
> 'client' pair
> ```

New description:

Hi,

If I'm not mistaken, brackets are optional for an ipv6 address without
port number. The problem is that it confuses django. In `asgi.py` we have

{{{
Invalid HTTP_HOST header: '2001:x:y:z:0:0:0:1'. The domain name provided
is not valid according to RFC 1034/1035.
}}}

which can be fixed by changing `django.http.request.host_validation_re` to
`_lazy_re_compile(r"[a-zA-z0-9.:]*")`

but it also triggers an exception with `asgi.py`

{{{
2022/09/02 07:57:10 [alert] 422#422 [unit] Python failed to call
'loop.call_soon'
Traceback (most recent call last):
File "/usr/lib/python3.10/asyncio/base_events.py", line 750, in
call_soon
self._check_closed()
ValueError: invalid literal for int() with base 10: 'x:y:z:0:0:0:1'
2022/09/02 07:57:25 [alert] 422#422 [unit] #23: Python failed to create
'client' pair
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33976#comment:1>

Django

unread,
Sep 2, 2022, 5:20:55 AM9/2/22
to django-...@googlegroups.com

Old description:

New description:

Hi,

{{{


Invalid HTTP_HOST header: '2001:x:y:z:0:0:0:1'. The domain name provided
is not valid according to RFC 1034/1035.
}}}

which can be fixed by changing `django.http.request.host_validation_re` to
`_lazy_re_compile(r"[a-zA-z0-9.:]*")`

but it also triggers an exception with `asgi.py`

{{{
2022/09/02 07:57:10 [alert] 422#422 [unit] Python failed to call
'loop.call_soon'
Traceback (most recent call last):
File "/usr/lib/python3.10/asyncio/base_events.py", line 750, in
call_soon
self._check_closed()
ValueError: invalid literal for int() with base 10: 'x:y:z:0:0:0:1'
2022/09/02 07:57:25 [alert] 422#422 [unit] #23: Python failed to create
'client' pair
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/33976#comment:2>

Django

unread,
Sep 2, 2022, 6:05:03 AM9/2/22
to django-...@googlegroups.com
#33976: HTTP_HOST does not allow an ipv6 not enclosed in []
-----------------------------+--------------------------------------
Reporter: eburghar | Owner: nobody
Type: Bug | Status: closed

Component: Core (URLs) | Version: 3.2
Severity: Normal | Resolution: invalid

Keywords: ipv6 | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

As far as I'm aware, brackets are mandatory in the URI scheme for IPv6,
see [https://www.rfc-editor.org/rfc/rfc3986#section-3.2.2 RFC3986]:

{{{
IP-literal = "[" ( IPv6address / IPvFuture ) "]"
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33976#comment:3>

Reply all
Reply to author
Forward
0 new messages