#1085·gitleaks

Private key regex is greedy

Author: SimonGurneyCreated Jan 30, 2023Updated Sep 23, 2026

When a file contains two private keys, gitleaks greedy matches both into one detection.

The regex should be changed to be none greedy so it detects two private keys seperately.

-----BEGIN[ A-Z0-9_-]{0,100}PRIVATE KEY( BLOCK)?-----[\s\S-]*?KEY( BLOCK)?----
                                                             ^

https://github.com/zricethezav/gitleaks/blob/afdccad46ff8d3b38a8238cde4052d096e98961e/config/gitleaks.toml#L2430