-
Notifications
You must be signed in to change notification settings - Fork 2.1k
V2 detector for confluent #4489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
V2 detector for confluent #4489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work.
Added a few questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to this, we must send the API key in an Authorization: Basic {credentials} header, which requires us to provide the credentials as the API key ID and associated API secret separated by a colon and encoded using Base64 format.
So my question is, how useful is this API secret alone without an API key ID? I get that we can detect and potentially verify the API secret using your new implementation, but can an API secret alone be exploited if leaked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point ! API secret cannot be exploited without the corresponding API key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added API key detection in V2, similar to V1. Sorry about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update. I am not saying this is wrong but I do have some concerns regarding the way we are verifying the secrets. Right now, we are detecting keys and secrets, but we are verifying only secrets, instead of verifying a pair of key and secret.
For example, I copied the secret you have added in the test file and pasted in a file, and added a fake api key "0123456789ABCDEF", and ran a scan and the detector is showing this finding as a verified secret. However, this is a fake pair of secret and if this pair of API key and secret is leaked, they are worthless(correct me if I am wrong here).
So maybe we should switch to the API-based verification. I am open to suggestions here but just giving you the idea of how we detect and verify secrets in the detectors.
I am attaching the screenshot of the scan result where the incorrect API key is shown as verified.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way to accurately verify confluent secrets via API (for both V1 and V2) . V2 secrets don't need API verification since they have CRC32 checksum appended. But, I have added API key + secret detection for V2 (instead of just secrets detection). More context in the issue : #4490
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added API key detection in V2, similar to V1. Sorry about that.
Thanks for adding the API Key ID detection, however, I do not see the API Key ID actually being used in the verification part. The reason I asked for the addition of API Key ID here was because in order to verify a confluent API Key, we need both the API key ID and the associated API Secret as mentioned in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is another example. I have created the following secret using a Python script:
confluent_key=ABCDEF1234567890
confluent_secret: cfltAsBrY8jb/2fxvr4eyerR8Cel/PnpFSuWfn5Y3Rfzgg70rfKOczuFrmk3LUYA
Both of these are fake, yet they were able to bypass the checksum-based validation, and the detector marked them as a verified result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shahzadhaider1 , The test secret you shared in the last comment has a valid checksum. That is why it's passing the check. However, I think we can rely on this checksum based mechanism because of the following reasons :
- the new pattern for Confluent Secrets is very specific and it's unlikely that random strings will match this pattern, especially due to the CRC32 checksum being appended at the end.
- If the secret is present in text and valid, then it is very likely that a valid Confluent key pattern (16 bytes of uppercase characters or numbers only) is also present in the nearby text, in which case we can consider it the key+secret pair as valid. for the key pattern, we are using
\b
which will ensure that the key pattern only matches complete words and not random characters.
I think the above checks are sufficient to eliminate FPs in real world. Please let me know your thoughts. Thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahzadhaider1 please let me know if you agree my last comment in this thread. Thanks !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after some internal discussion, I have decided to convert this to a draft. we are thinking about how we can accurately perform validation on different types of API keys. Thanks a lot for your inputs.
@shahzadhaider1 addressed all your comments. Please let me know if you need any more changes. I also tested that a valid confluent cloud API key can be detected by V2 detector. |
Hey @ap00rv, thanks for clarifying that. I completely understand that V2 secrets have a built-in checksum, which makes offline validation possible, that part makes sense. However, I did some testing of your branch and shared a concern here. Two things I wanted to discuss:
|
95fbb8e
to
3f5d567
Compare
3f5d567
to
568ea89
Compare
Description:
closes #4490
Checklist:
make test-community
)?make lint
this requires golangci-lint)? (linting passes for changes in this PR)Local testing
V2 detector is catching a real confluent cloud V2 secret