RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
39.84k stars 10.24k forks source link

Files with an ampersand '&' in their name are corrupted when downloading from Minio #29223

Open shiryov opened 1 year ago

shiryov commented 1 year ago

Description:

When using Minio as AmazonS3 storage, files containing an ampersand character in the name are downloaded with an error in their content. The downloaded file contains xml with the following error description: SignatureDoesNotMatch The request signature we calculated does not match the signature you provided. Check your key and signing method

<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method</Message>
<Key>*****</Key><BucketName>****</BucketName><Resource>****</Resource>
<RequestId>****</RequestId>
<HostId>****</HostId>
</Error>

Steps to reproduce:

  1. Connect MINIO to Rocket.chat as described in the article
  2. Upload any file containing an ampersand in the name to a private chat or room, for example "&.txt"
  3. Download the file and open it in a text viewer

Expected behavior:

Original file content

Actual behavior:

XML content with description of the error "SignatureDoesNotMatch..."

Server Setup Information:

Client Setup Information

Additional context

The solution with switching to SignatureV4 in a similar #27687 solves the issue of file download, but with this we have an error when uploading:

Relevant logs:

{"type":"Error","message":"Non-file stream objects are not supported with SigV4","stack":"Error: Non-file stream objects are not supported with SigV4
at Object.computeSha256 (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/util.js:753:23)
at Request.COMPUTE_SHA256 (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/event_listeners.js:171:18)
at Request.callListeners (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:102:18)
at Request.emit (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /app/bundle/programs/server/npm/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at Request.emit (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /app/bundle/programs/server/npm/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request. (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:38:9)
at Request. (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
at callNextListener (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/sequential_executor.js:96:12)
at /app/bundle/programs/server/npm/node_modules/aws-sdk/lib/event_listeners.js:86:9
at finish (/app/bundle/programs/server/npm/node_modules/aws-sdk/lib/config.js:396:7)","code":"Error","time":"2023-05-02T05:44:06.398Z"},"msg":"Non-file stream objects are not supported with SigV4"}

debdutdeb commented 1 year ago

Is this over http?

shiryov commented 1 year ago

Is this over http?

Yes in Administration->Settings->File Upload>-Amazon S3->Bucket Url uses "http" if that's what you mean

debdutdeb commented 1 year ago

yeah that's the one. if you switch the signature version to v2, uploads should start to work.

shiryov commented 1 year ago

yeah that's the one. if you switch the signature version to v2, uploads should start to work.

Yes, uploading with v2 starts working, but downloading files with "&" in the name stops working.

debdutdeb commented 1 year ago

Ah ok - so v4 let's you download files fine but breaks upload. v2 fixes uploads but breaks download?

shiryov commented 1 year ago

Ah ok - so v4 let's you download files fine but breaks upload. v2 fixes uploads but breaks download?

Yes, that's right