OWASP / OWASP/Nest

Minor vulnerability: create_api_key mutation fails for naive datetime input

Open
#3,175 1 comment 0 reactions 0 assignees View on GitHub
bug enhancement
Dominant language
Python
Stars
451
Forks
702
Avg merge
22h 59m
Merged PRs (30d)
91

Description

**Describe the bug**
The create_api_key mutation directly compares expires_at with timezone.now() without checking if expires_at is timezone aware. Sending a naive datetime from the GraphQL client may result in incorrect validation or a Django runtime warning/error.

**To Reproduce**
Steps to reproduce the behavior:

1. Call the createApiKey GraphQL mutation
Invoke createApiKey with expires_at in format "2026-01-05T12:00:00" (no timezone).

2. Pass a naive expires_at datetime
Django gets a naive datetime (without timezone info).

3. Mutation reaches expiry validation logic
Mutation compares it to timezone.now()

4. Datetime comparison behaves incorrectly or raises a warning/error
Python raises an error or inappropriate behaviour when comparing naive and aware.

5. Here i will add a more condition to check time zones

**Screenshot**
Image

**Expected behavior**
The mutation should safely handle naive datetimes by converting them to timezone-aware values before comparison, ensuring consistent and correct expiry validation.

Are you going to work on fixing this?
Yes

Desktop (please complete the following information):
OS: Linux / macOS / Windows
Browser: Chrome / Firefox
Version: Latest

Hi @arkid15r @kasya ,
I’d like to formally take ownership of this issue and work on the fix. Could you please assign it to me.
I have learned from my previous mistakes. I read all the contribution guidelines and will now further contribute to OWASP
Nest more better.

Thanks!
From @nios-x

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.