Repository navigation
CLDSRV-1101: Refuse a grant to an id that is not a canonical id - #6424
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 |
| // before they get here, so we check the canonical ids here, like | ||
| // PutObject does. Before CLDSRV-1101, the header id=http://acs.amazonaws.com/groups/global/AllUsers | ||
| // was stored, and the permission checks read it as the AllUsers group. | ||
| if (usersIdentifiedByID.some(user => !aclUtils.isValidCanonicalId(user.identifier))) { |
There was a problem hiding this comment.
Upper-case canonical ids are handled differently by path. objectPutACL lowercases XML ids and accepts them (200, as the PR says AWS does). Here, header ids are not lowercased, so CopyObject/CreateMultipartUpload with x-amz-grant-read: id=<UPPERCASE canonical id> now return 400 where they returned 200 before. checkGrantHeaderValidity already rejects the same header on PutObject/PutObjectAcl. If AWS also accepts upper case in headers, lowercase identifier before this check, and in checkGrantHeaderValidity too. If it doesn't, say so in the PR so the difference is clearly on purpose.
| after(() => cleanup()); | ||
|
|
||
| Object.entries(invalidIds).forEach(([name, id]) => { | ||
| it(`PutObjectAcl returns InvalidArgument for ${name} and keeps the ACL`, done => { |
There was a problem hiding this comment.
Test names should start with should (repo convention). This applies to every it() in this file.
| it(`PutObjectAcl returns InvalidArgument for ${name} and keeps the ACL`, done => { | |
| it(`should return InvalidArgument on PutObjectAcl for ${name} and keep the ACL`, done => { |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 4 files with indirect coverage changes @@ Coverage Diff @@
## development/9.4 #6424 +/- ##
===================================================
+ Coverage 86.84% 86.95% +0.10%
===================================================
Files 214 214
Lines 14756 14765 +9
===================================================
+ Hits 12815 12839 +24
+ Misses 1941 1926 -15
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
41b3246 to
4cbe463
Compare
| } | ||
| } | ||
| const usersIdentifiedByID = allGrantHeaders.filter(item => item && item.userIDType.toLowerCase() === 'id'); | ||
| // CopyObject and CreateMultipartUpload don't check the grant headers |
There was a problem hiding this comment.
For CopyObject this check runs in services.metadataStoreObject, after data.copyObject/data.put has already written the destination data. On InvalidArgument, objectCopy returns the error and never deletes that data, so each rejected request leaves orphaned data in the backend. Validate the grant ids early in objectCopy (before any data write), as objectPut does with checkGrantHeaderValidity, while still lowercasing the ids.
| }); | ||
| assertOk(result); | ||
| const { res } = await request({ method: 'GET', objectKey, queryObj: { acl: '' } }); | ||
| assert(res.body.includes(`<ID>${otherId}</ID>`), res.body); |
There was a problem hiding this comment.
Prefer assert.match so a failure shows a diff (same at line 128).
| assert(res.body.includes(`<ID>${otherId}</ID>`), res.body); | |
| assert.match(res.body, new RegExp(`<ID>${otherId}</ID>`)); |
| // constants.publicId, so this grant made the object public. | ||
| it('PutObjectAcl returns InvalidArgument for the AllUsers group URI as ID and keeps the ACL', done => { | ||
| putObjectAcl(canonicalUserAcl(canonicalUserGrant(constants.publicId)), err => { | ||
| assert(err && err.is.InvalidArgument, `expected InvalidArgument, got ${err}`); |
There was a problem hiding this comment.
Compare the error message rather than using .is, so a failure shows the actual error name. Same at lines 109, 111 and 128.
| assert(err && err.is.InvalidArgument, `expected InvalidArgument, got ${err}`); | |
| assert.strictEqual(err?.message, 'InvalidArgument'); |
4cbe463 to
6de62e2
Compare
Issue: CLDSRV-1101
problem
If you put a
CanonicalUsergrant in a PutObjectAcl XML with theIDset tohttp://acs.amazonaws.com/groups/global/AllUsers, we accept it. And then it works like the AllUsers group: the object is public. CopyObject and CreateMultipartUpload accept the same id in thex-amz-grant-*headers.reproduction
x-amz-grant-read: id=http://acs.amazonaws.com/groups/global/AllUsers. You get 200.expected
We want the same answers as AWS:
AWS
We checked each case on AWS S3 on 2026-12-04, and that's what it returns.