Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve permission checks in File connector [HZ-2991] #25348

Merged

Conversation

frant-hartm
Copy link
Collaborator

@frant-hartm frant-hartm commented Aug 31, 2023

SqlConnector#resolveAndValidateFields may try to resolve field names from metadata and a sample. This is not covered by any permission check.

Added SqlConnector#permissionsForResolve that returns permissions required to run the resolveAndValidateFields. Propagation of SqlSecurityContext was required for the actuall permission check.

Added permission to ProcessorSupplier returned by ReadFilesP.MetaSupplier (previously this allowed constructing unsecured DAG):

public Function<? super Address, ? extends ProcessorSupplier> get(@Nonnull List<Address> addresses) {
return address -> ProcessorSupplier.of(new SupplierEx<>() {
@Override
public Processor getEx() {
return new ReadFilesP<>(directory, glob, sharedFileSystem, ignoreFileNotFound, readFileFn);
}
@Override
public List<Permission> permissions() {
return singletonList(ConnectorPermission.file(directory, ACTION_READ));
}
});
}

EE PR https://github.com/hazelcast/hazelcast-enterprise/pull/6421 (adds security tests)

Checklist:

  • Labels (Team:, Type:, Source:, Module:) and Milestone set
  • Label Add to Release Notes or Not Release Notes content set
  • Request reviewers if possible
  • Send backports/forwardports if fix needs to be applied to past/future releases

Backports will be sent to valid branches (need to figure out - all 5.x branches?).

`SqlConnector#resolveAndValidateFields` may try to resolve field names
from metadata and a sample. This is not covered by any permission check.

Added `SqlConnector#permissionsForResolve` that returns permissions
required to run the `resolveAndValidateFields`. Propagation of
SqlSecurityContext was required for the actuall permission check.

EE PR #... (adds security tests)
@frant-hartm frant-hartm added this to the 5.4.0 milestone Aug 31, 2023
@k-jamroz
Copy link
Collaborator

you need to merge current master but that will unfortunately make backporting the change harder due to changes for GET_DDL security.

@frant-hartm frant-hartm changed the title Check permission before resolving mapping fields [HZ-2991] Improve permission checks in File connector [HZ-2991] Oct 2, 2023
Copy link
Collaborator

@k-jamroz k-jamroz left a comment

Choose a reason for hiding this comment

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

LGTM, however it might be better to move ReadFileP supplier to SecuredFunctions

frant-hartm added a commit to frant-hartm/hazelcast that referenced this pull request Oct 2, 2023
`SqlConnector#resolveAndValidateFields` may try to resolve field names
from metadata and a sample. This is not covered by any permission check.

Added `SqlConnector#permissionsForResolve` that returns permissions
required to run the `resolveAndValidateFields`. Propagation of
SqlSecurityContext was required for the actuall permission check.

EE PR #... (adds security tests)

Backport of hazelcast#25348
@@ -174,8 +175,9 @@ private MetaSupplier(
@Nonnull
@Override
public Function<? super Address, ? extends ProcessorSupplier> get(@Nonnull List<Address> addresses) {
return address -> ProcessorSupplier.of(() -> new ReadFilesP<>(directory, glob, sharedFileSystem,
ignoreFileNotFound, readFileFn));
return address -> ProcessorSupplier.of(SecuredFunctions.readFilesProcessorFn(
Copy link
Collaborator

Choose a reason for hiding this comment

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

when backported this might be a breaking change for an upgrade - old lambda will be not present in the code

@kwart kwart merged commit 98be233 into hazelcast:master Oct 4, 2023
8 checks passed
kwart pushed a commit to kwart/hazelcast that referenced this pull request Oct 4, 2023
`SqlConnector#resolveAndValidateFields` may try to resolve field names
from metadata and a sample. This is not covered by any permission check.

Added `SqlConnector#permissionsForResolve` that returns permissions
required to run the `resolveAndValidateFields`. Propagation of
SqlSecurityContext was required for the actuall permission check.

Added permission to ProcessorSupplier returned by
ReadFilesP.MetaSupplier (previously this allowed constructing unsecured
DAG):


https://github.com/hazelcast/hazelcast/blob/ee7e96933748283a01428e306e1b886b06b8a5ba/hazelcast/src/main/java/com/hazelcast/jet/impl/connector/ReadFilesP.java#L179-L191

EE PR hazelcast/hazelcast-enterprise#6421 (adds
security tests)
frant-hartm added a commit to frant-hartm/hazelcast that referenced this pull request Oct 10, 2023
`SqlConnector#resolveAndValidateFields` may try to resolve field names
from metadata and a sample. This is not covered by any permission check.

Added `SqlConnector#permissionsForResolve` that returns permissions
required to run the `resolveAndValidateFields`. Propagation of
SqlSecurityContext was required for the actuall permission check.

Added permission to ProcessorSupplier returned by
ReadFilesP.MetaSupplier (previously this allowed constructing unsecured
DAG):


https://github.com/hazelcast/hazelcast/blob/ee7e96933748283a01428e306e1b886b06b8a5ba/hazelcast/src/main/java/com/hazelcast/jet/impl/connector/ReadFilesP.java#L179-L191

EE PR hazelcast/hazelcast-enterprise#6421 (adds
security tests)
frant-hartm added a commit that referenced this pull request Oct 10, 2023
Backport of #25348 to 5.3.z

EE PR hazelcast/hazelcast-enterprise#6621

---------

Co-authored-by: František Hartman <frant.hartm@gmail.com>
frant-hartm added a commit to frant-hartm/hazelcast that referenced this pull request Oct 11, 2023
devOpsHazelcast pushed a commit that referenced this pull request Feb 26, 2024
Backport port of: #25674 and
https://github.com/hazelcast/hazelcast-enterprise/pull/6631

Original PRs in master:
#25348 and
https://github.com/hazelcast/hazelcast-enterprise/pull/6421

---------

Co-authored-by: František Hartman <frant.hartm@gmail.com>
GitOrigin-RevId: 836979eec9b74102f67e9f2a44f49c1544dad014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants