Change an existing rule to find more candy.#155
Merged
l0ss merged 1 commit intoSnaffCon:masterfrom Oct 15, 2024
Merged
Conversation
Changing the rule identifying client secrets to identify unquoted secrets as well.
ZephrFish
pushed a commit
to ZephrFish/Snaffler
that referenced
this pull request
Jan 31, 2026
Change an existing rule to find more candy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Change rule for more candy.
Long story
In engagements, we encounter more and more hybrid environments (especially Azure).
Therefore, I was wondering if Snaffler identifies secrets in Azure/Entra related scripts.
Therefore, I tested several authentication methods with several Azure related tool (Azure CLI, Azure PowerShell, MS Graph, Exchange Online PNP, native API calls etc.).
Snaffler catches all scripts for tools which require a PS password object 😄 .
However, it does not catch the secret in some cases 😢 .
Sometimes customer do not use PowerShell module but native API call (example with curl). The string client_secret is currently not detected if the secret is not quoted.
The current rule (client_secret\s*=\s*[\'\"][^\\'\\\"]....) in the file KeepPassOrKeyInCode.toml catches stuff like:
client_secret = 'SuperPassword1!'
client_secret = "SuperPassword1!"
But it will miss client secrets which are not quoted:
client_secret = SuperPassword1!
client_secret = $MyPW
At least using the example by Microsoft (using CURL) the passwords are not quoted:
References: https://learn.microsoft.com/en-us/graph/auth-v2-user?tabs=curl#step-2-request-an-access-token
Therefore, I suggest to change the current regex to catch all those cases:
Old: client_secret\s*=\s*[\'\"][^\\'\\\"]....
New: client_secret\s*=\s
Using this changed rule, all credentials (quoted and unquoted) are identified:

(Parsed Snaffler output file)