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

Gitleaks misses quite a few Azure rules. #539

Open
jessehouwing opened this issue Mar 16, 2021 · 13 comments · May be fixed by #1291
Open

Gitleaks misses quite a few Azure rules. #539

jessehouwing opened this issue Mar 16, 2021 · 13 comments · May be fixed by #1291
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@jessehouwing
Copy link
Contributor

Gitleaks is missing quite a few rules for the Microsoft ecosystem, including Visual Studio, Azure and Azure DevOps.

Microsoft used to have a competing product called credscan, but it was recently deprecated in favor of the GitHub Security offerings.

I've ported most of the rules from credscan to the gitleaks format and put them in a repo here:
https://github.com/jessehouwing/gitleaks-azure

I'd love to contribute them, but I'm unsure to the process of vetting and approving these rules.

cc @zricethezav


Some features GitLeaks may be missing:

  • credscan has a few built-in decoders, so you can have it match a specific kind of pattern, say a base64 encoded string of 78 characters, then decode it and check the decoded value matches a regex. This reduces positives on base-64 encoded credentials that don't have an easily recognizable pattern.
  • similarly, it has a regex, xpath and jsonpath matcher.
  • it has a set of rules that use the .NET base library to assert things about the contents) that can detect whether a base64 encoded value is an image/icon/cert/jsonwebtoken. You can use these to include or exclude the values for further probing.

Without these the ruleset will trigger more false-positives.

@jessehouwing jessehouwing added the enhancement New feature or request label Mar 16, 2021
@zricethezav
Copy link
Collaborator

@jessehouwing wow thanks for bringing this up! I definitely would like to add more rules to the default gitleaks configuration. Feel free to open a MR. It looks like you have a good start https://github.com/jessehouwing/gitleaks-azure/blob/main/UDMSecretChecks.toml

I'd love to contribute them, but I'm unsure to the process of vetting and approving these rules.

There isn't really a process. If you could link to some example credentials or Azure documentation that describes the regexes that would be more than sufficient.

I need to add a CONTRIBUTE.md file so it's easier to contribute new rules but for now you can edit https://github.com/zricethezav/gitleaks/blob/master/config/default.go and add the rules there.

@jessehouwing
Copy link
Contributor Author

I contributed in a project called SpamAssassin before. There I was abne tm setup what we called a Spam and a Ham corpus of examples to test rules against, many people separated oud good code vs bad code and every time the ruleset changed, they'd run the new ruleset and reported any new false positives and false negatives.

Would be nice if people could setup a private repo with a GitHub action to give you more confidence over the quality of the rules added through a pull request.

@zricethezav zricethezav added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 18, 2021
@jessehouwing
Copy link
Contributor Author

Yups that's the pattern source. There isn't a 1-to-1 mapping, but it's close.

@SebastianSchuetze
Copy link

Any update on a possible PR @jessehouwing and @zricethezav . We use are going to use gitleaks internally at our company and implemented your rules @jessehouwing. We also started creating a repo that triggers the rules to get findings. We may be able to work something out to push this a little bit.

Could we integrate this into the default rule set?

@zricethezav
Copy link
Collaborator

@SebastianSchuetze @jessehouwing if either of you wanted to contribute these rules into the default config I'd be more than happy to review it. Going to pin this issue as it's a relatively easy first issue for newcomers

@zricethezav zricethezav pinned this issue Nov 28, 2022
@dvasdekis
Copy link
Contributor

Hi all, currently working on this in https://github.com/dvasdekis/gitleaks-azure/tree/fix_%23539

@SebastianSchuetze
Copy link

Just a small tipp @dvasdekis. Can you use the wording AzDO oder ADO for abbreviation or the full product name Azure DevOps? VSTS is the old name and is deprecated.

@dvasdekis
Copy link
Contributor

Just a small tipp @dvasdekis. Can you use the wording AzDO oder ADO for abbreviation or the full product name Azure DevOps? VSTS is the old name and is deprecated.

Thanks for reviewing. These specific tokens are VSTS tokens - Azure Devops tokens have a different format (I believe)

@jessehouwing
Copy link
Contributor Author

Just a small tipp @dvasdekis. Can you use the wording AzDO oder ADO for abbreviation or the full product name Azure DevOps? VSTS is the old name and is deprecated.

Thanks for reviewing. These specific tokens are VSTS tokens - Azure Devops tokens have a different format (I believe)

It's the same format. It's the same thing. The "new name" s Azure DevOps and unfortunately, there's no fixed prefix on these tokens to easily detect them.

@dvasdekis
Copy link
Contributor

Hi, this is now ready for review: #1079

@SebastianSchuetze
Copy link

@zricethezav the PR is open. So you need anything to have this approved or checked?

@zricethezav zricethezav unpinned this issue Mar 7, 2023
zricethezav pushed a commit that referenced this issue Jun 15, 2023
* Initial secret set

* Covered off all rule types in comments

* Finished Azure and Ansible rules

* About to run go run main.go

* Fixed some rules, but tests need work

* Initial secret set for Azure

Needs work - many tests fail

* Fix remaining Azure secrets - but couldn't get XML to work

* Update .gitignore

Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>

---------

Co-authored-by: Jesse Houwing <jesse.houwing@gmail.com>
zricethezav added a commit that referenced this issue Jun 15, 2023
zricethezav added a commit that referenced this issue Jun 15, 2023
@StephenHogg StephenHogg linked a pull request Nov 17, 2023 that will close this issue
3 tasks
@StephenHogg
Copy link

StephenHogg commented Nov 17, 2023

Hi guys, I've made a copy of this PR but with keywords included. It's almost completely the same otherwise. Let me know if this helps

@jessehouwing @zricethezav @dvasdekis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants