Skip to content

Conversation

@rayshoo
Copy link

@rayshoo rayshoo commented Jun 23, 2025

Description

This PR improves the ClamAV plugin's multipart form-data parsing to properly support HTTP/2 requests. The original implementation had issues parsing multipart data in HTTP/2 environments, causing file uploads to bypass ClamAV scanning.

Changes Made

  • Enhanced boundary extraction: Improved parsing of Content-Type header to handle quoted and unquoted boundary values
  • Fixed multipart parsing logic: Completely rewrote the multipart parsing function to properly handle HTTP/2 multipart data structure
  • Better section splitting: Used exact string matching instead of regex patterns for more reliable boundary detection
  • Improved header/data separation: Enhanced logic to separate headers from file data in each multipart section
  • Robust filename extraction: Better parsing of Content-Disposition headers to extract filenames accurately

Technical Details

I modified the code to support HTTP/2 because the original multipart parsing wasn't working properly. Since I'm not very familiar with Lua code, I got help from ChatGPT and Claude AI to implement these improvements. The updated code has been thoroughly tested and works excellently.

Testing

  • ✅ Tested with HTTP/2 multipart file uploads
  • ✅ Successfully detects and scans files with ClamAV
  • ✅ Properly blocks malware (tested with EICAR test file)
  • ✅ Allows clean files to pass through
  • ✅ Maintains backward compatibility with HTTP/1.1

Impact

This fix ensures that file uploads via HTTP/2 are properly scanned by ClamAV, closing a potential security gap where malicious files could bypass antivirus scanning in HTTP/2 environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant