Repository navigation
CLDSRV-1099: Refuse malformed grant headers instead of crashing - #6422
nicolas2bert wants to merge 1 commit into
Conversation
Hello nicolas2bert,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
Incorrect fix versionThe
Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:
Please check the |
| [{ userIDType: 'uri', identifier: constants.publicId, grantType: 'READ' }], | ||
| ], | ||
| ].forEach(([name, value, expected]) => { | ||
| it(`parseGrant skips a grant with ${name} instead of throwing`, () => { |
There was a problem hiding this comment.
Test names in this repo should start with should. That applies to every it() in this file.
| it(`parseGrant skips a grant with ${name} instead of throwing`, () => { | |
| it(`should skip a grant with ${name} in parseGrant instead of throwing`, () => { |
| it('parseAclFromHeaders refuses an invalid canonical id', done => { | ||
| const params = { headers: { 'x-amz-grant-read': 'id=123' }, resourceType: 'object', acl: {}, log }; | ||
| acl.parseAclFromHeaders(params, err => { | ||
| assert(err && err.is.InvalidArgument, `expected InvalidArgument, got ${err}`); |
There was a problem hiding this comment.
Compare the error message instead of using err.is.*, so a failure shows the actual error name. The same pattern appears throughout this file.
| assert(err && err.is.InvalidArgument, `expected InvalidArgument, got ${err}`); | |
| assert.strictEqual(err?.message, 'InvalidArgument'); |
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 4 files with indirect coverage changes @@ Coverage Diff @@
## development/9.4 #6422 +/- ##
===================================================
+ Coverage 86.84% 86.90% +0.05%
===================================================
Files 214 214
Lines 14756 14773 +17
===================================================
+ Hits 12815 12838 +23
+ Misses 1941 1935 -6
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
bf37cd8 to
ed5fb8f
Compare
| it('should store a canonical id given in upper case in lower case on CopyObject', async () => { | ||
| assertOk(await request(withGrant(apis[3].params, `id=${otherId.toUpperCase()}`))); | ||
| const { res } = await request({ method: 'GET', objectKey: 'copy', queryObj: { acl: '' } }); | ||
| assert(res.body.includes(`<ID>${otherId}</ID>`), res.body); |
There was a problem hiding this comment.
Prefer assert.match over includes so a failure shows the body and the expected pattern.
| assert(res.body.includes(`<ID>${otherId}</ID>`), res.body); | |
| assert.match(res.body, new RegExp(`<ID>${otherId}</ID>`)); |
ed5fb8f to
fb04f04
Compare
Issue: CLDSRV-1099
problem
If you send a grant header that isn't a list of
type=identifierpairs, likex-amz-grant-read: x, the server crashes. An empty grant header crashes it too. On PutBucketAcl you don't even need credentials or a bucket. On PutObject, CreateMultipartUpload and CopyObject you need write access on one bucket.reproduction
PUT /no-such-bucket?aclwithx-amz-grant-read: x. The worker exits withCallback was already called.x-amz-grant-read. The worker exits withCannot read properties of undefined (reading 'trim').x-amz-grant-read: x. Same crash.x-amz-grant-read: x. Same crash.x-amz-grant-read: uri=http://acs.amazonaws.com/groups/global/AllUsersreturns 200, and the server stays up.expected
We want the same answers as AWS, and the server stays up:
x-amz-grant-read: xon PutBucketAcl, PutObject, PutObjectAcl, CopyObject or CreateMultipartUpload: 400 InvalidArgument.x-amz-grant-read: 200. The empty header is just ignored.x-amz-grant-read: 400.AWS
We checked each case on AWS S3 on 2026-12-04, and that's what it returns. AWS also takes a quoted value, like
uri="http://acs.amazonaws.com/groups/global/AllUsers", and returns 200. CloudServer returns 400 on it today.