File name stripped of unicode chars in file transfer from Moodle to Mahara
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
Mahara: 17.10.2
OS: Ubuntu 16.04
PHP: 7.0
DB: Postgres
Browser: n/a
During a XML-RPC 'File' transfer (not 'Leap2A' transfer) from Moodle to Mahara, a file name with unicode characters gets stripped out. Clamdscan then can't find the file when it tries to scan it and reports an error.
The error message coming from Clam is:
ERROR: Can't access file /var/lib/
The file name should be: upload(
Please note that the brackets are actually unicode: %uFF08 and %uFF09
This PHP core function strips any unicode characters: escapeshellarg(
This is in htdocs/
We were able to reproduce by:
1. Set up a Moodle / Mahara xml-rpc integration
2. In Mahara, set up clamAV (or clamdscan) virus checking
3. In Moodle, create a course and set up an assignment to upload a file
4. In Moodle, Enrol a test user in the course.
5. In Moodle, Log in as the test user and go to course.
6. In Moodle, Upload a file with unicode chars %uFF08 and %uFF09 in the name (I've attached a sample).
7. In Moodle, export the file to Mahara and select 'File'
8. In Moodle, the following error will appear to the user:
Exception: Failed to start communication with remote server: remote server error: code: , message: Your administrator has enabled virus checking for file uploads but has misconfigured something. Your file upload was NOT successful. Your administrator was notified so they can fix it. Maybe try uploading this file later.ERROR 4:
4: remote server error: code: , message: Your administrator has enabled virus checking for file uploads but has misconfigured something. Your file upload was NOT successful. Your administrator was notified so they can fix it. Maybe try uploading this file later.
in ./portfolio/
Stack trace:
line 212 of ./portfolio/
line 510 of ./lib/portfolio
line 227 of ./lib/portfolio
line 233 of ./lib/portfolio
line 233 of ./lib/portfolio
line 265 of ./portfolio/
9. In Mahara, an error is generated in the error log:
*14997 FastCGI sent in stderr: "PHP message: [DBG] 75 (lib/uploadmana
* PluginImportFil
* PluginImportFil
* send_content_
* api_dummy_
* xmlrpc_
* Dispatcher-
10. In Mahara, a system message (in inbox) is sent to the administrator:
You have been sent a notification from ePortfolios. Message follows:
-------
From: System
To: Admin
ClamAV has failed to run. The return error message was An error occurred. Here is the output from ClamAV:
ERROR: Can't access file /var/lib/
----------- SCAN SUMMARY -----------
Infected files: 0
Total errors: 1
Time: 0.214 sec (0 m 0 s)
The file has been moved to a quarantine directory.
-------
11. In Mahara, the file is moved to the quarantine directory:
-rw-r--r-- 1 www-data www-data 15 Mar 11 22:33 20180312093305-
The call to: escapeshellarg() is essential to ensure the system is not compromised with additional command line execution.
One option is to rename the file at the beginning of this function and rename it back again to its original name.
Please note that a direct upload of the file to Mahara does not cause this issue. Neither does a Leap2A export from Moodle.
Changed in mahara: | |
status: | New → Confirmed |