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

Additional regex in KeepPassOrKeyInCode.toml #154

Merged
merged 1 commit into from
Oct 15, 2024
Merged

Conversation

zh54321
Copy link
Contributor

@zh54321 zh54321 commented Oct 11, 2024

TL;DR
More rules 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 😢 .

Unquoted credentials example for Azure CLI (az login --user johndoe@contoso.com --password VerySecret) are not found by Snaffler. Potentially there could be many scripts which using this parameter in other context (example for custom on-prem applications). At least on Windows, strings are many times not quoted. Or they simply are stored in variables.
For example, in the official Microsoft documentation: https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli-interactively#sign-in-with-credentials-on-the-command-line

The current rule (passw?o?r?d\s*=\s*[\'\"][^\\'\\\"]....) and (passw?o?r?d?>\s*[^\\s<]+\s*<) in the file KeepPassOrKeyInCode.toml catches stuff like:
password = "SuperPassword1!"
password = 'SuperPassword1!'
SuperPassword1!

But it will miss client secrets which are not enquoted:
-password SuperPassword1!
-password $MyPW
-pass SuperPassword1!
-pass $MyPW

Therefore, I suggest adding an additional regex to cover those cases:
-passw?o?r?d?

Using this additional rule entry, the credentials are identified by Snaffler:
O7bXnqjJtU
(Parsed Snaffler output file)

Additional detection of unquoted credentials which are used with for example the parameter -password
@zh54321 zh54321 changed the title Update KeepPassOrKeyInCode.toml Additional regex in KeepPassOrKeyInCode.toml Oct 11, 2024
@l0ss l0ss merged commit 02c7410 into SnaffCon:master Oct 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants