xiangfu0 commented on code in PR #20169:
URL: https://github.com/apache/pinot/pull/20169#discussion_r4498580078


##########
pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java:
##########
@@ -610,6 +610,26 @@ public static String 
canonicalizeFunctionNamePreservingSpecialKey(String functio
     return CANONICAL_NAME_TO_SPECIAL_KEY_MAP.getOrDefault(canonicalName, 
canonicalName);
   }
 
+  /// Canonical names, see [#canonicalizeFunctionName(String)], of the 
functions that read rows from somewhere other
+  /// than the FROM clause of the query that calls them: `lookup()` joins a 
dimension table by primary key,
+  /// `IN_SUBQUERY` runs its quoted subquery as a request of its own and 
`IN_PARTITIONED_SUBQUERY` runs it on the
+  /// server. The access checks keyed on the FROM clause do not cover them, so 
the single-stage broker rejects them
+  /// under row-level security, see [#isCrossTableFunction(String)].
+  ///
+  /// Nothing derives this set from the function registries, so a function 
that reads another table or runs a nested
+  /// query must be added here when it is defined, and to 
`DeleteStatement#CROSS_TABLE_FUNCTIONS`, which keeps the
+  /// same list in its own fold: `lookup` is `TransformFunctionType#LOOKUP` 
(with `LookupTransformFunction` in
+  /// pinot-core), `insubquery` is rewritten by 
`BaseSingleStageBrokerRequestHandler#IN_SUBQUERY` in pinot-broker and
+  /// `inpartitionedsubquery` by 
`ServerQueryExecutorV1Impl#IN_PARTITIONED_SUBQUERY` in pinot-core.
+  private static final Set<String> CROSS_TABLE_FUNCTIONS = Set.of("lookup", 
"insubquery", "inpartitionedsubquery");
+
+  /// Returns whether `canonicalName` names a function that reads rows from 
somewhere other than the FROM clause, see
+  /// [#CROSS_TABLE_FUNCTIONS]. The name must already be canonical, see 
[#canonicalizeFunctionName(String)], as the
+  /// parser leaves the operator of every compiled function call; a name as 
written in a query is not matched.
+  public static boolean isCrossTableFunction(String canonicalName) {

Review Comment:
   MAJOR (security): this exact match on the canonical name is weaker than the 
server's resolver, which uses per-character `equalsIgnoreCase`. 
`IN_PART\u0131TIONED_SUBQUERY` (dotless ı) canonicalizes to 
`inpartıtionedsubquery` and passes. Under a Turkish default locale, so does the 
normal spelling, because `canonicalizeFunctionName` uses `toLowerCase()`. A 
server without this PR then builds the ID_SET from hidden rows (repro: 47940 vs 
0). Please match the server's fold, e.g. `StringUtils.remove(name, '_')` + 
`equalsIgnoreCase` as `5cbec5b1` did, and restore the dotless-ı test.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to