[AUTHZ] Upgrade Apache Ranger to 2.9.0 and migrate Spark authz plugin to Ranger PDP mode - #7437
[AUTHZ] Upgrade Apache Ranger to 2.9.0 and migrate Spark authz plugin to Ranger PDP mode#7437aajisaka wants to merge 2 commits into
Conversation
|
@aajisaka Thank you for this work. Did you verify kyuubi/extensions/spark/kyuubi-spark-authz-shaded/pom.xml Lines 46 to 112 in be35121 |
Sorry I forgot to verify. I removed Jackson 1 config because Ranger 2.8.0+ doesn't have its dependency. Also, updated the LICENSE file of the shaded jar. |
|
If we have to make a breaking change here eventually, I wonder if we should do more things to move to Ranger 2.9 and PDP mode. The current architecture- pulling all policies from the Ranger Admin Server on Spark application start, and evaluating authz requests on the client side (Spark driver), does not fit short-lived Spark ETL cases, and another disadvantage is that we have to bundle a heavy Ranger client that pulls in many dependencies. (easy to conflict, varies across versions, vulnerable) In PDP mode, the Ranger client becomes lightweight and is almost an HTTP client, also no need to download the whole policies to the client. There are many organizations have similar enhancements to make the Ranger Spark Plugin fit large-scale lakehouses; now this is supported by the upstream Ranger community, we should migrate to it ASAP. UT infrastructure might require a significant adjustment to allow us to adopt the Ranger PDP ... |
|
Thank you @pan3793 While it's a significant change, it really makes sense to me. I'll try to move to Ranger 2.9 and support PDP mode. |
…gin to Ranger PDP mode Upgrade Apache Ranger from 2.6.0 to 2.9.0 to fix GHSA-c87w-642h-m97h, and migrate the plugin to the new Ranger authorization API with Ranger PDP mode as the default (suggested in review): - SparkRangerAdminPlugin delegates to org.apache.ranger.authz.api RangerAuthorizer; the default implementation is RangerRemoteAuthorizer (the thin authz-remote client sending REST requests to the Ranger PDP server), and the embedded policy-download mode is kept as an option via ranger.authorizer.impl.class - AccessRequest/AccessResource are rewritten for the new resource model (RRN-style resources, e.g. table:default/src, column:default/src/id) - the shaded plugin bundles only ranger-authz-api, authz-remote, jackson, httpclient and commons-lang3; audits are recorded by the PDP server in PDP mode, and by the embedded authorizer in embedded mode - the UT runs on the embedded authorizer with the local policy fixture, plus RangerRemoteAuthorizerSuite exercising the thin client against a mock PDP server (CI default), which can also run against a real Ranger PDP server via -Dranger.authz.remote.pdp.url The security review findings are also addressed: - resource names containing RRN metacharacters (backslash and slash) are escaped when building the RRN request, and blank resource names are denied instead of being evaluated against the wildcard marker - a uri is authorized as alternative resource variants (the exact path and the path with a trailing slash), because the RRN request evaluates the sub-resources as conjunctive requirements instead of alternatives - accesses are denied when the Ranger authorizer returns no result, instead of skipping the checks or leaving the row filter and the data mask unapplied - the security-critical configurations (the authorizer implementation, the Ranger PDP server address, the Ranger service name, and the Ranger PDP client authentication and encryption settings) are read from ranger-spark-security.xml only, cannot be set or overridden by JVM system properties, and the plugin fails to initialize when the Ranger PDP server address is missing for the Ranger PDP mode
65128c9 to
e20a3b2
Compare
|
Updated to support Ranger 2.9.0 and also updated the PR description. |
- keep the changed lines within 100 characters - extend RangerRemoteAuthorizerSuite with KyuubiFunSuite instead of AnyFunSuite, and shut down the mock PDP server's executor pool on close so the suite's thread audit sees no leaked threads
Why are the changes needed?
Upgrade Apache Ranger from 2.6.0 to 2.9.0 in the Spark AuthZ plugin to fix
GHSA-c87w-642h-m97h, and migrate the plugin to the new Ranger authorization API
introduced in Ranger 2.9.0 (
ranger-authz-api/authz-remote/authz-embedded):SparkRangerAdminPlugindelegates toorg.apache.ranger.authz.api.RangerAuthorizer.The default is the Ranger PDP mode (
RangerRemoteAuthorizer, a thin client sendingREST requests to the Ranger PDP server); the embedded mode (pull policies from the
Ranger admin and evaluate locally, as the previous plugin did) is kept as an option
via
ranger.authorizer.impl.class. The plugin now requires Apache Ranger 2.9.0 orabove; the migration guide and the docs are updated.
resource names instead of matching wildcard policies with them;
path): the RRN request evaluates sub-resources as conjunctive requirements, which
denied access to users granted exact-path url policies;
the checks or leaving the row filter / data mask unapplied;
Ranger PDP server address, the Ranger service name, and the Ranger PDP client
authentication and encryption settings) from
ranger-spark-security.xmlonly:JVM system properties can neither set nor override them.
How was this patch tested?
AccessResourceSuite: RRN metacharacter escaping (round-trip through the realRangerResourceNameParser), blank resource name denial, uri resource variants.SparkRangerAdminPluginSuite: accesses denied when the authorizer returns noresult (per-request and single-call paths), security-critical configurations
cannot be overridden by system properties, fail fast on a missing Ranger PDP url.
RangerRemoteAuthorizerSuite(+ newMockPdpServer): the thin client against amock PDP server.
build/mvn -nsu test -pl extensions/spark/kyuubi-spark-authz -am
-Dtest=none
-DwildcardSuites=org.apache.kyuubi.plugin.spark.authz.ranger.RangerRemoteAuthorizerSuite,org.apache.kyuubi.plugin.spark.authz.ranger.SparkRangerAdminPluginSuite,org.apache.kyuubi.plugin.spark.authz.ranger.AccessResourceSuite
build/mvn -nsu test -pl extensions/spark/kyuubi-spark-authz -am
-DforkMode=never
-DwildcardSuites=org.apache.kyuubi.plugin.spark.authz.ranger.RangerRemoteAuthorizerSuite
-Dranger.authz.remote.pdp.url=http://localhost:6500
-Dranger.authz.remote.authn.type=header
-Dranger.authz.remote.authn.header.X-Forwarded-User=ranger
Also verified the uri variant fix on the real PDP with both an exact-path url
policy and a trailing-slash url policy.
Was this patch authored or co-authored using generative AI tooling?
Assisted-by: OpenCode (GLM-5.3-Flash)