Skip to content

Find the holes before someone else does. A fast, 100% Rust vulnerability scanner: XSS, SQL injection, leaked secrets, dependency CVEs and AI agent setups.

fix(secrets): detect GitLab deploy and pipeline trigger tokens (#152)

Brixton Pham76582695508c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6a07658..70d7a2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Unreleased
+- Secrets: `secret.gitlab-token` also finds GitLab deploy tokens (`gldt-` and 20 letters, digits, `_` or `-`)
+ and pipeline trigger tokens (`glptt-` and 40 lowercase hex).
- Secrets: `secret.slack-token` also finds Slack app-level tokens (`xapp-1-A0123...-1234567890123-` and
lowercase letters and digits), which let a Socket Mode app connect as the app. A bare `xapp-` stays quiet.
- Secrets: `secret.env-file` and `secret.env-example-value` stay on one line instead of matching
diff --git a/docs/rules.md b/docs/rules.md
index 33cc75f..0bfa9d8 100644
--- a/docs/rules.md
+++ b/docs/rules.md
@@ -39,7 +39,7 @@ Every rule safe-anything checks, generated from `safe-anything --list-rules --js
| [`secret.aws-access-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | An AWS access key id is written in the file. |
| [`secret.aws-secret-key`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | An AWS secret access key is written in the file. |
| [`secret.github-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A GitHub token is written in the file. |
-| [`secret.gitlab-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A GitLab personal access token is written in the file. |
+| [`secret.gitlab-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | critical | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A GitLab token is written in the file. |
| [`secret.slack-token`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Slack token is written in the file. |
| [`secret.slack-webhook`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Slack incoming webhook URL is written in the file. |
| [`secret.discord-webhook`](https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) | high | [CWE-798](https://cwe.mitre.org/data/definitions/798.html) | A07:2021 Identification and Authentication Failures | A Discord webhook URL is written in the file. |
diff --git a/src/rules/secrets.rs b/src/rules/secrets.rs
index 9b11fb5..479cdff 100644
--- a/src/rules/secrets.rs
+++ b/src/rules/secrets.rs
@@ -204,8 +204,8 @@ pub static RULES: &[Rule] = &[
secret!(
"secret.gitlab-token",
Critical,
- r"\bglpat-[0-9a-zA-Z_\-]{20}",
- "A GitLab personal access token is written in the file."
+ r"\b(?:gl(?:pat|dt)-[0-9a-zA-Z_\-]{20}|glptt-[0-9a-f]{40}\b)",
+ "A GitLab token is written in the file."
),
secret!(
"secret.slack-token",
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 7548cbc..79be9cd 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -26,6 +26,9 @@ pub fn fake(name: &str) -> String {
"aws-secret-example" => [&body(30, MIXED), "EXAMPLE", "KEY"].concat(),
"github" => ["gh", "p_", &body(36, MIXED)].concat(),
"gitlab" => ["gl", "pat-", &body(20, MIXED)].concat(),
+ "gitlab-deploy" => ["gl", "dt-", &body(20, MIXED)].concat(),
+ "gitlab-trigger" => ["gl", "ptt-", &body(40, HEX)].concat(),
+ "gitlab-trigger-upper" => ["gl", "ptt-", &body(40, HEX).to_uppercase()].concat(),
"github-pat" => ["github", "_pat_", &body(82, MIXED)].concat(),
"slack" => [
"xo",
diff --git a/tests/fixtures/secrets/EXPECTED b/tests/fixtures/secrets/EXPECTED
index fd9b00c..1502e58 100644
--- a/tests/fixtures/secrets/EXPECTED
+++ b/tests/fixtures/secrets/EXPECTED
@@ -59,3 +59,5 @@ config.py:72 secret.grafana-token
config.py:74 secret.doppler-token
config.py:76 secret.slack-token
config.py:78 secret.rubygems-token
+config.py:82 secret.gitlab-token
+config.py:84 secret.gitlab-token
diff --git a/tests/fixtures/secrets/config.py b/tests/fixtures/secrets/config.py
index b7fe461..b3bab34 100644
--- a/tests/fixtures/secrets/config.py
+++ b/tests/fixtures/secrets/config.py
@@ -79,3 +79,7 @@ rubygems = "{{fake:rubygems}}"
rubygems_short = "rubygems_0123abcd"
rubygems_upper = "{{fake:rubygems-upper}}"
rubygems_long = "{{fake:rubygems}}a"
+gitlab_deploy = "{{fake:gitlab-deploy}}"
+gitlab_deploy_lookalike = "gldt-short123 my{{fake:gitlab-deploy}}"
+gitlab_trigger = "{{fake:gitlab-trigger}}"
+gitlab_trigger_lookalike = "glptt-0123abcd {{fake:gitlab-trigger-upper}} {{fake:gitlab-trigger}}a"