Skip to content

CLDSRV-1101: Refuse a grant to an id that is not a canonical id - #6424

Open
nicolas2bert wants to merge 1 commit into
development/9.4from
bugfix/CLDSRV-1101-validate-canonical-id-object-acl
Open

nicolas2bert wants to merge 1 commit into
development/9.4from
bugfix/CLDSRV-1101-validate-canonical-id-object-acl

Conversation

@nicolas2bert

@nicolas2bert nicolas2bert commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Issue: CLDSRV-1101

problem

If you put a CanonicalUser grant in a PutObjectAcl XML with the ID set to http://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 the x-amz-grant-* headers.

reproduction

  1. As the owner, set that ACL on an object. You get 200.
  2. Do an anonymous GET on the object. You get 200.
  3. Send a CopyObject with x-amz-grant-read: id=http://acs.amazonaws.com/groups/global/AllUsers. You get 200.

expected

We want the same answers as AWS:

  • An ID that isn't a canonical id, in the XML body or in a header: 400 InvalidArgument.
  • A canonical id in upper case: 200.

AWS

We checked each case on AWS S3 on 2026-12-04, and that's what it returns.

@bert-e

bert-e commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Hello nicolas2bert,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval ⭐
/bypass_build_status Bypass the build and test status ⭐
/bypass_commit_size Bypass the check on the size of the changeset TBA ⭐
/bypass_incompatible_branch Bypass the check on the source branch prefix ⭐
/bypass_jira_check Bypass the Jira issue check ⭐
/bypass_peer_approval Bypass the pull request peers' approval ⭐
/bypass_leader_approval Bypass the pull request leaders' approval ⭐
/bypass_source_branch_lineage Bypass the cross-branch contamination check ⭐
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request.
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e

bert-e commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Incorrect fix version

The Fix Version/s in issue CLDSRV-1101 contains:

  • None

Considering where you are trying to merge, I ignored possible hotfix versions and I expected to find:

  • 9.4.24

  • 9.5.14

  • 9.6.4

  • 9.7.0

Please check the Fix Version/s of CLDSRV-1101, or the target
branch of this pull request.

Comment thread lib/metadata/acl.js
// 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))) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/unit/api/aclCanonicalId.js Outdated
after(() => cleanup());

Object.entries(invalidIds).forEach(([name, id]) => {
it(`PutObjectAcl returns InvalidArgument for ${name} and keeps the ACL`, done => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test names should start with should (repo convention). This applies to every it() in this file.

Suggested change
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

codecov Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.95%. Comparing base (28b50da) to head (6de62e2).
⚠️ Report is 13 commits behind head on development/9.4.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
lib/api/objectPutACL.js 97.76% <100.00%> (+0.10%) ⬆️
lib/metadata/acl.js 98.82% <100.00%> (+0.04%) ⬆️

... 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     
Flag Coverage Δ
checksums-disabled-tests 35.19% <10.00%> (-0.03%) ⬇️
file-ft-tests 69.72% <100.00%> (+0.05%) ⬆️
file-ft-tests-null-compat 70.21% <100.00%> (+0.06%) ⬆️
kmip-ft-tests 27.98% <10.00%> (-0.02%) ⬇️
mongo-v0-ft-tests 70.89% <100.00%> (+0.11%) ⬆️
mongo-v1-ft-tests 70.82% <100.00%> (+0.04%) ⬆️
multiple-backend 35.91% <10.00%> (-0.03%) ⬇️
s3c-ft-tests-v0 64.75% <40.00%> (-0.04%) ⬇️
s3c-ft-tests-v0-null-compat 64.80% <40.00%> (-0.04%) ⬇️
s3c-ft-tests-v0-replication-compat 64.61% <40.00%> (-0.02%) ⬇️
s3c-ft-tests-v1 64.73% <40.00%> (-0.02%) ⬇️
sur-tests 36.37% <10.00%> (-0.03%) ⬇️
sur-tests-inflights 39.20% <10.00%> (-0.03%) ⬇️
unit 75.34% <100.00%> (+0.08%) ⬆️
utapi-v2-tests 35.15% <10.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nicolas2bert
nicolas2bert force-pushed the bugfix/CLDSRV-1101-validate-canonical-id-object-acl branch from 41b3246 to 4cbe463 Compare December 5, 2026 13:24
Comment thread lib/metadata/acl.js Outdated
}
}
const usersIdentifiedByID = allGrantHeaders.filter(item => item && item.userIDType.toLowerCase() === 'id');
// CopyObject and CreateMultipartUpload don't check the grant headers

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer assert.match so a failure shows a diff (same at line 128).

Suggested change
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}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare the error message rather than using .is, so a failure shows the actual error name. Same at lines 109, 111 and 128.

Suggested change
assert(err && err.is.InvalidArgument, `expected InvalidArgument, got ${err}`);
assert.strictEqual(err?.message, 'InvalidArgument');

@nicolas2bert
nicolas2bert force-pushed the bugfix/CLDSRV-1101-validate-canonical-id-object-acl branch from 4cbe463 to 6de62e2 Compare December 5, 2026 13:29

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants