You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "holdenk (via GitHub)" <gi...@apache.org> on 2026/08/31 23:21:11 UTC

[PR] [SPARK-59118][SQL] Warn when doAs is enabled but not enforced [spark]

holdenk opened a new pull request, #58438:
URL: https://github.com/apache/spark/pull/58438

   ### What changes were proposed in this pull request?
   
   This is a softer follow on of https://github.com/apache/spark/pull/58414 for 4.X branch which warns when doAs is enabled but not enforced. We should log rather than fail a previously running job.
   
   ### Why are the changes needed?
   
   People might expect doAs to run as a different user, which is not supported.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Explicit error unless config flag is disabled.
   
   ### How was this patch tested?
   
   New unit test.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Yes, claude 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5784516195

   BTW, for `master` PR, I approved it.
   - https://github.com/apache/spark/pull/58414


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5784486484

   Yup I'll update this one shortly since it seems like we've largely settled on the master/5.X version :) 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-6381242968

   the master pr is merged, is this one ready to go?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan closed pull request #58438: [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced
URL: https://github.com/apache/spark/pull/58438


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL] Warn when doAs is enabled but not enforced [spark]

Posted by "uros-b (via GitHub)" <gi...@apache.org>.
uros-b commented on code in PR #58438:
URL: https://github.com/apache/spark/pull/58438#discussion_r3904580403


##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala:
##########
@@ -105,6 +107,28 @@ object HiveThriftServer2 extends Logging {
     }
   }
 
+  // Sessions are impersonated for metastore calls, but queries run as the service identity
+  // (SPARK-5159), so storage ACLs are checked against the wrong principal. Auth types that never
+  // establish a user identity have nothing to impersonate, so they are exempt.
+  private[thriftserver] def warnIfIneffectiveDoAs(hiveConf: HiveConf): Unit = {
+    val authType = hiveConf.getVar(ConfVars.HIVE_SERVER2_AUTHENTICATION)
+    val unverifiedAuthTypes = Seq(AuthTypes.NONE, AuthTypes.NOSASL).map(_.getAuthName)
+    // Constant on the left: authType is null when explicitly set empty, and this must not NPE.
+    val authVerifiesUser = !unverifiedAuthTypes.exists(_.equalsIgnoreCase(authType))
+    if (authVerifiesUser && hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS)) {
+      logWarning(log"${MDC(CONFIG, ConfVars.HIVE_SERVER2_ENABLE_DOAS.varname)} is set to true, " +
+        log"but the Spark Thrift Server impersonates the connecting user only for Hive " +
+        log"metastore calls: queries and the storage access they perform still run as the " +
+        log"server's own service identity, so storage permissions are checked against the " +
+        log"service principal rather than the connecting user (SPARK-5159). That can expose " +
+        log"data the connecting user is not authorized to read. Setting it to false silences " +
+        log"this, but note that it stops impersonating metastore calls too, so it is not a " +
+        log"no-op (and unsetting it does not help -- Hive's own default is true). Spark 5.0 " +
+        log"is expected to refuse to start on this configuration; set " +
+        log"spark.sql.hive.thriftServer.allowIneffectiveDoAs=true there to keep it running.")

Review Comment:
   The warning message hardcodes spark.sql.hive.thriftServer.allowIneffectiveDoAs, which isn't even merged yet, right? I wonder if there is a more robust way to do this... Otherwise, the implementation looks clean and the test coverage is good!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #58438:
URL: https://github.com/apache/spark/pull/58438#discussion_r3974251894


##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/HiveThriftServer2.scala:
##########
@@ -105,6 +107,28 @@ object HiveThriftServer2 extends Logging {
     }
   }
 
+  // Sessions are impersonated for metastore calls, but queries run as the service identity
+  // (SPARK-5159), so storage ACLs are checked against the wrong principal. Auth types that never
+  // establish a user identity have nothing to impersonate, so they are exempt.
+  private[thriftserver] def warnIfIneffectiveDoAs(hiveConf: HiveConf): Unit = {
+    val authType = hiveConf.getVar(ConfVars.HIVE_SERVER2_AUTHENTICATION)
+    val unverifiedAuthTypes = Seq(AuthTypes.NONE, AuthTypes.NOSASL).map(_.getAuthName)
+    // Constant on the left: authType is null when explicitly set empty, and this must not NPE.
+    val authVerifiesUser = !unverifiedAuthTypes.exists(_.equalsIgnoreCase(authType))
+    if (authVerifiesUser && hiveConf.getBoolVar(ConfVars.HIVE_SERVER2_ENABLE_DOAS)) {
+      logWarning(log"${MDC(CONFIG, ConfVars.HIVE_SERVER2_ENABLE_DOAS.varname)} is set to true, " +

Review Comment:
   Warn-only is the right call for a maintenance branch -- it surfaces the SPARK-5159 impersonation gap without breaking servers that are running today, and pointing at the 5.0 escape hatch (`allowIneffectiveDoAs`) in the message is a nice touch. One fix: the PR description still answers the user-facing-change question with "Explicit error unless config flag is disabled" (copied from #58414), but this variant only logs a warning and never fails startup -- please update it so the 4.x behavior isn't misread as a hard failure.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5801515642

   I'm going back and forth on if the config flag is worth it since it would just gate a warning *but* it does let people proactively see how to opt out of enforcement.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5808001469

   Moved to draft while I update it based on the master approved one


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-6444027521

   **Merge Summary:**
   - merged into branch-4.x https://github.com/apache/spark/commit/f21fdf4d41727b170f5e1af7f5385f427fdbfa52
   
   *Posted by `merge_spark_pr.py`*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-6433314247

   @holdenk I pushed two commits to retarget this at 4.4. It missed 4.3.0: neither 4.3.0-rc2 nor 4.3.0-rc3 includes it, and branch-4.x is now the 4.4.0 line.
   
   - 9c9befc8523: merged the current `branch-4.x` into this branch. It was based on an Aug 12 `branch-4.x`, and the "Upgrading from Spark SQL 4.3 to 4.4" section has since grown on both sides of its only entry, so moving the migration note there would otherwise conflict. The merge itself had no conflicts.
   - f918b8e6f54: `spark.sql.hive.thriftServer.allowIneffectiveDoAs` is now `.version("4.4.0")`, and the migration note moved from the 4.2 to 4.3 section to the end of the 4.3 to 4.4 section ("Since Spark 4.4"). This matches master's migration guide, which already says "Spark 4.4 logs a warning for the same configuration."
   
   No code or test changes; the PR still touches the same 5 files. I also fixed the user-facing-change line in the PR description, which said the warning is silenced by disabling a flag; it is silenced by setting `allowIneffectiveDoAs` to `true`.
   
   After this merges, master needs a one-line follow-up to change the same conf's `.version("5.0.0")` to `"4.4.0"`, since it will first ship in 4.4.0.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-6433668623

   Yeah 4.4.0 makes sense


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5769632501

   Good point updated the PR description


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-5784360654

   Thank you for making a softer version for `branch-4.x`, @holdenk.
   
   Since this is the `branch-4.x` counterpart of #58414, it would be great to keep the two consistent. Currently there are a few divergences:
   
   1. **Unrecognized auth types**: #58414 uses an allow-list (`LDAP/KERBEROS/CUSTOM/PAM`) and leaves unknown values to `HiveAuthFactory`'s own error, while this PR uses a deny-list (everything except `NONE/NOSASL`), and the test `an unrecognized auth type warns` pins the opposite behavior. 4.x should warn on exactly the configurations that 5.0 will reject.
   2. **Message accuracy**: #58414 says impersonation applies on the driver (metastore calls *and* driver-side file system access) and executor-side access runs as the service identity. This PR says only metastore calls are impersonated.
   3. **Null comment**: `authType is null when explicitly set empty` contradicts #58414 (`getVar` returns `""`, never null). With the allow-list approach, this comment becomes unnecessary.
   4. **PR description**: It says "Explicit warning unless config flag is disabled", but there is no such flag in this PR. The only way to silence it is `doAs=false`, which also disables metastore impersonation. Do we want to add the same static conf to 4.x (e.g., default `true`) so that users can acknowledge the limitation without changing behavior?
   
   Also, the warning message is quite long for a single log line. It might be better to keep it concise and move the details to the migration guide.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Re: [PR] [SPARK-59118][SQL][4.x] Warn when doAs is enabled but not enforced [spark]

Posted by "cloud-fan (via GitHub)" <gi...@apache.org>.
cloud-fan commented on PR #58438:
URL: https://github.com/apache/spark/pull/58438#issuecomment-6443980633

   tests actually passed, thanks, merging to 4.x!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org