Andrea Cosentino created CAMEL-27931:
----------------------------------------

             Summary: camel-aws2-s3 - mask the SSE-C customerKeyId in logs and 
management output
                 Key: CAMEL-27931
                 URL: https://issues.apache.org/jira/browse/CAMEL-27931
             Project: Camel
          Issue Type: Improvement
          Components: camel-aws2-s3
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino
             Fix For: 4.25.0


h3. Background

The camel-aws2-s3 component supports server-side encryption with a 
customer-provided key (SSE-C). When {{useCustomerKey=true}}, the key material 
is configured through the {{customerKeyId}} option on {{AWS2S3Configuration}}. 
Despite its name, {{customerKeyId}} is not an identifier: it holds the 256-bit 
customer-provided key itself, base64-encoded, and is passed straight to the AWS 
SDK ({{sseCustomerKey(...)}} / {{copySourceSSECustomerKey(...)}}) in 
{{AWS2S3Consumer}}, {{AWS2S3Producer}} (PutObject, multipart upload, streaming 
upload, getObject, getObjectRange and copyObject) and {{AWS2S3Utils}}.

h3. Current behaviour

{{customerKeyId}} is annotated {{@UriParam(label = "common,advanced")}} with no 
secret marker, unlike the component's other credential options ({{accessKey}}, 
{{secretKey}}, {{sessionToken}}), which carry {{security = "secret"}}. Camel's 
endpoint-URI value masking ({{org.apache.camel.util.URISupport.sanitizeUri}} 
then {{sanitizeQueryParameters}} then {{isSensitiveKey}}) is driven by a 
build-generated keyword set and pattern in {{core/camel-util}} 
({{org.apache.camel.util.SensitiveUtils}}), which the packaging generator 
{{UpdateSensitizeHelper.collectSecretOption}} populates only from options whose 
metadata marks them secret. Because {{customerKeyId}} is unmarked, 
{{customerkeyid}} is absent from {{SensitiveUtils}}, so its value is rendered 
verbatim wherever a sanitized endpoint URI is printed: route and startup 
logging, {{DefaultEndpoint.toString()}}, JMX endpoint object names and 
attributes, the developer console, the Camel CLI ({{camel get endpoint}}), 
health endpoint URIs, JSON events and endpoint-failure messages. The component 
documentation example inlines the key in the URI with 
{{customerKeyId=RAW(...)}}.

h3. Behaviour after the change

{{customerKeyId}} is marked as a secret option, so the build includes 
{{customerkeyid}} in the generated {{SensitiveUtils}} keyword set and pattern. 
{{URISupport.sanitizeUri}} then masks its value (replaced with {{xxxxxx}}) 
across all of the surfaces above, consistent with how {{accessKey}} and 
{{secretKey}} are already handled. {{customerKeyMD5}} (a base64 MD5 digest, not 
the key) and {{customerAlgorithm}} ({{AES256}}) are left unchanged.

h3. Code-level change

* {{components/camel-aws/camel-aws2-s3/.../AWS2S3Configuration.java}}: add 
{{security = "secret"}} to the {{@UriParam}} on {{customerKeyId}}, keeping 
{{label = "common,advanced"}} so the SSE-C options stay grouped. (On the 4.18.x 
line, which predates the {{@UriParam(security = ...)}} attribute, use {{secret 
= true}} instead; both forms make the generator emit {{customerkeyid}}.)
* Regenerate metadata through the full reactor and commit the generated output: 
the component descriptor {{aws2-s3.json}} and its catalog mirror (now 
{{"secret": true, "security": "secret"}} on {{customerKeyId}}), plus 
{{SensitiveUtils.java}} and {{sensitive-keys.json}} in {{core/camel-util}}, 
which both gain {{customerkeyid}}.

h3. Tests

A unit test in camel-aws2-s3 builds an {{aws2-s3}} endpoint URI with 
{{useCustomerKey=true&customerKeyId=RAW(<base64>)&customerKeyMD5=...&customerAlgorithm=AES256}}
 and asserts that {{URISupport.sanitizeUri}} masks the {{customerKeyId}} value 
while leaving {{customerKeyMD5}} and {{customerAlgorithm}} visible. The 
module's tests use JUnit assertions, so the new test follows that style.

h3. Documentation

An upgrade-guide note records that the {{customerKeyId}} option is now masked 
in logs, JMX, consoles and the Camel CLI (added for 4.25.0 on main, with the 
matching notes for the backport lines also kept on main). Optionally, the 
component documentation can mention property-placeholder or vault resolution as 
an alternative to inlining the key with {{RAW(...)}}.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to