BUG: [Security] Critical: Login CSRF vulnerability in OAuth flow (Missing 'state' parameter)

Abierto
#268 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@Shevilll ya está trabajando en esto.

Desde el 20/6/2026.

  • #269 de @KumarADITHYA123 — cerrado sin fusionar
  • #301 de @Shevilll — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
github, python, redis, supabase

Línea de trabajo

Lee backend/integrations/discord/cogs.py alrededor del comando /verify_github y luego sigue login_with_github en backend/app/services/auth/supabase.py y el callback en backend/app/api/v1/auth.py. Confirma cómo se genera, almacena, envía a GitHub y comprueba el OAuth state antes de la vinculación; se considera terminado cuando el callback rechaza un state ausente o que no coincide.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

📌 Issue Overview
The current GitHub OAuth implementation in
backend/integrations/discord/cogs.py
and
backend/app/api/v1/auth.py
is vulnerable to Login CSRF / Session Fixation attacks. The flow relies solely on a session_id embedded in the redirect_uri to bind the Discord verification request to the GitHub callback, without validating the standard OAuth state parameter (RFC 6749).

This allows an attacker to force a victim's Discord account to be linked to the attacker's GitHub account by tricking them into clicking a valid callback link.

🔍 Steps to Reproduce
Initiate Verification: Run /verify_github in Discord to generate a verification link.
Inspect URL: Analyze the generated OAuth URL.
Code Verification: Inspect
backend/integrations/discord/cogs.py
at line 150.
auth_url_data = await login_with_github(redirect_to=callback_url)
The Error: the
login_with_github
function supports a state parameter, but it is not passed.
🎯 Expected Behavior
The OAuth initialization should generate a cryptographically secure random state token, store it (e.g., in Redis) with a short expiration, and pass it to GitHub. The callback endpoint should verify that the returned state matches the stored token before processing the linkage.

🚨 Actual Behavior
The state parameter is defined as Optional in
backend/app/services/auth/supabase.py
and is never passed by the
verify_github
command. The backend accepts any valid code + session_id pair without verifying the origin of the request.

🔗 Verification Evidence
I verified this using a script that imports the actual project code.

Source Code Check (
cogs.py
): Line 150 calls
login_with_github
with ONLY redirect_to. The state argument is absent.

Execution Check (
supabase.py
): When running the actual backend logic, the generated URL sent to the provider is:

Provider: github
Options: {'redirect_to': '.../callback'}
State Parameter: MISSING

This confirms the vulnerability exists in the live codebase.

💡 Suggested Improvements
Generate State: In
cogs.py
, generate state = secrets.token_urlsafe(32).
Store It: Save redis.setex(f"oauth_state:{state}", 300, session_id).
Pass It: Update correct call: await login_with_github(..., state=state).
Validate It: Update auth_callback in auth.py to Depends(verify_state_token).

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Lenguaje dominante
Python
Estrellas
103
Forks
143
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AOSSIE-Org/Devr.AI

Todos los issues de AOSSIE-Org/Devr.AI

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.