rajeshkumarchandolu opened a new pull request, #12177: URL: https://github.com/apache/ozone/pull/12177
## What changes were proposed in this pull request? `AuditUtils.getAuditParameters` adds every path and query parameter of an S3 request to the audit parameters. For a presigned (query-authenticated) request this includes the authentication parameters `X-Amz-Signature`, `X-Amz-Credential` and `X-Amz-Security-Token` (and `Signature` / `AWSAccessKeyId` for SigV2). They are written in clear text to the S3 Gateway audit log, for both the `AUTH` failure entry and the operation entry (for example `GET_BUCKET`). These values are credentials and are not needed for auditing: the caller is already recorded in the `user` field. The audit parameters are also added to the current tracing span by the tracing improvements in #12145 (HDDS-17593), so without this change the same values would reach the trace collector as well. This PR leaves those parameters out in `AuditUtils.getAuditParameters`, so neither the audit log nor spans contain them. The fix is in one place because every audit entry goes through this method, including the `AUTH` failure entry in `AWSSignatureProcessor` and the S3 secret and STS endpoints. * The match on the parameter name is case-insensitive. * The non-secret presign parameters (`X-Amz-Algorithm`, `X-Amz-Date`, `X-Amz-Expires`, `X-Amz-SignedHeaders`) and all other query parameters are still audited, as they are useful for debugging. * A denylist is used instead of an allowlist because S3 query parameters (`prefix`, `uploadId`, `list-type`, ...) cannot be enumerated. * Only query parameters reach the audit map; the credential headers of header-authenticated requests are not part of it. ## What is the link to the Apache JIRA https://issues.apache.org/jira/browse/HDDS-17928 ## How was this patch tested? * New unit test `TestAuditUtils`: builds a request with the SigV4 and SigV2 credential parameters (including a differently cased name) plus non-secret ones, and asserts that only the non-secret parameters and the path parameter remain in the audit map. * `TestS3GatewayAuditLog` and checkstyle on `ozone-s3gateway` pass. * Manual check on a local compose cluster (3 OM, 3 SCM, 3 datanodes, S3 Gateway) with tracing enabled and Jaeger, built with the tracing changes from #12145. A presigned-style `GET /auditcheck` with fake `X-Amz-Credential`, `X-Amz-Security-Token` and `X-Amz-Signature` was sent before and after this change. The request returns 400 in both cases because the unsecure cluster cannot validate the fake session token; the span tags are not affected by that. Before: the `BucketEndpoint.get` span has `X-Amz-Credential`, `X-Amz-Security-Token` and `X-Amz-Signature` as tags. <attach 1-presigned-get-before.png> After: those three tags are gone, the other presign parameters and `prefix` are still present. <attach 2-presigned-get-after.png> -- 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]
