Skip to content

Fix SQL Injection Risk in RLS Session Context Assignment #6

@007-SARANG

Description

@007-SARANG

I am Sarang, a GSoC contributor interested in improving security in this project.

In server/app/worker/tasks.py, the RLS session context is currently set using interpolated SQL:

SET app.current_user_id = '{user_id}'

Since user_id originates from request context, this introduces a potential SQL injection risk in a security-sensitive execution path.

Proposed Solution:

  • Replace string interpolation with a safe parameterized approach (e.g., using database parameter binding or set_config)
  • Enforce strict UUID validation before setting the session context

Acceptance Criteria:

  • Remove SQL string interpolation when setting app.current_user_id
  • Validate user_id as a proper UUID before database execution
  • Reject invalid or malicious inputs with clear error handling
  • Preserve existing RLS behavior and upload flow for valid users
  • Add unit tests for:
    • Valid UUID input
    • Invalid UUID input
    • Injection-like input (e.g., SQL payloads)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions