Copilot commented on code in PR #62108:
URL: https://github.com/apache/doris/pull/62108#discussion_r3033415205


##########
fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java:
##########
@@ -671,12 +671,19 @@ private String getAllHeaders(HttpServletRequest request) {
         Enumeration<String> headerNames = request.getHeaderNames();
         while (headerNames.hasMoreElements()) {
             String headerName = headerNames.nextElement();
-            String headerValue = request.getHeader(headerName);
+            String headerValue = isSensitiveHeader(headerName) ? 
"***MASKED***" : request.getHeader(headerName);
             
headers.append(headerName).append(":").append(headerValue).append(", ");
         }
         return headers.toString();
     }
 
+    private boolean isSensitiveHeader(String headerName) {
+        return "Authorization".equalsIgnoreCase(headerName)
+                || "Proxy-Authorization".equalsIgnoreCase(headerName)
+                || "token".equalsIgnoreCase(headerName)
+                || "Auth-Token".equalsIgnoreCase(headerName);
+    }

Review Comment:
   `getAllHeaders()` still logs every header name/value and only masks a small 
hard-coded set. Since FE auth can fall back to cookies (session-based auth), 
unmasked `Cookie` / `Set-Cookie` headers can leak session identifiers into INFO 
logs. Consider expanding the sensitive header list to include cookie headers 
(and ideally using a centralized allowlist/denylist such as a static Set of 
lowercased names) so future auth headers don’t get missed.



##########
fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java:
##########
@@ -671,12 +671,19 @@ private String getAllHeaders(HttpServletRequest request) {
         Enumeration<String> headerNames = request.getHeaderNames();
         while (headerNames.hasMoreElements()) {
             String headerName = headerNames.nextElement();
-            String headerValue = request.getHeader(headerName);
+            String headerValue = isSensitiveHeader(headerName) ? 
"***MASKED***" : request.getHeader(headerName);
             
headers.append(headerName).append(":").append(headerValue).append(", ");

Review Comment:
   The new masking behavior in `getAllHeaders()` is security-sensitive but 
currently untested. There are HTTPv2 REST action tests in this repo (e.g., 
`GetLogFileActionTest` uses reflection to test private helpers); adding a small 
unit test that verifies sensitive headers are masked (and non-sensitive headers 
are preserved) would help prevent regressions.



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