Skip to content
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

Algolia key support #865

Closed
SimonGurney opened this issue May 5, 2022 · 8 comments
Closed

Algolia key support #865

SimonGurney opened this issue May 5, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@SimonGurney
Copy link
Contributor

An Algolia key matches the regex [a-zA-Z0-9]{32}.

Algolia keys are quite common now and are often included in front end JS code to build autocomplete forms etc. Overly permissive keys are an issue as it means attackers can manipulate data etc and gitleaks would make an awesome tool to find them.

The regex for the key is likely prone to false positives, but no more so than "generic-api-key".

I am happy to do the PR on this, but I was wondering if you would consider a regex without an obvious prefix/suffix which would eliminate false positives.
cc @zricethezav

@SimonGurney SimonGurney added the enhancement New feature or request label May 5, 2022
@zricethezav
Copy link
Collaborator

Hi @SimonGurney, all semi-generic regexes follow a similar pattern to that of https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml#L74, for example. I generate these rules with a utility here https://github.com/zricethezav/gitleaks/blob/master/cmd/generate/config/main.go.

I can add this sometime in the next two weeks if you haven't gotten to it already

@SimonGurney
Copy link
Contributor Author

I'll get a PR in tomorrow. So does the keyword need to be found in the document for the regex to find the secret?

@zricethezav
Copy link
Collaborator

@SimonGurney yes, the keyword is essentially a ROI marker or prefilter. If a git patch fragment does not contain a the keyword, that rule can be ignored.

@SimonGurney
Copy link
Contributor Author

Ok understood. I think in most cases the word "Algolia" would be on the same line, but it's definitely not required and I imagine a diff which changes the key could be as simple as

Key=[key]

Would you want the keyword including or not? I guess it's a balance between eliminating false positives and missing secrets right?

@zricethezav
Copy link
Collaborator

zricethezav commented May 5, 2022

but it's definitely not required and I imagine a diff which changes the key could be as simple as Key=[key]

I don't follow

Would you want the keyword including or not? I guess it's a balance between eliminating false positives and missing secrets right?

Keywords should always be included to reduce fps and help performance. The generic key would likely catch keys that don't contain Algolia

@SimonGurney
Copy link
Contributor Author

Makes sense, I'll raise the PR tomorrow.

Thanks for your help 😃

@SimonGurney
Copy link
Contributor Author

Is this what you were thinking, I just based it off old PRs, or do you want me to use the rule generator and add one to here cmd/generate/config/rules/?

@SimonGurney
Copy link
Contributor Author

@zricethezav are you happy with the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants