AOSSIE-Org / AOSSIE-Org/EduAid

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

Open
#589 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
171
Forks
425
PR merge metrics
No merged PRs in 30d

Description

### 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

- [x] I have joined the [Discord server](https://discord.gg/hjUhu33uAn) and will post updates there
- [x] I have searched existing issues to avoid duplicates

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.