Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashicorp Vault Token #625

Merged
merged 4 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 34 additions & 15 deletions credsweeper/rules/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,21 @@
- code
- doc

- name: Grafana Service Account Token
severity: high
confidence: strong
type: pattern
values:
- (?<![0-9A-Za-z_-])(?P<value>glsa_[0-9A-Za-z_-]{32}_[0-9A-Fa-f]{8})(?![0-9A-Za-z_-])
min_line_len: 46
filter_type:
- ValueGrafanaServiceCheck
required_substrings:
- glsa_
target:
- code
- doc

- name: Dropbox API secret (long term)
severity: high
confidence: weak
Expand Down Expand Up @@ -1235,6 +1250,24 @@
- code
- doc

- name: Hashicorp Vault Token
severity: high
confidence: strong
type: pattern
values:
- (?<![.0-9A-Za-z_-])(?P<value>hv[brs]\.[0-9A-Za-z_-]{80,160})
filter_type:
- ValuePatternCheck
- ValueEntropyBase64Check
min_line_len: 90
required_substring:
- hvb.
- hvr.
- hvs.
target:
- code
- doc

- name: Hashicorp Terraform Token
severity: high
confidence: strong
Expand All @@ -1243,6 +1276,7 @@
- (?<![.0-9A-Za-z_-])(?P<value>[0-9A-Za-z_-]{14}\.atlasv1\.[0-9A-Za-z_-]{67})(?![0-9A-Za-z_-])
filter_type:
- ValuePatternCheck
- ValueEntropyBase64Check
min_line_len: 90
required_substring:
- .atlasv1.
Expand Down Expand Up @@ -1351,21 +1385,6 @@
- code
- doc

- name: Grafana Service Account Token
severity: high
confidence: strong
type: pattern
values:
- (?<![0-9A-Za-z_-])(?P<value>glsa_[0-9A-Za-z_-]{32}_[0-9A-Fa-f]{8})(?![0-9A-Za-z_-])
min_line_len: 46
filter_type:
- ValueGrafanaServiceCheck
required_substrings:
- glsa_
target:
- code
- doc

- name: Tencent WeChat API App ID
severity: medium
confidence: weak
Expand Down
8 changes: 4 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
NEGLIGIBLE_ML_THRESHOLD = 0.0001

# credentials count after scan
SAMPLES_CRED_COUNT: int = 411
SAMPLES_CRED_LINE_COUNT: int = 429
SAMPLES_CRED_COUNT: int = 412
SAMPLES_CRED_LINE_COUNT: int = 430

# credentials count after post-processing
SAMPLES_POST_CRED_COUNT: int = 368
SAMPLES_POST_CRED_COUNT: int = 369

# with option --doc
SAMPLES_IN_DOC = 447
SAMPLES_IN_DOC = 448

# archived credentials that are not found without --depth
SAMPLES_IN_DEEP_1 = SAMPLES_POST_CRED_COUNT + 29
Expand Down
31 changes: 29 additions & 2 deletions tests/data/depth_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -7831,8 +7831,8 @@
{
"line": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 1,
"path": "./tests/samples/hashicorp_terraform",
"info": "./tests/samples/hashicorp_terraform|RAW",
"path": "./tests/samples/hashicorp",
"info": "./tests/samples/hashicorp|RAW",
"value": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
"value_end": 90,
Expand All @@ -7847,6 +7847,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Hashicorp Vault Token",
"severity": "high",
"confidence": "strong",
"line_data_list": [
{
"line": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 2,
"path": "./tests/samples/hashicorp",
"info": "./tests/samples/hashicorp|RAW",
"value": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
"value_end": 94,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64_CHARS",
"entropy": 5.346321090472658,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
31 changes: 29 additions & 2 deletions tests/data/doc.json
Original file line number Diff line number Diff line change
Expand Up @@ -11987,8 +11987,8 @@
{
"line": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 1,
"path": "./tests/samples/hashicorp_terraform",
"info": "./tests/samples/hashicorp_terraform|RAW",
"path": "./tests/samples/hashicorp",
"info": "./tests/samples/hashicorp|RAW",
"value": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
"value_end": 90,
Expand All @@ -12003,6 +12003,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Hashicorp Vault Token",
"severity": "high",
"confidence": "strong",
"line_data_list": [
{
"line": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 2,
"path": "./tests/samples/hashicorp",
"info": "./tests/samples/hashicorp|RAW",
"value": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
"value_end": 94,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64_CHARS",
"entropy": 5.346321090472658,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
29 changes: 28 additions & 1 deletion tests/data/ml_threshold.json
Original file line number Diff line number Diff line change
Expand Up @@ -8465,7 +8465,7 @@
{
"line": "8d92cc575673b937117a0bc2d9933296bc82695b5edfce134b6f4742d26132c5",
"line_num": 1,
"path": "./tests/samples/hashicorp_terraform",
"path": "./tests/samples/hashicorp",
"info": "",
"value": "8d92cc575673b937117a0bc2d9933296bc82695b5edfce134b6f4742d26132c5",
"value_start": 0,
Expand All @@ -8481,6 +8481,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Hashicorp Vault Token",
"severity": "high",
"confidence": "strong",
"line_data_list": [
{
"line": "ab065aa9aa644f0c7b24030e33468fcacd6c7f20140af08249fb744b1bbb7ccc",
"line_num": 2,
"path": "./tests/samples/hashicorp",
"info": "",
"value": "ab065aa9aa644f0c7b24030e33468fcacd6c7f20140af08249fb744b1bbb7ccc",
"value_start": 0,
"value_end": 94,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64_CHARS",
"entropy": 5.346321090472658,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
29 changes: 28 additions & 1 deletion tests/data/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -7412,7 +7412,7 @@
{
"line": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 1,
"path": "./tests/samples/hashicorp_terraform",
"path": "./tests/samples/hashicorp",
"info": "",
"value": "Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
Expand All @@ -7428,6 +7428,33 @@
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
"ml_probability": null,
"rule": "Hashicorp Vault Token",
"severity": "high",
"confidence": "strong",
"line_data_list": [
{
"line": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"line_num": 2,
"path": "./tests/samples/hashicorp",
"info": "",
"value": "hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0",
"value_start": 0,
"value_end": 94,
"variable": null,
"variable_start": -2,
"variable_end": -2,
"entropy_validation": {
"iterator": "BASE64_CHARS",
"entropy": 5.346321090472658,
"valid": true
}
}
]
},
{
"api_validation": "NOT_AVAILABLE",
"ml_validation": "NOT_AVAILABLE",
Expand Down
4 changes: 4 additions & 0 deletions tests/samples/hashicorp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Z28P3STmkBQi1Y.atlasv1.YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0
hvs.atlasv1-Z28P3STmkBQi1Y-YE7RBqu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0

FalseCase:iOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0RN3N5SEpsWSIsImtpZCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVRN3N5SEpsWSJ9/hvs.u6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0/iOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Imk2bEdrM0ZaenhSY1ViMu6VVyQIOq9a1eC3YFU5Elt7ToIr6OwzKAWlCTQ7N4gElXaWou6aPpOIwGCoc0kMzbkVRN3N5SEpsWSIsImtpZCI6Imk2bEdrM0ZaenhSY1ViMkMzbkVRN3N5SEpsWSJ9
1 change: 0 additions & 1 deletion tests/samples/hashicorp_terraform

This file was deleted.

Loading