Skip to content

Commit 2ab1333

Browse files
committed
Updated README.md
1 parent 0f334c4 commit 2ab1333

File tree

3 files changed

+233
-3
lines changed

3 files changed

+233
-3
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Custom Secret Scanning Patterns repository.
6161

6262
- Generic Password with Base64 encoded secrets
6363

64+
- Generic Password with URI-safe Base64 encoded secrets
65+
6466
- UUIDs
6567

6668
- Bearer Tokens

configs/README.md

+154-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,82 @@ _version: v0.1_
661661
<summary>Pattern Format</summary>
662662

663663
```regex
664-
(([A-Za-z0-9+/]){4})+[A-Za-z0-9+/]{1,2}={0,2}
664+
(([A-Za-z0-9+/]){4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)
665+
```
666+
667+
</details>
668+
669+
<details>
670+
<summary>Start Pattern</summary>
671+
672+
```regex
673+
(?:\n|\A)[ \t]*(?i)[a-z_-]*(?:secret|service_pass(wd|word|code|phrase)|pass(?:wd|word|code|phrase)?|key|token)[ \t]*:[ \t]*(['"]?|[|>]-?[ \t]*\n[ \t]*)
674+
```
675+
676+
</details><details>
677+
<summary>End Pattern</summary>
678+
679+
```regex
680+
['"\r\n]|\z
681+
```
682+
683+
</details>
684+
685+
<details>
686+
<summary>Additional Matches</summary>
687+
688+
Add these additional matches to the [Secret Scanning Custom Pattern](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/defining-custom-patterns-for-secret-scanning#example-of-a-custom-pattern-specified-using-additional-requirements).
689+
690+
691+
692+
- Match:
693+
694+
```regex
695+
[0-9]
696+
```
697+
698+
- Match:
699+
700+
```regex
701+
[A-Z]
702+
```
703+
704+
- Match:
705+
706+
```regex
707+
[a-z]
708+
```
709+
710+
- Match:
711+
712+
```regex
713+
^.{12,}$
714+
```
715+
716+
</details>
717+
718+
## YAML with URI-safe Base64 encoded secrets
719+
720+
**⚠️ WARNING: THIS RULE IS EXPERIMENTAL AND MIGHT CAUSE A HIGH FALSE POSITIVE RATE (test before commiting to org level) ⚠️**
721+
Hardcoded URI-safe Base64-encoded passwords in YAML configuration files
722+
723+
_version: v0.1_
724+
725+
**Comments / Notes:**
726+
727+
728+
- The Base64 must contain numbers, upper case and lower case and be at least 12 characters long
729+
730+
- Some false positives in code might appear
731+
732+
- This matches _- instead of +/, for URI-safe Base64
733+
734+
735+
<details>
736+
<summary>Pattern Format</summary>
737+
738+
```regex
739+
(([A-Za-z0-9_-]){4})*([A-Za-z0-9_-]{4}|[A-Za-z0-9_-]{3}=|[A-Za-z0-9_-]{2}==)
665740
```
666741

667742
</details>
@@ -797,7 +872,84 @@ _version: v0.1_
797872
<summary>Pattern Format</summary>
798873

799874
```regex
800-
(([A-Za-z0-9+/]){4})+[A-Za-z0-9+/]{1,2}={0,2}
875+
(([A-Za-z0-9+/]){4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)
876+
```
877+
878+
</details>
879+
880+
<details>
881+
<summary>Start Pattern</summary>
882+
883+
```regex
884+
[{[,][ \t]*[ \t\r\n]*"(?i)[a-z_.-]*(?:secret|service_pass(wd|word|code|phrase)|pass(?:wd|word|code|phrase)?|key|token)"[ \t]*:[ \t]*"
885+
```
886+
887+
</details><details>
888+
<summary>End Pattern</summary>
889+
890+
```regex
891+
"[ \t\r\n]*[,}\]]
892+
```
893+
894+
</details>
895+
896+
<details>
897+
<summary>Additional Matches</summary>
898+
899+
Add these additional matches to the [Secret Scanning Custom Pattern](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/defining-custom-patterns-for-secret-scanning#example-of-a-custom-pattern-specified-using-additional-requirements).
900+
901+
902+
903+
- Match:
904+
905+
```regex
906+
[0-9]
907+
```
908+
909+
- Match:
910+
911+
```regex
912+
[A-Z]
913+
```
914+
915+
- Match:
916+
917+
```regex
918+
[a-z]
919+
```
920+
921+
- Match:
922+
923+
```regex
924+
^.{12,}$
925+
```
926+
927+
</details>
928+
929+
## JSON with URI-safe Base64 encoded secrets
930+
931+
**⚠️ WARNING: THIS RULE IS EXPERIMENTAL AND MIGHT CAUSE A HIGH FALSE POSITIVE RATE (test before commiting to org level) ⚠️**
932+
Hardcoded URI-safe Base64-encoded passwords in JSON configuration files
933+
934+
_version: v0.1_
935+
936+
**Comments / Notes:**
937+
938+
939+
- The Base64 must contain numbers, upper case and lower case and be at least 12 characters long
940+
941+
- This may match in code, such as Python, that resembles JSON
942+
943+
- This will not match some isolated fragments of JSON, so be aware of that when testing it
944+
945+
- This matches _- instead of +/, for URI-safe Base64
946+
947+
948+
<details>
949+
<summary>Pattern Format</summary>
950+
951+
```regex
952+
(([A-Za-z0-9_-]){4})*([A-Za-z0-9_-]{4}|[A-Za-z0-9_-]{3}=|[A-Za-z0-9_-]{2}==)
801953
```
802954

803955
</details>

generic/README.md

+77-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,83 @@ _version: v0.1_
219219
<summary>Pattern Format</summary>
220220

221221
```regex
222-
(([A-Za-z0-9+/]){4})+[A-Za-z0-9+/]{1,2}={0,2}
222+
(([A-Za-z0-9+/]){4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)
223+
```
224+
225+
</details>
226+
227+
<details>
228+
<summary>Start Pattern</summary>
229+
230+
```regex
231+
(?:\A|[^a-zA-Z0-9])(?i)[a-z0-9._-]*(?:api|auth[a-z]+|jwt|mysql|db)?[_.-]?(?:pass?(?:wo?r?d|code|phrase)|secret|key|token)([_-][a-z0-9]+){0,3}([ \t]+As[ \t]+String)?[\t ]*(={1,3}|:)[\t ]*(?:["']|b["'])?
232+
```
233+
234+
</details><details>
235+
<summary>End Pattern</summary>
236+
237+
```regex
238+
(\z|[\r\n'"])
239+
```
240+
241+
</details>
242+
243+
<details>
244+
<summary>Additional Matches</summary>
245+
246+
Add these additional matches to the [Secret Scanning Custom Pattern](https://docs.github.com/en/enterprise-cloud@latest/code-security/secret-scanning/defining-custom-patterns-for-secret-scanning#example-of-a-custom-pattern-specified-using-additional-requirements).
247+
248+
249+
250+
- Match:
251+
252+
```regex
253+
[0-9]
254+
```
255+
256+
- Match:
257+
258+
```regex
259+
[A-Z]
260+
```
261+
262+
- Match:
263+
264+
```regex
265+
[a-z]
266+
```
267+
268+
- Match:
269+
270+
```regex
271+
^.{12,}$
272+
```
273+
274+
</details>
275+
276+
## Generic Password with URI-safe Base64 encoded secrets
277+
278+
279+
280+
_version: v0.1_
281+
282+
**Comments / Notes:**
283+
284+
285+
- The Base64 must contain numbers, upper case and lower case and be at least 12 characters long
286+
287+
- `password`, `secret`, `key`, or password like prefix (fuzzy)
288+
289+
- Delimiters like `=` or `:` (with padding)
290+
291+
- This matches _- instead of +/, for URI-safe Base64
292+
293+
294+
<details>
295+
<summary>Pattern Format</summary>
296+
297+
```regex
298+
(([A-Za-z0-9_-]){4})*([A-Za-z0-9_-]{4}|[A-Za-z0-9_-]{3}=|[A-Za-z0-9_-]{2}==)
223299
```
224300

225301
</details>

0 commit comments

Comments
 (0)