Skip to content

[BUG][SECURITY]: Uploaded temporary files are not cleaned up when file extraction fails #589

@Ashvin-KS

Description

@Ashvin-KS

Bug Description

The backend upload processing flow removes uploaded files only on the happy path.

If text extraction fails for a PDF or DOCX file, the temporary uploaded file may remain on disk. This creates an avoidable resource leak and weakens upload hygiene.

The issue is especially relevant for repeated failed uploads or malformed files.

Steps to Reproduce

  1. Start the EduAid backend locally.
  2. Upload a malformed or corrupted PDF or DOCX file to the /upload endpoint.
  3. Trigger an extraction failure.
  4. Inspect the upload directory after the request fails.
  5. Observe that the temporary file may still remain on disk.

Logs and Screenshots

No screenshot attached.

This issue is visible from the upload-processing flow and can be verified by forcing an extraction failure and checking whether the temporary file is removed.

Environment Details

  • OS: Windows 11
  • Python Version: 3.10.x
  • Flask Version: 2.x
  • Repository Branch: main
  • Area: Backend file upload processing

Impact

High - Major feature is broken

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions