Skip to content

Fix: Handle nil 'queried_user' in forgot-password POST request#466

Open
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/ai/32/1
Open

Fix: Handle nil 'queried_user' in forgot-password POST request#466
cycomachead wants to merge 1 commit into
mainfrom
cycomachead/ai/32/1

Conversation

@cycomachead
Copy link
Copy Markdown
Member

Fix: Guard against nil queried_user in global before_filter

Prevents a 500 crash when the global before_filter receives a request with a user_id that doesn't match any database record. Without this guard, any request carrying a non-existent user_id would crash before the route handler even ran.

Changes

  • Add a nil check before accessing self.queried_user.username in the global before_filter, bringing the user_id branch into parity with the username branch which already handles nil lookups safely

Context

This was surfaced by an automated security scanner sending POST /forgot-password/?user_id=1&hash_check=%25C0 — not a real user action. The legitimate forgot-password form posts to a different URL with a different parameter set and would never trigger this path. However, the bug is real: any request to any route on the site with a stale or non-existent user_id would have hit this crash, so the guard is warranted regardless of the source.


Superconductor Ticket Implementation | App Preview | Guided Review

Add a guard to check if queried_user exists before accessing its
username property. This prevents a 500 error when a request provides
 a non-existent user_id, which previously caused a nil-index exception
in the global before_filter.

Co-authored-by: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant