Skip to content

Conversation

@Otto-AGPT
Copy link
Contributor

Context

From PR #11796 review discussion. Files processed by the video blocks (downloads, uploads, generated videos) should be scanned through ClamAV for malware detection.

Problem

store_media_file() in backend/util/file.py already scans:

  • workspace:// references
  • Cloud storage paths
  • Data URIs (data:...)
  • HTTP/HTTPS URLs

But local file paths were NOT scanned. The else branch only verified the file exists.

This gap affected video processing blocks (e.g., LoopVideoBlock, AddAudioToVideoBlock) that:

  1. Download/receive input media
  2. Process it locally (loop, add audio, etc.)
  3. Write output to temp directory
  4. Call store_media_file(output_filename, ...) with a local path → skipped virus scanning

Solution

Added virus scanning to the local file path branch:

# Virus scan the local file before any further processing
local_content = target_path.read_bytes()
if len(local_content) > MAX_FILE_SIZE_BYTES:
    raise ValueError(...)
await scan_content_safe(local_content, filename=sanitized_file)

Changes

  • backend/util/file.py - Added ~7 lines to scan local files (consistent with other input types)
  • backend/util/file_test.py - Added 2 test cases for local file scanning

Risk Assessment

  • Low risk: Single point of change, follows existing pattern
  • Backwards compatible: No API changes
  • Fail-safe: If scanning fails, file is rejected (existing behavior)

Closes SECRT-1904

…a_file

Files processed via local paths in store_media_file() were not being
scanned through ClamAV, unlike URLs, data URIs, cloud paths, and
workspace references which already had scanning.

This gap affected video processing blocks (LoopVideoBlock,
AddAudioToVideoBlock, etc.) that write output to temp directories
then pass filenames to store_media_file().

Changes:
- Add virus scanning to the local file path branch in store_media_file()
- Add file size limit check consistent with other input types
- Add unit tests for local file scanning behavior

Closes SECRT-1904
@Otto-AGPT Otto-AGPT requested a review from a team as a code owner February 5, 2026 23:48
@Otto-AGPT Otto-AGPT requested review from Pwuts and ntindle and removed request for a team February 5, 2026 23:48
@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Feb 5, 2026
@github-actions github-actions bot added platform/backend AutoGPT Platform - Back end size/l labels Feb 5, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

Reads local file bytes in store_media_file, enforces MAX_FILE_SIZE_BYTES, and performs an asynchronous virus scan (scan_content_safe) with the sanitized filename before continuing; tests added to validate scanning and virus-detection propagation for local paths.

Changes

Cohort / File(s) Summary
Local File Security Scanning
autogpt_platform/backend/backend/util/file.py
Reads local file content, enforces MAX_FILE_SIZE_BYTES, and calls async scan_content_safe with file bytes and sanitized filename for local (non-cloud) paths before further processing.
Local File Test Coverage
autogpt_platform/backend/backend/util/file_test.py
Adds two async tests: test_store_media_file_local_path_scanned (mocks local path resolution and virus scan invocation) and test_store_media_file_local_path_virus_detected (ensures VirusDetectedError propagates).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Store as store_media_file
  participant FS as LocalFS
  participant Scanner as ClamAVScanner

  Client->>Store: submit local file path
  Store->>FS: resolve & open file (read bytes)
  FS-->>Store: file bytes
  Store->>Scanner: scan_content_safe(bytes, sanitized_filename)
  alt scan ok
    Scanner-->>Store: scan result OK
    Store->>Client: continue processing / return local filename
  else virus detected
    Scanner-->>Store: raises VirusDetectedError
    Store-->>Client: propagate error
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

size/s

Suggested reviewers

  • Pwuts

Poem

🐰 I nibble bytes with careful pace,

I scan each file in every place,
ClamAV keeps my burrow neat,
No sneaky viruses to meet,
Hooray — secure files for the race! 🎩

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding ClamAV scanning for local file paths in the backend.
Description check ✅ Passed The description provides relevant context about the security gap and the solution implemented for scanning local file paths in the store_media_file function.
Linked Issues check ✅ Passed The PR implements the core requirement from SECRT-1904 by adding ClamAV scanning to local file paths in the store_media_file function, following the same pattern used for other input types.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective of adding virus scanning for local file paths; no out-of-scope modifications are evident.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch otto/secrt-1904-clamav-local-files

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 35b0e0f and 8ba6390.

📒 Files selected for processing (1)
  • autogpt_platform/backend/backend/util/file.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • autogpt_platform/backend/backend/util/file.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: types
  • GitHub Check: Seer Code Review
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: Check PR Status

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@ntindle ntindle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Reviewed: Closes security gap where local file paths weren't virus-scanned.

  • Reads file bytes, checks size, calls existing scan_content_safe()
  • Good test coverage (scan called + virus detected scenarios)
  • Simple, focused fix

LGTM

@github-project-automation github-project-automation bot moved this from 🆕 Needs initial review to 👍🏼 Mergeable in AutoGPT development kanban Feb 8, 2026
@qodo-code-review
Copy link

ⓘ Your monthly quota for Qodo has expired. Upgrade your plan
ⓘ Paying users. Check that your Qodo account is linked with this Git user account

@ntindle ntindle enabled auto-merge February 9, 2026 00:23
@ntindle ntindle self-requested a review February 9, 2026 00:24
@ntindle ntindle added this pull request to the merge queue Feb 9, 2026
@ntindle ntindle requested a review from majdyz February 9, 2026 00:44
Merged via the queue into dev with commit a329831 Feb 9, 2026
25 checks passed
@ntindle ntindle deleted the otto/secrt-1904-clamav-local-files branch February 9, 2026 00:48
@github-project-automation github-project-automation bot moved this from 👍🏼 Mergeable to ✅ Done in AutoGPT development kanban Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform/backend AutoGPT Platform - Back end size/l

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants