Title
Create new category
Edit page index title
Edit category
Edit link
Why am I getting a "File not found, invalid path or access" error when using the 'filepath' header in the RestAPI on Linux?
This article applies to MetaDefender Core All MetaDefender Core releases deployed on Linux.
When using the RestAPI to send a file under the header ‘filepath', the error 'File not found, invalid path or access’ is returned.
# curl -X POST http://MDCORE-HOST:8008/file -H "apikey: xxxxxxxxxxxxxx" -H "filepath:/home/admin/test.txt" -H "rule:xxxxx"{"err":"File not found, invalid path or access."}Even though the file exists and is accessible when traversed manually.
# ls -la /home/admin/test.txt-rwxrwxrwx. 1 root root 5 Nov 12 09:39 /home/admin/test.txt# namei -l /home/admin/test.txtf: /home/admin/test.txtdr-xr-xr-x root root /drwxr-xr-x root root homedrwxr-x--- admin admin admin-rwxrwxrwx root root test.txtMain Cause:
MetaDefender Core runs as the ‘metascan' user. When a request is made with the ‘filepath’ header, the 'metascan’ user requires explicit permission to access the file, beyond the permissions granted to normal or root users.
# sudo -u metascan namei -l /home/admin/test.txtf: /home/admin/test.txtdr-xr-xr-x root root /drwxr-xr-x root root homedrwxr-x--- admin admin admin test.txt - Permission deniedResolution:
The metascan user needs at least 'Execute' (x) permission at each folder/file level to access the file. Adjust the permissions on the directory level to grant 'execute' permission. For example:
# chmod +x /home/admin/# sudo -u metascan namei -l /home/admin/test.txtf: /home/admin/test.txtdr-xr-xr-x root root /drwxr-xr-x root root homedrwxr-x--x admin admin admin-rwxrwxrwx root root test.txtThen, verify again
# curl -X POST http://MDCORE-HOST:8008/file -H "apikey: xxxxxxxxxxxxxx" -H "filepath:/home/admin/test.txt" -H "rule:xxxxx"{"data_id":"95690812c3594522a18ce2b3c8a2ae7b"}If Further Assistance is required, please proceed to log a support case or chatting with our support engineer.
