Skip to content

Conversation

@kerneltime
Copy link
Contributor

Buckets created via S3 should not allow read access for usersin same group

What changes were proposed in this pull request?

Buckets created via S3 should not allow read access for users

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-6942

How was this patch tested?

Bucket created via S3 vs ozone sh

bash-4.2$ aws s3api --endpoint-url http://localhost:9878 create-bucket --bucket bucket2
bash-4.2$ ozone sh bucket getacl s3v/bucket2
[ {
  "type" : "USER",
  "name" : "key",
  "aclScope" : "ACCESS",
  "aclList" : [ "ALL" ]
} ]
bash-4.2$ ozone sh bucket create s3v/bucket
bash-4.2$ ozone sh bucket getacl s3v/bucket 
[ {
  "type" : "USER",
  "name" : "hadoop",
  "aclScope" : "ACCESS",
  "aclList" : [ "ALL" ]
}, {
  "type" : "GROUP",
  "name" : "hadoop",
  "aclScope" : "ACCESS",
  "aclList" : [ "ALL" ]
} ]
bash-4.2$ 

@kerneltime kerneltime changed the title HDDS-6942. Buckets created via S3 should not allow read access for users HDDS-6942. Ozone Vols/Buckets/Objects created via S3 should not allow group access Jun 27, 2022
Ozone vol/bucket/objects created via S3 should not allow read access for users
in same group
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

It may be better to set this config from OzoneClientCache before any client is instantiated.

private OzoneClientCache(OzoneConfiguration ozoneConfiguration)
throws IOException {
// Set the expected OM version if not set via config.
ozoneConfiguration.setIfUnset(OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_KEY,
OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_DEFAULT);
String omServiceID = OmUtils.getOzoneManagerServiceId(ozoneConfiguration);
secConfig = new SecurityConfig(ozoneConfiguration);
client = null;
try {
if (secConfig.isGrpcTlsEnabled()) {
if (ozoneConfiguration
.get(OZONE_OM_TRANSPORT_CLASS,
OZONE_OM_TRANSPORT_CLASS_DEFAULT) !=
OZONE_OM_TRANSPORT_CLASS_DEFAULT) {
// Grpc transport selected
// need to get certificate for TLS through
// hadoop rpc first via ServiceInfo
setCertificate(omServiceID,
ozoneConfiguration);
}
}
if (omServiceID == null) {
client = OzoneClientFactory.getRpcClient(ozoneConfiguration);
} else {
// As in HA case, we need to pass om service ID.
client = OzoneClientFactory.getRpcClient(omServiceID,
ozoneConfiguration);
}
} catch (IOException e) {
LOG.warn("cannot create OzoneClient", e);
throw e;
}
// S3 Gateway should always set the S3 Auth.
ozoneConfiguration.setBoolean(S3Auth.S3_AUTH_CHECK, true);
}

@kerneltime
Copy link
Contributor Author

kerneltime commented Jun 27, 2022

It may be better to set this config from OzoneClientCache before any client is instantiated.

private OzoneClientCache(OzoneConfiguration ozoneConfiguration)
throws IOException {
// Set the expected OM version if not set via config.
ozoneConfiguration.setIfUnset(OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_KEY,
OZONE_CLIENT_REQUIRED_OM_VERSION_MIN_DEFAULT);
String omServiceID = OmUtils.getOzoneManagerServiceId(ozoneConfiguration);
secConfig = new SecurityConfig(ozoneConfiguration);
client = null;
try {
if (secConfig.isGrpcTlsEnabled()) {
if (ozoneConfiguration
.get(OZONE_OM_TRANSPORT_CLASS,
OZONE_OM_TRANSPORT_CLASS_DEFAULT) !=
OZONE_OM_TRANSPORT_CLASS_DEFAULT) {
// Grpc transport selected
// need to get certificate for TLS through
// hadoop rpc first via ServiceInfo
setCertificate(omServiceID,
ozoneConfiguration);
}
}
if (omServiceID == null) {
client = OzoneClientFactory.getRpcClient(ozoneConfiguration);
} else {
// As in HA case, we need to pass om service ID.
client = OzoneClientFactory.getRpcClient(omServiceID,
ozoneConfiguration);
}
} catch (IOException e) {
LOG.warn("cannot create OzoneClient", e);
throw e;
}
// S3 Gateway should always set the S3 Auth.
ozoneConfiguration.setBoolean(S3Auth.S3_AUTH_CHECK, true);
}

