More rule fixes (#1586)

* feat: tweak more rules

* fix(curl): update pattern & ignore more stuff

* chore: update .gitleaksignore
This commit is contained in:
Richard Gomez authored and GitHub committed 2024-10-22 08:23:47 -05:00
1 parent 5407c44e0c
commit 455ae0aab7
47 files changed
+531 -374

No files matched your search

+21 -16
View File
@@ -13,10 +13,10 @@ import (
func SlackBotToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Identified a Slack Bot token, which may compromise bot integrations and communication channel security.",
RuleID: "slack-bot-token",
Regex: regexp.MustCompile(
`(xoxb-[0-9]{10,13}\-[0-9]{10,13}[a-zA-Z0-9-]*)`),
Description: "Identified a Slack Bot token, which may compromise bot integrations and communication channel security.",
Regex: regexp.MustCompile(`xoxb-[0-9]{10,13}-[0-9]{10,13}[a-zA-Z0-9-]*`),
Entropy: 3,
Keywords: []string{
"xoxb",
},
@@ -44,10 +44,11 @@ func SlackBotToken() *config.Rule {
func SlackUserToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Found a Slack User token, posing a risk of unauthorized user impersonation and data access within Slack workspaces.",
RuleID: "slack-user-token",
Description: "Found a Slack User token, posing a risk of unauthorized user impersonation and data access within Slack workspaces.",
// The last segment seems to be consistently 32 characters. I've made it 28-34 just in case.
Regex: regexp.MustCompile(`xox[pe](?:-[0-9]{10,13}){3}-[a-zA-Z0-9-]{28,34}`),
Entropy: 2,
Keywords: []string{"xoxp-", "xoxe-"},
}
@@ -82,10 +83,11 @@ func SlackUserToken() *config.Rule {
func SlackAppLevelToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Detected a Slack App-level token, risking unauthorized access to Slack applications and workspace data.",
RuleID: "slack-app-token",
Description: "Detected a Slack App-level token, risking unauthorized access to Slack applications and workspace data.",
// This regex is based on a limited number of examples and may not be 100% accurate.
Regex: regexp.MustCompile(`(?i)xapp-\d-[A-Z0-9]+-\d+-[a-z0-9]+`),
Entropy: 2,
Keywords: []string{"xapp"},
}
@@ -103,9 +105,10 @@ func SlackAppLevelToken() *config.Rule {
func SlackConfigurationToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Found a Slack Configuration access token, posing a risk to workspace configuration and sensitive data access.",
RuleID: "slack-config-access-token",
Description: "Found a Slack Configuration access token, posing a risk to workspace configuration and sensitive data access.",
Regex: regexp.MustCompile(`(?i)xoxe.xox[bp]-\d-[A-Z0-9]{163,166}`),
Entropy: 2,
Keywords: []string{"xoxe.xoxb-", "xoxe.xoxp-"},
}
@@ -128,9 +131,10 @@ func SlackConfigurationToken() *config.Rule {
func SlackConfigurationRefreshToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Discovered a Slack Configuration refresh token, potentially allowing prolonged unauthorized access to configuration settings.",
RuleID: "slack-config-refresh-token",
Description: "Discovered a Slack Configuration refresh token, potentially allowing prolonged unauthorized access to configuration settings.",
Regex: regexp.MustCompile(`(?i)xoxe-\d-[A-Z0-9]{146}`),
Entropy: 2,
Keywords: []string{"xoxe-"},
}
@@ -146,11 +150,11 @@ func SlackConfigurationRefreshToken() *config.Rule {
// Reference: https://api.slack.com/authentication/token-types#legacy_bot
func SlackLegacyBotToken() *config.Rule {
r := config.Rule{
Description: "Uncovered a Slack Legacy bot token, which could lead to compromised legacy bot operations and data exposure.",
RuleID: "slack-legacy-bot-token",
Description: "Uncovered a Slack Legacy bot token, which could lead to compromised legacy bot operations and data exposure.",
// This rule is based off the limited information I could find and may not be 100% accurate.
Regex: regexp.MustCompile(
`(xoxb-[0-9]{8,14}\-[a-zA-Z0-9]{18,26})`),
Regex: regexp.MustCompile(`xoxb-[0-9]{8,14}-[a-zA-Z0-9]{18,26}`),
Entropy: 2,
Keywords: []string{
"xoxb",
},
@@ -189,11 +193,11 @@ func SlackLegacyBotToken() *config.Rule {
// Reference: https://api.slack.com/authentication/token-types#workspace
func SlackLegacyWorkspaceToken() *config.Rule {
r := config.Rule{
Description: "Identified a Slack Legacy Workspace token, potentially compromising access to workspace data and legacy features.",
RuleID: "slack-legacy-workspace-token",
Description: "Identified a Slack Legacy Workspace token, potentially compromising access to workspace data and legacy features.",
// This is by far the least confident pattern.
Regex: regexp.MustCompile(
`(xox[ar]-(?:\d-)?[0-9a-zA-Z]{8,48})`),
Regex: regexp.MustCompile(`xox[ar]-(?:\d-)?[0-9a-zA-Z]{8,48}`),
Entropy: 2,
Keywords: []string{
"xoxa",
"xoxr",
@@ -224,9 +228,10 @@ func SlackLegacyWorkspaceToken() *config.Rule {
func SlackLegacyToken() *config.Rule {
// define rule
r := config.Rule{
Description: "Detected a Slack Legacy token, risking unauthorized access to older Slack integrations and user data.",
RuleID: "slack-legacy-token",
Description: "Detected a Slack Legacy token, risking unauthorized access to older Slack integrations and user data.",
Regex: regexp.MustCompile(`xox[os]-\d+-\d+-\d+-[a-fA-F\d]+`),
Entropy: 2,
Keywords: []string{"xoxo", "xoxs"},
}
@@ -255,11 +260,11 @@ func SlackLegacyToken() *config.Rule {
func SlackWebHookUrl() *config.Rule {
// define rule
r := config.Rule{
Description: "Discovered a Slack Webhook, which could lead to unauthorized message posting and data leakage in Slack channels.",
RuleID: "slack-webhook-url",
Description: "Discovered a Slack Webhook, which could lead to unauthorized message posting and data leakage in Slack channels.",
// If this generates too many false-positives we should define an allowlist (e.g., "xxxx", "00000").
Regex: regexp.MustCompile(
`(https?:\/\/)?hooks.slack.com\/(services|workflows)\/[A-Za-z0-9+\/]{43,46}`),
`(?:https?://)?hooks.slack.com/(?:services|workflows)/[A-Za-z0-9+/]{43,46}`),
Keywords: []string{
"hooks.slack.com",
},