gnodet-bot commented on code in PR #27945:
URL: https://github.com/apache/camel/pull/27945#discussion_r4294405878


##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -523,6 +523,22 @@ registered.
 To restore the previous behaviour, set `webhookSecretTokenEnabled=false`: the 
webhook is then registered without a
 secret token, and webhook requests are not verified.
 
+=== camel-netty-http - the security constraint resolves dot-segments in the 
request path
+
+A `netty-http` consumer configured with a `securityConstraint` now resolves 
`.` and `..` segments in the request path
+(including their percent-encoded `%2e` form) before the path is matched 
against the configured inclusions and exclusions,
+following the `remove_dot_segments` algorithm of RFC 3986. The constraint is 
therefore evaluated against the effective
+resolved path, which is the same resource the request is routed to. Excess 
`..` segments cannot climb above the endpoint
+context root.
+

Review Comment:
   ⚠️ **Inaccurate wording:** The upgrade guide says _"Excess `..` segments 
cannot climb above the **endpoint context root**"_, but the `removeDotSegments` 
algorithm is a standalone string transform with no knowledge of the endpoint's 
context path — it normalizes against the server root `/`. The test case 
`/foo/../../admin/x → /admin/x` confirms this: the result is `/admin/x` 
relative to `/`, not relative to the endpoint base.
   
   The Javadoc in the source correctly says _"cannot climb above the **root**"_ 
(no "endpoint context" qualifier). The upgrade guide should match:
   
   ```suggestion
   resolved path, which is the same resource the request is routed to. Excess 
`..` segments cannot climb above the root.
   ```



##########
components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandlerDotSegmentTest.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty.http.handlers;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * The security constraint is evaluated against the effective resolved 
resource path, so {@code .} and {@code ..}
+ * segments are removed (RFC 3986 section 5.2.4) before the target is matched 
against the configured inclusions. Excess
+ * {@code ..} segments cannot climb above the root, so the result never 
contains a {@code ..} segment.
+ */
+class HttpServerChannelHandlerDotSegmentTest {
+
+    @ParameterizedTest
+    @CsvSource(delimiter = '|', textBlock = """
+            # input                 | expected
+            /foo/admin/x            | /foo/admin/x
+            /foo/./admin/x          | /foo/admin/x
+            /foo/../admin/x         | /admin/x
+            /foo/../../admin/x      | /admin/x
+            /foo/sub/../admin/x     | /foo/admin/x
+            /foo/a/../../../admin   | /admin
+            /foo/admin/.            | /foo/admin/
+            /foo/admin/..           | /foo/
+            /..                     | /
+            /admin/file.txt         | /admin/file.txt
+            /                       | /
+            """)

Review Comment:
   💡 **Consider adding edge-case tests:** The current test matrix covers the 
main traversal patterns well. Two additional cases worth considering:
   
   1. **Hidden file with a leading dot** (not a dot-segment): 
`/admin/.hidden/secret` should pass through unchanged — a `.hidden` component 
is not a RFC 3986 dot segment, so the algorithm must not remove it. Without an 
explicit test, a regression could silently strip it.
   2. **Traversal escaping the endpoint prefix toward `/admin/`**: a variant 
like `/app/../admin/x` (as opposed to the existing `/foo/../admin/x`) would 
make it clearer that the security bypass works regardless of the prefix name.
   
   Neither is blocking, but they would strengthen the regression coverage for a 
security fix.



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