[ 
https://issues.apache.org/jira/browse/KNOX-3039?focusedWorklogId=974826&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-974826
 ]

ASF GitHub Bot logged work on KNOX-3039:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Jul/25 15:27
            Start Date: 16/Jul/25 15:27
    Worklog Time Spent: 10m 
      Work Description: smolnar82 opened a new pull request, #1062:
URL: https://github.com/apache/knox/pull/1062

   
:exclamation::exclamation::exclamation:IMPORTANT:exclamation::exclamation::exclamation:
   This PR is an almost identical copy of #914 (including this description), 
except:
   - sanitizer configuration init is extracted to a private method
   - a new factory method was created in a singleton class to ensure the new 
`SanitizedException` still complies with the Single Responsibility principal, 
but sanitization is centralized and reusable.
   - new test cases added to the sanitization logic
   - new exception constructor w/o message
   
   ## What changes were proposed in this pull request?
   
   This pull request introduces a mechanism to sanitize error messages in the 
`GatewayServlet` to improve security by hiding IP addresses from exception 
messages. The following changes were made:
   - Added a `isErrorMessageSanitizationEnabled` flag to the `GatewayServlet` 
to control whether error messages should be sanitized.
   - Implemented the `sanitizeException` and `sanitizeAndRethrow` methods in 
`GatewayServlet` to handle exception sanitization.
   - Updated the `GatewayConfig` interface and its implementation 
`GatewayConfigImpl` to include a new method `isErrorMessageSanitizationEnabled`.
   - Created the `GatewayServletTest` class to parameterize tests for scenarios 
where sanitization is enabled and disabled.
   
   ## How was this patch tested?
   
   This patch was tested using the following methods:
   - Parameterized unit tests were added to `GatewayServletTest` to cover both 
scenarios where error message sanitization is enabled and disabled.
   - Manual review and inspection of the code changes to ensure accuracy and 
completeness.
   
   Test steps:
   1. Added unit tests in `GatewayServletTest` to check for sanitized and 
non-sanitized error messages.
   2. Verified the new tests pass successfully, ensuring error messages are 
appropriately sanitized or left unchanged based on the configuration.




Issue Time Tracking
-------------------

    Worklog Id:     (was: 974826)
    Time Spent: 6h  (was: 5h 50m)

> IP Address Exposure in HTTP 500 Error Message
> ---------------------------------------------
>
>                 Key: KNOX-3039
>                 URL: https://issues.apache.org/jira/browse/KNOX-3039
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>            Reporter: Guillermo Kardolus
>            Priority: Major
>          Time Spent: 6h
>  Remaining Estimate: 0h
>
> A potential security vulnerability has been identified in Apache Knox where 
> internal IP addresses are exposed in HTTP 500 error messages. This issue can 
> occur when a user modifies the URL for one of the proxy services, leading to 
> an error page that includes the IP address of the internal service.
> *Steps to Reproduce:*
>  # Navigate to a proxy service URL, for example:
> {{<[https://example.com:8443/gateway/proxy/service?scheme=https&host=example.com&port=8051]>}}
>  # Modify the {{port}} parameter to an invalid port, such as:
> {{<[https://example.com:8443/gateway/proxy/service?scheme=https&host=example.com&port=9999]>}}
>  # Observe the resulting HTTP 500 error message which includes the internal 
> IP address.
> *Observed Behavior:* The error message reveals the internal IP address in the 
> stack trace, which can be used by an attacker for port scanning and other 
> malicious activities.
> *Example:*
> {code:java}
> HTTP ERROR 500 java.io.IOException: java.io.IOException: Service connectivity 
> error.
> MESSAGE: java.io.IOException: java.io.IOException: Service connectivity error.
> ...
> CAUSED BY: java.io.IOException: Connect to example.com:9996 
> [example.com/10.140.190.10] failed: Connection refused (Connection refused)
> ... {code}
> *Expected Behavior:* Error messages should not expose internal IP addresses. 
> Instead, they should be sanitized to prevent the disclosure of sensitive 
> information.
> *Proposed Solution:*
>  # *Sanitization Mechanism:* Implement a mechanism to sanitize error messages 
> before they are sent to the client. This can include replacing IP addresses 
> with placeholders such as {{{}[hidden]{}}}.
>  # *Configuration Options:* Provide configuration options for users to enable 
> or disable this sanitization based on their security needs. By default, users 
> should opt-in to this new sanitization functionality, with an option to 
> opt-out if necessary.
>  # *Knox-specific Error Page:* Alternatively, consider implementing a 
> Knox-specific error page that displays an error message without revealing any 
> sensitive information.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to