I think decision for what the ACL config should be for entities created should reside closer to the request processing. The Client and it's cache should avoid deciding defaults for the requests.

It is much easier to evaluate all the outcomes of an API call if the choices in defaults are where the processing of the API is done. I would prefer to leave it here.

It makes sense to evaluate connection level setting in the Client Cache (TLS etc) but should a bucket have read access to all in the same group is really a S3 API level decision and BaseEndpoint is a good place to store that logic.

@kerneltime
Copy link
Contributor Author

The CI failures seem unrelated.

@adoroszlai
Copy link
Contributor

The Client and it's cache should avoid deciding defaults for the requests.

I was concerned that the setting may not be effective, as the client may already be created when endpoint's initialization() is called (since client needs to be injected). Now that @neils-dev pointed to OzoneConfigurationHolder, I see that the original approach works because the same instance of OzoneConfiguration is shared in S3 Gateway for all injections.

Can you please add an assertion for the expected ACL in S3 smoketests? hadoop-ozone/dist/src/main/smoketest/s3/bucketcreate.robot or hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-s3.robot might be a good candidate for that.

@adoroszlai adoroszlai added the s3 S3 Gateway label Jun 28, 2022
@adoroszlai adoroszlai changed the title HDDS-6942. Ozone Vols/Buckets/Objects created via S3 should not allow group access HDDS-6942. Ozone Buckets/Objects created via S3 should not allow group access Jun 28, 2022
@adoroszlai
Copy link
Contributor

Thanks @kerneltime for adding the test. Seems like in secure case (in ozonesecure-ha) group ACL is still set:

Create new bucket and check no group ACL                              | FAIL |
'[ {
  "type" : "USER",
  "name" : "testuser/[email protected]",
  "aclScope" : "ACCESS",
  "aclList" : [ "ALL" ]
}, {
  "type" : "GROUP",
  "name" : "testuser",
  "aclScope" : "ACCESS",
  "aclList" : [ "ALL" ]
} ]' contains '"type" : "GROUP"'

https://github.com/apache/ozone/runs/7104193656#step:5:599

@kerneltime
Copy link
Contributor Author

