Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/

This commit is contained in:
Translator
2024-12-31 20:45:32 +00:00
parent ea3a11546a
commit 3c2f3f44a7
245 changed files with 9950 additions and 12671 deletions

View File

@@ -4,7 +4,7 @@
## What is Github
(From [here](https://kinsta.com/knowledgebase/what-is-github/)) At a high level, **GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code**.
(From [here](https://kinsta.com/knowledgebase/what-is-github/)) 高いレベルで、**GitHubは開発者がコードを保存・管理し、コードの変更を追跡・制御するのを助けるウェブサイトおよびクラウドベースのサービスです**。
### Basic Information
@@ -14,19 +14,19 @@ basic-github-information.md
## External Recon
Github repositories can be configured as public, private and internal.
Githubリポジトリは、公開、非公開、内部として設定できます。
- **Private** means that **only** people of the **organisation** will be able to access them
- **Internal** means that **only** people of the **enterprise** (an enterprise may have several organisations) will be able to access it
- **Public** means that **all internet** is going to be able to access it.
- **非公開**は、**組織**の人々だけがアクセスできることを意味します。
- **内部**は、**エンタープライズ**の人々(エンタープライズは複数の組織を持つことがあります)だけがアクセスできることを意味します。
- **公開**は、**全インターネット**がアクセスできることを意味します。
In case you know the **user, repo or organisation you want to target** you can use **github dorks** to find sensitive information or search for **sensitive information leaks** **on each repo**.
**ターゲットにしたいユーザー、リポジトリ、または組織を知っている場合**、**github dorks**を使用して、機密情報を見つけたり、**各リポジトリでの機密情報の漏洩**を検索できます。
### Github Dorks
Github allows to **search for something specifying as scope a user, a repo or an organisation**. Therefore, with a list of strings that are going to appear close to sensitive information you can easily **search for potential sensitive information in your target**.
Githubは、**ユーザー、リポジトリ、または組織をスコープとして指定して何かを検索することを許可します**。したがって、機密情報の近くに表示される文字列のリストを使用して、ターゲット内の**潜在的な機密情報を簡単に検索できます**。
Tools (each tool contains its list of dorks):
ツール各ツールにはそのdorkのリストが含まれています
- [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ([Dorks list](https://github.com/obheda12/GitDorker/tree/master/Dorks))
- [https://github.com/techgaun/github-dorks](https://github.com/techgaun/github-dorks) ([Dorks list](https://github.com/techgaun/github-dorks/blob/master/github-dorks.txt))
@@ -34,9 +34,9 @@ Tools (each tool contains its list of dorks):
### Github Leaks
Please, note that the github dorks are also meant to search for leaks using github search options. This section is dedicated to those tools that will **download each repo and search for sensitive information in them** (even checking certain depth of commits).
github dorksは、githubの検索オプションを使用して漏洩を検索するためにも使用されることに注意してください。このセクションは、**各リポジトリをダウンロードし、その中で機密情報を検索する**ツールに専念しています(特定のコミットの深さをチェックすることも含まれます)。
Tools (each tool contains its list of regexes):
ツール(各ツールにはその正規表現のリストが含まれています):
- [https://github.com/zricethezav/gitleaks](https://github.com/zricethezav/gitleaks)
- [https://github.com/trufflesecurity/truffleHog](https://github.com/trufflesecurity/truffleHog)
@@ -47,15 +47,15 @@ Tools (each tool contains its list of regexes):
- [https://github.com/awslabs/git-secrets](https://github.com/awslabs/git-secrets)
> [!WARNING]
> When you look for leaks in a repo and run something like `git log -p` don't forget there might be **other branches with other commits** containing secrets!
> リポジトリで漏洩を探すときに`git log -p`のようなコマンドを実行する際、**秘密を含む他のコミットがある他のブランチ**が存在する可能性があることを忘れないでください!
### External Forks
It's possible to **compromise repos abusing pull requests**. To know if a repo is vulnerable you mostly need to read the Github Actions yaml configs. [**More info about this below**](./#execution-from-a-external-fork).
**プルリクエストを悪用してリポジトリを妥協する**ことが可能です。リポジトリが脆弱かどうかを知るには、主にGithub Actionsyaml設定を読む必要があります。[**この下に詳細があります**](./#execution-from-a-external-fork)。
### Github Leaks in deleted/internal forks
Even if deleted or internal it might be possible to obtain sensitive data from forks of github repositories. Check it here:
削除されたり内部のものであっても、githubリポジトリのフォークから機密データを取得することが可能な場合があります。ここで確認してください
{{#ref}}
accessible-deleted-data-in-github.md
@@ -65,184 +65,172 @@ accessible-deleted-data-in-github.md
### Member Privileges
There are some **default privileges** that can be assigned to **members** of the organization. These can be controlled from the page `https://github.com/organizations/<org_name>/settings/member_privileges` or from the [**Organizations API**](https://docs.github.com/en/rest/orgs/orgs).
組織の**メンバー**に割り当てることができる**デフォルトの権限**があります。これらは、ページ`https://github.com/organizations/<org_name>/settings/member_privileges`または[**Organizations API**](https://docs.github.com/en/rest/orgs/orgs)から制御できます。
- **Base permissions**: Members will have the permission None/Read/write/Admin over the org repositories. Recommended is **None** or **Read**.
- **Repository forking**: If not necessary, it's better to **not allow** members to fork organization repositories.
- **Pages creation**: If not necessary, it's better to **not allow** members to publish pages from the org repos. If necessary you can allow to create public or private pages.
- **Integration access requests**: With this enabled outside collaborators will be able to request access for GitHub or OAuth apps to access this organization and its resources. It's usually needed, but if not, it's better to disable it.
- _I couldn't find this info in the APIs response, share if you do_
- **Repository visibility change**: If enabled, **members** with **admin** permissions for the **repository** will be able to **change its visibility**. If disabled, only organization owners can change repository visibilities. If you **don't** want people to make things **public**, make sure this is **disabled**.
- _I couldn't find this info in the APIs response, share if you do_
- **Repository deletion and transfer**: If enabled, members with **admin** permissions for the repository will be able to **delete** or **transfer** public and private **repositories.**
- _I couldn't find this info in the APIs response, share if you do_
- **Allow members to create teams**: If enabled, any **member** of the organization will be able to **create** new **teams**. If disabled, only organization owners can create new teams. It's better to have this disabled.
- _I couldn't find this info in the APIs response, share if you do_
- **More things can be configured** in this page but the previous are the ones more security related.
- **基本的な権限**: メンバーは、組織のリポジトリに対してNone/Read/write/Adminの権限を持ちます。推奨は**None**または**Read**です。
- **リポジトリのフォーク**: 必要でない場合、メンバーが組織のリポジトリをフォークすることを**許可しない方が良い**です。
- **ページの作成**: 必要でない場合、メンバーが組織のリポジトリからページを公開することを**許可しない方が良い**です。必要な場合は、公開または非公開のページを作成することを許可できます。
- **統合アクセス要求**: これを有効にすると、外部のコラボレーターがこの組織とそのリソースにアクセスするためのGitHubまたはOAuthアプリへのアクセスを要求できるようになります。通常は必要ですが、必要でない場合は無効にする方が良いです。
- _この情報をAPIの応答で見つけられませんでした。知っている場合は共有してください。_
- **リポジトリの可視性の変更**: 有効にすると、**リポジトリ**に対して**管理者**権限を持つ**メンバー**が**可視性を変更できる**ようになります。無効にすると、組織のオーナーのみがリポジトリの可視性を変更できます。人々に**公開**にすることを望まない場合は、これを**無効**にしてください。
- _この情報をAPIの応答で見つけられませんでした。知っている場合は共有してください。_
- **リポジトリの削除と転送**: 有効にすると、リポジトリに対して**管理者**権限を持つメンバーが**公開および非公開のリポジトリを削除**または**転送**できるようになります。
- _この情報をAPIの応答で見つけられませんでした。知っている場合は共有してください。_
- **メンバーがチームを作成することを許可**: 有効にすると、組織の**メンバー**は新しい**チームを作成**できるようになります。無効にすると、組織のオーナーのみが新しいチームを作成できます。これを無効にしておく方が良いです。
- _この情報をAPIの応答で見つけられませんでした。知っている場合は共有してください。_
- **このページで他の設定も可能ですが、前述のものが最もセキュリティに関連しています。**
### Actions Settings
Several security related settings can be configured for actions from the page `https://github.com/organizations/<org_name>/settings/actions`.
アクションに関するいくつかのセキュリティ関連の設定は、ページ`https://github.com/organizations/<org_name>/settings/actions`から設定できます。
> [!NOTE]
> Note that all this configurations can also be set on each repository independently
> これらの設定は、各リポジトリでも独立して設定できることに注意してください。
- **Github actions policies**: It allows you to indicate which repositories can tun workflows and which workflows should be allowed. It's recommended to **specify which repositories** should be allowed and not allow all actions to run.
- [**API-1**](https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization)**,** [**API-2**](https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization)
- **Fork pull request workflows from outside collaborators**: It's recommended to **require approval for all** outside collaborators.
- _I couldn't find an API with this info, share if you do_
- **Run workflows from fork pull requests**: It's highly **discouraged to run workflows from pull requests** as maintainers of the fork origin will be given the ability to use tokens with read permissions on the source repository.
- _I couldn't find an API with this info, share if you do_
- **Workflow permissions**: It's highly recommended to **only give read repository permissions**. It's discouraged to give write and create/approve pull requests permissions to avoid the abuse of the GITHUB_TOKEN given to running workflows.
- [**API**](https://docs.github.com/en/rest/actions/permissions#get-default-workflow-permissions-for-an-organization)
- **Githubアクションポリシー**: どのリポジトリがワークフローを実行でき、どのワークフローが許可されるべきかを指定できます。**許可されるリポジトリを指定する**ことを推奨し、すべてのアクションが実行されることを許可しない方が良いです。
- [**API-1**](https://docs.github.com/en/rest/actions/permissions#get-allowed-actions-and-reusable-workflows-for-an-organization)**,** [**API-2**](https://docs.github.com/en/rest/actions/permissions#list-selected-repositories-enabled-for-github-actions-in-an-organization)
- **外部コラボレーターからのフォークプルリクエストワークフロー**: すべての外部コラボレーターに対して**承認を要求する**ことを推奨します。
- _この情報を持つAPIは見つかりませんでした。知っている場合は共有してください。_
- **フォークプルリクエストからのワークフローの実行**: プルリクエストからのワークフローを実行することは非常に**推奨されません**。フォーク元のメンテナーにソースリポジトリの読み取り権限を持つトークンを使用する能力が与えられるためです。
- _この情報を持つAPIは見つかりませんでした。知っている場合は共有してください。_
- **ワークフローの権限**: **リポジトリの読み取り権限のみを付与する**ことを強く推奨します。GITHUB_TOKENが実行中のワークフローに与えられることを避けるために、書き込みおよびプルリクエストの作成/承認権限を与えることは推奨されません。
- [**API**](https://docs.github.com/en/rest/actions/permissions#get-default-workflow-permissions-for-an-organization)
### Integrations
_Let me know if you know the API endpoint to access this info!_
_この情報にアクセスするためのAPIエンドポイントを知っている場合は教えてください_
- **Third-party application access policy**: It's recommended to restrict the access to every application and allow only the needed ones (after reviewing them).
- **Installed GitHub Apps**: It's recommended to only allow the needed ones (after reviewing them).
- **サードパーティアプリケーションアクセスポリシー**: すべてのアプリケーションへのアクセスを制限し、必要なもののみを許可することを推奨します(レビュー後)。
- **インストールされたGitHubアプリ**: 必要なもののみを許可することを推奨します(レビュー後)。
## Recon & Attacks abusing credentials
For this scenario we are going to suppose that you have obtained some access to a github account.
このシナリオでは、githubアカウントへのアクセスを取得したと仮定します。
### With User Credentials
If you somehow already have credentials for a user inside an organization you can **just login** and check which **enterprise and organization roles you have**, if you are a raw member, check which **permissions raw members have**, in which **groups** you are, which **permissions you have** over which **repos,** and **how are the repos protected.**
もし何らかの方法で組織内のユーザーの資格情報を持っている場合、**ログインして**どの**エンタープライズおよび組織の役割を持っているか**を確認できます。生のメンバーであれば、**生のメンバーが持つ権限**、どの**グループ**に属しているか、どの**リポジトリに対してどの権限を持っているか**、および**リポジトリがどのように保護されているか**を確認できます。
Note that **2FA may be used** so you will only be able to access this information if you can also **pass that check**.
**2FAが使用されている可能性がある**ことに注意してください。したがって、そのチェックを**通過できる**場合にのみ、この情報にアクセスできます。
> [!NOTE]
> Note that if you **manage to steal the `user_session` cookie** (currently configured with SameSite: Lax) you can **completely impersonate the user** without needing credentials or 2FA.
> `user_session`クッキーを**盗むことに成功した場合**現在SameSite: Laxで設定されています、資格情報や2FAを必要とせずに**ユーザーを完全に偽装**できます。
Check the section below about [**branch protections bypasses**](./#branch-protection-bypass) in case it's useful.
役立つ場合に備えて、[**ブランチ保護のバイパス**](./#branch-protection-bypass)に関するセクションを確認してください。
### With User SSH Key
Github allows **users** to set **SSH keys** that will be used as **authentication method to deploy code** on their behalf (no 2FA is applied).
With this key you can perform **changes in repositories where the user has some privileges**, however you can not sue it to access github api to enumerate the environment. However, you can get **enumerate local settings** to get information about the repos and user you have access to:
Githubは、**ユーザー**が**SSHキー**を設定することを許可しており、これが**コードをデプロイするための認証方法**として使用されます2FAは適用されません
このキーを使用して、ユーザーがいくつかの権限を持つリポジトリで**変更を行う**ことができますが、github APIにアクセスして環境を列挙するために使用することはできません。ただし、アクセスできるリポジトリやユーザーに関する情報を取得するために、**ローカル設定を列挙する**ことができます。
```bash
# Go to the the repository folder
# Get repo config and current user name and email
git config --list
```
ユーザーが自分のGitHubユーザー名としてユーザー名を設定している場合、_https://github.com/\<github_username>.keys_ で彼のアカウントに設定された **公開鍵** にアクセスできます。これを確認して、見つけた秘密鍵が使用できるかどうかを確認できます。
If the user has configured its username as his github username you can access the **public keys he has set** in his account in _https://github.com/\<github_username>.keys_, you could check this to confirm the private key you found can be used.
**SSH鍵** はリポジトリに **デプロイ鍵** としても設定できます。この鍵にアクセスできる人は、**リポジトリからプロジェクトを起動する** ことができます。通常、異なるデプロイ鍵を持つサーバーでは、ローカルファイル **`~/.ssh/config`** が関連する鍵に関する情報を提供します。
**SSH keys** can also be set in repositories as **deploy keys**. Anyone with access to this key will be able to **launch projects from a repository**. Usually in a server with different deploy keys the local file **`~/.ssh/config`** will give you info about key is related.
#### GPG鍵
#### GPG Keys
As explained [**here**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/github-security/broken-reference/README.md) sometimes it's needed to sign the commits or you might get discovered.
Check locally if the current user has any key with:
[**こちら**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/github-security/broken-reference/README.md) で説明されているように、コミットに署名する必要がある場合や、発見される可能性があります。
現在のユーザーが鍵を持っているかどうかをローカルで確認してください:
```shell
gpg --list-secret-keys --keyid-format=long
```
### ユーザートークンを使用して
### With User Token
[**ユーザートークンについての基本情報を確認する**](basic-github-information.md#personal-access-tokens)の紹介。
For an introduction about [**User Tokens check the basic information**](basic-github-information.md#personal-access-tokens).
ユーザートークンは、HTTPS経由のGitの**パスワードの代わり**に使用できるか、[**基本認証を介してAPIに認証するために使用できます**](https://docs.github.com/v3/auth/#basic-authentication)。付与された権限に応じて、さまざまなアクションを実行できる場合があります。
A user token can be used **instead of a password** for Git over HTTPS, or can be used to [**authenticate to the API over Basic Authentication**](https://docs.github.com/v3/auth/#basic-authentication). Depending on the privileges attached to it you might be able to perform different actions.
ユーザートークンは次のようになります: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
A User token looks like this: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
### Oauthアプリケーションを使用して
### With Oauth Application
[**Github Oauthアプリケーションについての基本情報を確認する**](basic-github-information.md#oauth-applications)の紹介。
For an introduction about [**Github Oauth Applications check the basic information**](basic-github-information.md#oauth-applications).
攻撃者は、フィッシングキャンペーンの一環として、ユーザーが受け入れる可能性のある**悪意のあるOauthアプリケーション**を作成して、特権データ/アクションにアクセスすることがあります。
An attacker might create a **malicious Oauth Application** to access privileged data/actions of the users that accepts them probably as part of a phishing campaign.
これらは、Oauthアプリケーションが要求できる[スコープ](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps)です。受け入れる前に、要求されたスコープを常に確認する必要があります。
These are the [scopes an Oauth application can request](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps). A should always check the scopes requested before accepting them.
さらに、基本情報で説明されているように、**組織はサードパーティアプリケーションに対して情報/リポジトリ/アクションへのアクセスを与えたり拒否したりできます**。
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
### Githubアプリケーションを使用して
### With Github Application
[**Githubアプリケーションについての基本情報を確認する**](basic-github-information.md#github-applications)の紹介。
For an introduction about [**Github Applications check the basic information**](basic-github-information.md#github-applications).
攻撃者は、フィッシングキャンペーンの一環として、ユーザーが受け入れる可能性のある**悪意のあるGithubアプリケーション**を作成して、特権データ/アクションにアクセスすることがあります。
An attacker might create a **malicious Github Application** to access privileged data/actions of the users that accepts them probably as part of a phishing campaign.
さらに、基本情報で説明されているように、**組織はサードパーティアプリケーションに対して情報/リポジトリ/アクションへのアクセスを与えたり拒否したりできます**。
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
## Github Actionの妥協と悪用
## Compromise & Abuse Github Action
There are several techniques to compromise and abuse a Github Action, check them here:
Github Actionを妥協し悪用するためのいくつかの技術があります。ここで確認してください
{{#ref}}
abusing-github-actions/
{{#endref}}
## Branch Protection Bypass
## ブランチ保護のバイパス
- **Require a number of approvals**: If you compromised several accounts you might just accept your PRs from other accounts. If you just have the account from where you created the PR you cannot accept your own PR. However, if you have access to a **Github Action** environment inside the repo, using the **GITHUB_TOKEN** you might be able to **approve your PR** and get 1 approval this way.
- _Note for this and for the Code Owners restriction that usually a user won't be able to approve his own PRs, but if you are, you can abuse it to accept your PRs._
- **Dismiss approvals when new commits are pushed**: If this isnt set, you can submit legit code, wait till someone approves it, and put malicious code and merge it into the protected branch.
- **Require reviews from Code Owners**: If this is activated and you are a Code Owner, you could make a **Github Action create your PR and then approve it yourself**.
- When a **CODEOWNER file is missconfigured** Github doesn't complain but it does't use it. Therefore, if it's missconfigured it's **Code Owners protection isn't applied.**
- **Allow specified actors to bypass pull request requirements**: If you are one of these actors you can bypass pull request protections.
- **Include administrators**: If this isnt set and you are admin of the repo, you can bypass this branch protections.
- **PR Hijacking**: You could be able to **modify the PR of someone else** adding malicious code, approving the resulting PR yourself and merging everything.
- **Removing Branch Protections**: If you are an **admin of the repo you can disable the protections**, merge your PR and set the protections back.
- **Bypassing push protections**: If a repo **only allows certain users** to send push (merge code) in branches (the branch protection might be protecting all the branches specifying the wildcard `*`).
- If you have **write access over the repo but you are not allowed to push code** because of the branch protection, you can still **create a new branch** and within it create a **github action that is triggered when code is pushed**. As the **branch protection won't protect the branch until it's created**, this first code push to the branch will **execute the github action**.
- **承認の数を要求する**: 複数のアカウントを妥協した場合、他のアカウントからPRを受け入れることができます。PRを作成したアカウントしか持っていない場合、自分のPRを承認することはできません。しかし、リポジトリ内の**Github Action**環境にアクセスできる場合、**GITHUB_TOKEN**を使用して**PRを承認**し、この方法で1つの承認を得ることができるかもしれません。
- _この点とCode Owners制限についての注意: 通常、ユーザーは自分のPRを承認できませんが、もしできる場合は、それを悪用して自分のPRを受け入れることができます。_
- **新しいコミットがプッシュされたときに承認を取り消す**: これが設定されていない場合、正当なコードを提出し、誰かが承認するのを待ってから、悪意のあるコードを追加して保護されたブランチにマージすることができます。
- **Code Ownersからのレビューを要求する**: これが有効になっていて、あなたがCode Ownerであれば、**Github ActionがあなたのPRを作成し、あなた自身で承認することができます**。
- **CODEOWNERファイルが誤って設定されている場合**、Githubは文句を言いませんが、それを使用しません。したがって、誤って設定されている場合は、**Code Ownersの保護が適用されません。**
- **指定されたアクターがプルリクエストの要件をバイパスできるようにする**: あなたがこれらのアクターの1人であれば、プルリクエストの保護をバイパスできます。
- **管理者を含める**: これが設定されていない場合、リポジトリの管理者であれば、このブランチの保護をバイパスできます。
- **PRハイジャック**: 他の誰かのPRを**変更して悪意のあるコードを追加し、結果として得られたPRを自分で承認し、すべてをマージすることができるかもしれません。**
- **ブランチ保護の削除**: あなたが**リポジトリの管理者であれば、保護を無効にし、PRをマージして、再度保護を設定できます。**
- **プッシュ保護のバイパス**: リポジトリが**特定のユーザーのみ**がブランチにプッシュ(コードをマージ)できるようにしている場合(ブランチ保護がすべてのブランチを保護している可能性がありますが、ワイルドカード`*`を指定しています)。
- **リポジトリに対する書き込みアクセスがあるが、ブランチ保護のためにコードをプッシュできない場合**、新しいブランチを**作成し、その中でコードがプッシュされたときにトリガーされる**Github Actionを作成することができます。**ブランチ保護はブランチが作成されるまで保護しないため**、この最初のコードプッシュは**Github Actionを実行します**。
## Bypass Environments Protections
## 環境保護のバイパス
For an introduction about [**Github Environment check the basic information**](basic-github-information.md#git-environments).
[**Github環境についての基本情報を確認する**](basic-github-information.md#git-environments)の紹介。
In case an environment can be **accessed from all the branches**, it's **isn't protected** and you can easily access the secrets inside the environment. Note that you might find repos where **all the branches are protected** (by specifying its names or by using `*`) in that scenario, **find a branch were you can push code** and you can **exfiltrate** the secrets creating a new github action (or modifying one).
Note, that you might find the edge case where **all the branches are protected** (via wildcard `*`) it's specified **who can push code to the branches** (_you can specify that in the branch protection_) and **your user isn't allowed**. You can still run a custom github action because you can create a branch and use the push trigger over itself. The **branch protection allows the push to a new branch so the github action will be triggered**.
環境が**すべてのブランチからアクセス可能な場合**、それは**保護されていない**ため、環境内の秘密に簡単にアクセスできます。**すべてのブランチが保護されている**リポジトリ(名前を指定するか、`*`を使用することによって)を見つけることがあることに注意してください。その場合、**コードをプッシュできるブランチを見つけ**、新しいGithub Actionを作成することで秘密を**抽出**できますまたは1つを修正することができます
すべてのブランチが**保護されている**(ワイルドカード`*`を介して)場合、**誰がブランチにコードをプッシュできるかが指定されており**、**あなたのユーザーは許可されていない**というエッジケースがあることに注意してください。それでもカスタムGithub Actionを実行できます。なぜなら、ブランチを作成し、その上でプッシュトリガーを使用できるからです。**ブランチ保護は新しいブランチへのプッシュを許可するため、Github Actionがトリガーされます**。
```yaml
push: # Run it when a push is made to a branch
branches:
- current_branch_name #Use '**' to run when a push is made to any branch
branches:
- current_branch_name #Use '**' to run when a push is made to any branch
```
注意してください。**ブランチの作成後**、**ブランチ保護が新しいブランチに適用され**、変更することはできませんが、その時点で既に秘密をダンプしているでしょう。
Note that **after the creation** of the branch the **branch protection will apply to the new branch** and you won't be able to modify it, but for that time you will have already dumped the secrets.
## 永続性
## Persistence
- **ユーザートークン**を生成
- **シークレット**から**githubトークン**を盗む
- ワークフローの**結果**と**ブランチ**の**削除**
- **組織全体に対してより多くの権限を付与**
- 情報を外部に流出させるための**ウェブフック**を作成
- **外部コラボレーター**を招待
- **SIEM**によって使用される**ウェブフック**を**削除**
- **バックドア**を持つ**Github Action**を作成/変更
- **シークレット**値の変更を通じて**コマンドインジェクション**に脆弱な**Github Action**を見つける
- Generate **user token**
- Steal **github tokens** from **secrets**
- **Deletion** of workflow **results** and **branches**
- Give **more permissions to all the org**
- Create **webhooks** to exfiltrate information
- Invite **outside collaborators**
- **Remove** **webhooks** used by the **SIEM**
- Create/modify **Github Action** with a **backdoor**
- Find **vulnerable Github Action to command injection** via **secret** value modification
### 偽のコミット - リポジトリのコミットを通じたバックドア
### Imposter Commits - Backdoor via repo commits
In Github it's possible to **create a PR to a repo from a fork**. Even if the PR is **not accepted**, a **commit** id inside the orginal repo is going to be created for the fork version of the code. Therefore, an attacker **could pin to use an specific commit from an apparently ligit repo that wasn't created by the owner of the repo**.
Like [**this**](https://github.com/actions/checkout/commit/c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e):
Githubでは、**フォークからリポジトリにPRを作成**することが可能です。PRが**受け入れられなくても**、元のリポジトリ内にフォーク版のコードのための**コミット**IDが作成されます。したがって、攻撃者は**リポジトリの所有者によって作成されていない、見た目上正当なリポジトリから特定のコミットを使用するようにピン留めすることができる**かもしれません。
[**これのように**](https://github.com/actions/checkout/commit/c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e):
```yaml
name: example
on: [push]
jobs:
commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e
- shell: bash
run: |
echo 'hello world!'
commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@c7d749a2d57b4b375d1ebcd17cfbfb60c676f18e
- shell: bash
run: |
echo 'hello world!'
```
For more info check [https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd](https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd)
詳細については、[https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd](https://www.chainguard.dev/unchained/what-the-fork-imposter-commits-in-github-actions-and-ci-cd)を確認してください。
{{#include ../../banners/hacktricks-training.md}}