bunkerweb-plugins icon indicating copy to clipboard operation
bunkerweb-plugins copied to clipboard

fix: multipart parsing for HTTP/2 support in ClamAV plugin

Open rayshoo opened this issue 6 months ago • 0 comments

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.

rayshoo avatar Jun 23 '25 02:06 rayshoo