Opened 9 minutes ago

#37549 new Bug

Signer rejects separators "[", "\", "]", "^" and "`" as unsafe due to an A-z regex range

Reported by: Maddipatla Chatan Owned by:
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: Maddipatla Chatan Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

_SEP_UNSAFE in django/core/signing.py is r"[A-z0-9-_=]*$". The A-z range also covers the six ASCII characters between "Z" and "a": [ \ ] _ and . So Signer(sep="[") (and \ ] ^ ) raises "Unsafe Signer separator", even though none of these characters appear in base64url signatures.

>>> from django.core import signing
>>> signing.Signer(key="k", sep="[")
ValueError: Unsafe Signer separator: '[' (cannot be empty or consist of only A-z0-9-_=)

The check was added in #22804, whose patch defined the unsafe set as digits, A-Z, a-z, "-", "_" and "=", so the range was meant to be A-Za-z. ("_" stays unsafe since it is already listed explicitly.)

AI disclosure: I used Claude (Anthropic) to help verify this and draft the fix and tests. I reviewed and tested them myself.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top