Copilot commented on code in PR #13708:
URL: https://github.com/apache/trafficserver/pull/13708#discussion_r4061721521


##########
plugins/experimental/access_control/access_control.cc:
##########
@@ -470,6 +491,29 @@ accessTokenStatusToString(const AccessTokenStatus &state)
   return s;
 }
 
+/**
+ * Validates the request path against the token scope using normalized segment 
boundaries.
+ */
+bool
+validateScope(StringView requestPath, StringView scope)
+{
+  if (scope.empty()) {
+    return true;
+  }
+  String normRequestPath = normalizePath(requestPath);
+  String normScope       = normalizePath(scope);
+  if (normScope == "/") {
+    return true;
+  }
+  if (normRequestPath == normScope) {
+    return true;
+  }
+  if (normRequestPath.starts_with(normScope) && 
normRequestPath[normScope.length()] == '/') {

Review Comment:
   This comparison treats `..` as an ordinary segment, so a request such as 
`/reports/../hr/payroll` passes a `/reports` scope even though the normalized 
resource path can resolve outside `/reports` (and percent-encoded dot segments 
can have the same effect when decoded downstream). Canonicalize dot 
segments/escaped traversal before applying the prefix check, or reject such 
paths, and add regression tests for traversal attempts.



-- 
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]

Reply via email to