mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
chore: Enhance curl-auth-user to detect empty usernames or passwords (#1726)
This commit is contained in:
1 parent
1f323d8b69
commit
36c52c6b73
2 files changed
+5
-2
No files matched your search
@@ -13,7 +13,7 @@ func CurlBasicAuth() *config.Rule {
|
|||||||
r := config.Rule{
|
r := config.Rule{
|
||||||
RuleID: "curl-auth-user",
|
RuleID: "curl-auth-user",
|
||||||
Description: "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource.",
|
Description: "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource.",
|
||||||
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
|
Regex: regexp.MustCompile(`\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})("(:[^"]{3,}|[^:"]{3,}:|[^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)`),
|
||||||
Keywords: []string{"curl"},
|
Keywords: []string{"curl"},
|
||||||
Entropy: 2,
|
Entropy: 2,
|
||||||
Allowlists: []config.Allowlist{
|
Allowlists: []config.Allowlist{
|
||||||
@@ -38,6 +38,8 @@ func CurlBasicAuth() *config.Rule {
|
|||||||
-H 'Content-type: text/plain' \
|
-H 'Content-type: text/plain' \
|
||||||
-d 'world' \
|
-d 'world' \
|
||||||
-u developer:yqDVtkqPECriaLRi`, // different line
|
-u developer:yqDVtkqPECriaLRi`, // different line
|
||||||
|
`curl -u ":d2LkV78zLx!t" https://localhost:9200`, // empty username
|
||||||
|
`curl -u "d2LkV78zLx!t:" https://localhost:9200`, // empty password
|
||||||
|
|
||||||
// long
|
// long
|
||||||
`curl -sw '%{http_code}' -X POST --user 'johns:h0pk1ns~21s' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
`curl -sw '%{http_code}' -X POST --user 'johns:h0pk1ns~21s' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
||||||
@@ -65,6 +67,7 @@ func CurlBasicAuth() *config.Rule {
|
|||||||
`curl -u "${_username}:${_password}"`,
|
`curl -u "${_username}:${_password}"`,
|
||||||
`curl -u "${username}":"${password}"`,
|
`curl -u "${username}":"${password}"`,
|
||||||
`curl -k -X POST -I -u "SRVC_JENKINS:${APPID}"`,
|
`curl -k -X POST -I -u "SRVC_JENKINS:${APPID}"`,
|
||||||
|
`curl -u ":" https://localhost:9200`, // empty username and password
|
||||||
|
|
||||||
// long
|
// long
|
||||||
`curl -sw '%{http_code}' -X POST --user '$USERNAME:$PASSWORD' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
`curl -sw '%{http_code}' -X POST --user '$USERNAME:$PASSWORD' $GItHUB_API_URL/$GIT_COMMIT --data`,
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ keywords = ["curl"]
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
id = "curl-auth-user"
|
id = "curl-auth-user"
|
||||||
description = "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource."
|
description = "Discovered a potential basic authorization token provided in a curl command, which could compromise the curl accessed resource."
|
||||||
regex = '''\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})(?:"([^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)'''
|
regex = '''\bcurl\b(?:.*|.*(?:[\r\n]{1,2}.*){1,5})[ \t\n\r](?:-u|--user)(?:=|[ \t]{0,5})("(:[^"]{3,}|[^:"]{3,}:|[^:"]{3,}:[^"]{3,})"|'([^:']{3,}:[^']{3,})'|((?:"[^"]{3,}"|'[^']{3,}'|[\w$@.-]+):(?:"[^"]{3,}"|'[^']{3,}'|[\w${}@.-]+)))(?:\s|\z)'''
|
||||||
entropy = 2
|
entropy = 2
|
||||||
keywords = ["curl"]
|
keywords = ["curl"]
|
||||||
[[rules.allowlists]]
|
[[rules.allowlists]]
|
||||||
|
|||||||
Reference in new issue
Block a user