I think I know why some tests pass and this one fails.
The config for default rights is invoked on the client-side RpcClient.java

  public RpcClient(ConfigurationSource conf, String omServiceId)
      throws IOException {
    Preconditions.checkNotNull(conf);
    this.conf = conf;
    this.ugi = UserGroupInformation.getCurrentUser();
    // Get default acl rights for user and group.
    OzoneAclConfig aclConfig = this.conf.getObject(OzoneAclConfig.class);
    this.userRights = aclConfig.getUserDefaultRights();
    this.groupRights = aclConfig.getGroupDefaultRights();
...
...
...
  private List<OzoneAcl> getAclList() {
    if (ozoneManagerClient.getThreadLocalS3Auth() != null) {
      UserGroupInformation aclUgi =
          UserGroupInformation.createRemoteUser(
             ozoneManagerClient.getThreadLocalS3Auth().getAccessID());
      OzoneAclConfig aclConfig = this.conf.getObject(OzoneAclConfig.class);
      return OzoneAclUtil.getAclList(
          aclUgi.getUserName(),
          aclUgi.getGroupNames(),
         userRights, groupRights);
    }
    return OzoneAclUtil.getAclList(ugi.getUserName(), ugi.getGroupNames(),
        userRights, groupRights);

but the config is only applicable for OM OzoneAclConfig.java

  @Config(key = "group.rights",
      defaultValue = "ALL",
      type = ConfigType.STRING,
      tags = {ConfigTag.OM, ConfigTag.SECURITY},
      description = "Default group permissions set for an object in " +
          "OzoneManager."
  )
  private String groupDefaultRights;

which seems an odd mismatch. If the user used does not have any groups when queried by OM it skips adding the group permissions. The robot tests for non-secure clusters default to a random user who has no groups and the test passes.

@kerneltime kerneltime force-pushed the HDDS-6942 branch 2 times, most recently from 4c49338 to 6671177 Compare June 30, 2022 23:45
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

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

Thanks @kerneltime for iterating on this patch.

@adoroszlai adoroszlai merged commit c5e3745 into apache:master Jul 2, 2022
errose28 added a commit to errose28/ozone that referenced this pull request Jul 12, 2022
* master: (46 commits)
  HDDS-6901. Configure HDDS volume reserved as percentage of the volume space. (apache#3532)
  HDDS-6978. EC: Cleanup RECOVERING container on DN restarts (apache#3585)
  HDDS-6982. EC: Attempt to cleanup the RECOVERING container when reconstruction failed at coordinator. (apache#3583)
  HDDS-6968. Addendum: [Multi-Tenant] Fix USER_MISMATCH error even on correct user. (apache#3578)
  HDDS-6794. EC: Analyze and add putBlock even on non writing node in the case of partial single stripe. (apache#3514)
  HDDS-6900. Propagate TimeoutException for all SCM HA Ratis calls. (apache#3564)
  HDDS-6938. handle NPE when removing prefixAcl (apache#3568)
  HDDS-6960. EC: Implement the Over-replication Handler (apache#3572)
  HDDS-6979. Remove unused plexus dependency declaration (apache#3579)
  HDDS-6957. EC: ReplicationManager - priortise under replicated containers (apache#3574)
  HDDS-6723. Close Rocks objects properly in OzoneManager (apache#3400)
  HDDS-6942. Ozone Buckets/Objects created via S3 should not allow group access (apache#3553)
  HDDS-6965. Increase timeout for basic check (apache#3563)
  HDDS-6969. Add link to compose directory in smoketest README (apache#3567)
  HDDS-6970. EC: Ensure DatanodeAdminMonitor can handle EC containers during decommission (apache#3573)
  HDDS-6977. EC: Remove references to ContainerReplicaPendingOps in TestECContainerReplicaCount (apache#3575)
  HDDS-6217. Cleanup XceiverClientGrpc TODOs, and document how the client works and should be used. (apache#3012)
  HDDS-6773. Cleanup TestRDBTableStore (apache#3434) - fix checkstyle
  HDDS-6773. Cleanup TestRDBTableStore (apache#3434)
  HDDS-6676. KeyValueContainerData#getProtoBufMessage() should set block count (apache#3371)
  ...

Conflicts:
    hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/SCMUpgradeFinalizer.java
@kerneltime kerneltime deleted the HDDS-6942 branch July 18, 2022 04:25
k5342 added a commit to pfnet/ozone that referenced this pull request Oct 24, 2022
k5342 added a commit to pfnet/ozone that referenced this pull request Oct 25, 2022
k5342 added a commit to pfnet/ozone that referenced this pull request Dec 6, 2022
k5342 added a commit to pfnet/ozone that referenced this pull request Jan 13, 2023
kuenishi pushed a commit to pfnet/ozone that referenced this pull request Aug 14, 2023
k5342 added a commit to pfnet/ozone that referenced this pull request Mar 27, 2024
k5342 added a commit to pfnet/ozone that referenced this pull request Dec 10, 2024
k5342 added a commit to pfnet/ozone that referenced this pull request Dec 10, 2024
k5342 added a commit to pfnet/ozone that referenced this pull request Dec 11, 2024
k5342 added a commit to pfnet/ozone that referenced this pull request Feb 18, 2025
k5342 added a commit to pfnet/ozone that referenced this pull request Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

s3 S3 Gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants