mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-24 21:53:54 +00:00
GitBook: [#2872] update
This commit is contained in:
parent
34ea392656
commit
553ae9e27e
3 changed files with 103 additions and 6 deletions
|
@ -520,6 +520,7 @@
|
||||||
* [GCP - Databases Enumeration](cloud-security/gcp-security/gcp-databases-enumeration.md)
|
* [GCP - Databases Enumeration](cloud-security/gcp-security/gcp-databases-enumeration.md)
|
||||||
* [GCP - Serverless Code Exec Services Enumeration](cloud-security/gcp-security/gcp-serverless-code-exec-services-enumeration.md)
|
* [GCP - Serverless Code Exec Services Enumeration](cloud-security/gcp-security/gcp-serverless-code-exec-services-enumeration.md)
|
||||||
* [GCP - Buckets Enumeration](cloud-security/gcp-security/gcp-buckets-enumeration.md)
|
* [GCP - Buckets Enumeration](cloud-security/gcp-security/gcp-buckets-enumeration.md)
|
||||||
|
* [Github Security](cloud-security/github-security.md)
|
||||||
|
|
||||||
## Physical attacks
|
## Physical attacks
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ To start the tests you should have access with a user with **Reader permissions
|
||||||
It is recommended to **install azure-cli** in a **linux** and **windows** virtual machines (to be able to run powershell and python scripts): [https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)\
|
It is recommended to **install azure-cli** in a **linux** and **windows** virtual machines (to be able to run powershell and python scripts): [https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)\
|
||||||
Then, run `az login` to login. Note the **account information** and **token** will be **saved** inside _\<HOME>/.azure_ (in both Windows and Linux).
|
Then, run `az login` to login. Note the **account information** and **token** will be **saved** inside _\<HOME>/.azure_ (in both Windows and Linux).
|
||||||
|
|
||||||
Remember that if the **Security Centre Standard Pricing Tier** is being used and **not** the **free** tier, you can **generate** a **CIS compliance scan report** from the azure portal. Go to _Policy & Compliance-> Regulatory Compliance_ (or try to access [https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/22](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/22)).\
|
Remember that if the **Security Centre Standard Pricing Tier** is being used and **not** the **free** tier, you can **generate** a **CIS compliance scan report** from the azure portal. Go to _Policy & Compliance-> Regulatory Compliance_ (or try to access [https://portal.azure.com/#blade/Microsoft\_Azure\_Security/SecurityMenuBlade/22](https://portal.azure.com/#blade/Microsoft\_Azure\_Security/SecurityMenuBlade/22)).\
|
||||||
\__If the company is not paying for a Standard account you may need to review the **CIS Microsoft Azure Foundations Benchmark** by "hand" (you can get some help using the following tools). Download it from [**here**](https://www.newnettechnologies.com/cis-benchmark.html?keyword=\&gclid=Cj0KCQjwyPbzBRDsARIsAFh15JYSireQtX57C6XF8cfZU3JVjswtaLFJndC3Hv45YraKpLVDgLqEY6IaAhsZEALw_wcB#microsoft-azure).
|
\_\_If the company is not paying for a Standard account you may need to review the **CIS Microsoft Azure Foundations Benchmark** by "hand" (you can get some help using the following tools). Download it from [**here**](https://www.newnettechnologies.com/cis-benchmark.html?keyword=\&gclid=Cj0KCQjwyPbzBRDsARIsAFh15JYSireQtX57C6XF8cfZU3JVjswtaLFJndC3Hv45YraKpLVDgLqEY6IaAhsZEALw\_wcB#microsoft-azure).
|
||||||
|
|
||||||
### Run scanners
|
### Run scanners
|
||||||
|
|
||||||
|
@ -78,13 +78,13 @@ azscan #Run, login before with `az login`
|
||||||
|
|
||||||
### More checks
|
### More checks
|
||||||
|
|
||||||
* Check for a **high number of Global Admin** (between 2-4 are recommended). Access it on: [https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/Overview)
|
* Check for a **high number of Global Admin** (between 2-4 are recommended). Access it on: [https://portal.azure.com/#blade/Microsoft\_AAD\_IAM/ActiveDirectoryMenuBlade/Overview](https://portal.azure.com/#blade/Microsoft\_AAD\_IAM/ActiveDirectoryMenuBlade/Overview)
|
||||||
* Global admins should have MFA activated. Go to Users and click on Multi-Factor Authentication button.
|
* Global admins should have MFA activated. Go to Users and click on Multi-Factor Authentication button.
|
||||||
|
|
||||||
![](<../.gitbook/assets/image (293).png>)
|
![](<../.gitbook/assets/image (293).png>)
|
||||||
|
|
||||||
* Dedicated admin account shouldn't have mailboxes (they can only have mailboxes if they have Office 365).
|
* Dedicated admin account shouldn't have mailboxes (they can only have mailboxes if they have Office 365).
|
||||||
* Local AD shouldn't be sync with Azure AD if not needed([https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/AzureADConnect](https://portal.azure.com/#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/AzureADConnect)). And if synced Password Hash Sync should be enabled for reliability. In this case it's disabled:
|
* Local AD shouldn't be sync with Azure AD if not needed([https://portal.azure.com/#blade/Microsoft\_AAD\_IAM/ActiveDirectoryMenuBlade/AzureADConnect](https://portal.azure.com/#blade/Microsoft\_AAD\_IAM/ActiveDirectoryMenuBlade/AzureADConnect)). And if synced Password Hash Sync should be enabled for reliability. In this case it's disabled:
|
||||||
|
|
||||||
![](<../.gitbook/assets/image (294).png>)
|
![](<../.gitbook/assets/image (294).png>)
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ azscan #Run, login before with `az login`
|
||||||
|
|
||||||
![](<../.gitbook/assets/image (295).png>)
|
![](<../.gitbook/assets/image (295).png>)
|
||||||
|
|
||||||
* **Standard tier** is recommended instead of free tier (see the tier being used in _Pricing & Settings_ or in [https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/24](https://portal.azure.com/#blade/Microsoft_Azure_Security/SecurityMenuBlade/24))
|
* **Standard tier** is recommended instead of free tier (see the tier being used in _Pricing & Settings_ or in [https://portal.azure.com/#blade/Microsoft\_Azure\_Security/SecurityMenuBlade/24](https://portal.azure.com/#blade/Microsoft\_Azure\_Security/SecurityMenuBlade/24))
|
||||||
* **Periodic SQL servers scans**:
|
* **Periodic SQL servers scans**:
|
||||||
|
|
||||||
_Select the SQL server_ --> _Make sure that 'Advanced data security' is set to 'On'_ --> _Under 'Vulnerability assessment settings', set 'Periodic recurring scans' to 'On', and configure a storage account for storing vulnerability assessment scan results_ --> _Click Save_
|
_Select the SQL server_ --> _Make sure that 'Advanced data security' is set to 'On'_ --> _Under 'Vulnerability assessment settings', set 'Periodic recurring scans' to 'On', and configure a storage account for storing vulnerability assessment scan results_ --> _Click Save_
|
||||||
|
@ -108,3 +108,6 @@ Get objects in graph: [https://github.com/FSecureLABS/awspx](https://github.com/
|
||||||
|
|
||||||
## GPC
|
## GPC
|
||||||
|
|
||||||
|
{% content-ref url="gcp-security/" %}
|
||||||
|
[gcp-security](gcp-security/)
|
||||||
|
{% endcontent-ref %}
|
||||||
|
|
93
cloud-security/github-security.md
Normal file
93
cloud-security/github-security.md
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
# Github Security
|
||||||
|
|
||||||
|
## 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. To understand exactly what GitHub is, you need to know two connected principles:
|
||||||
|
|
||||||
|
* Version control
|
||||||
|
* Git
|
||||||
|
|
||||||
|
## External Recon
|
||||||
|
|
||||||
|
Github repositories can be configured as public, private and internal. 
|
||||||
|
|
||||||
|
* **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 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**.
|
||||||
|
|
||||||
|
Tools (each tool contains its list of dorks):
|
||||||
|
|
||||||
|
* [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))
|
||||||
|
* [https://github.com/hisxo/gitGraber](https://github.com/hisxo/gitGraber) ([Dorks list](https://github.com/hisxo/gitGraber/tree/master/wordlists))
|
||||||
|
|
||||||
|
### 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).
|
||||||
|
|
||||||
|
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)
|
||||||
|
* [https://github.com/eth0izzle/shhgit](https://github.com/eth0izzle/shhgit)
|
||||||
|
* [https://github.com/michenriksen/gitrob](https://github.com/michenriksen/gitrob)
|
||||||
|
* [https://github.com/anshumanbh/git-all-secrets](https://github.com/anshumanbh/git-all-secrets)
|
||||||
|
* [https://github.com/kootenpv/gittyleaks](https://github.com/kootenpv/gittyleaks)
|
||||||
|
* [https://github.com/awslabs/git-secrets](https://github.com/awslabs/git-secrets)
|
||||||
|
|
||||||
|
## Internal Recon
|
||||||
|
|
||||||
|
### Github Authentication
|
||||||
|
|
||||||
|
Github offers different ways to authenticate to your account and perform actions on your behalf.
|
||||||
|
|
||||||
|
* **Web access**: Accessing **github.com** you can login using your **username and password** (and a **2FA potentially**).
|
||||||
|
* **SSH Keys**: You can configure your account with one or several public keys allowing the related **private key to perform actions on your behalf.** [https://github.com/settings/keys](https://github.com/settings/keys)
|
||||||
|
|
||||||
|
#### **Personal Access Tokens**
|
||||||
|
|
||||||
|
You can generate personal access token to **give an application access to your account**. When creating a personal access token the **user** needs to **specify** the **permissions** to **token** will have. [https://github.com/settings/tokens](https://github.com/settings/tokens)
|
||||||
|
|
||||||
|
#### Oauth Applications
|
||||||
|
|
||||||
|
Oauth applications may ask you for permissions **to access part of your github information or to impersonate you** to perform some actions. A common example of this functionality is the **login with github button** you might find in some platforms.
|
||||||
|
|
||||||
|
* You can **create** your own **Oauth applications** in [https://github.com/settings/developers](https://github.com/settings/developers)
|
||||||
|
* You can see all the **Oauth applications that has access to your account** in [https://github.com/settings/applications](https://github.com/settings/applications)
|
||||||
|
* You can see the **scopes that Oauth Apps can ask for** in [https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps)
|
||||||
|
|
||||||
|
Some **security recommendations**:
|
||||||
|
|
||||||
|
* An **OAuth App** should always **act as the authenticated GitHub user across all of GitHub** (for example, when providing user notifications) and with access only to the specified scopes..
|
||||||
|
* An OAuth App can be used as an identity provider by enabling a "Login with GitHub" for the authenticated user.
|
||||||
|
* **Don't** build an **OAuth App** if you want your application to act on a **single repository**. With the `repo` OAuth scope, OAuth Apps can **act on **_**all**_** of the authenticated user's repositorie**s.
|
||||||
|
* **Don't** build an OAuth App to act as an application for your **team or company**. OAuth Apps authenticate as a **single user**, so if one person creates an OAuth App for a company to use, and then they leave the company, no one else will have access to it.
|
||||||
|
* **More** in [here](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-oauth-apps).
|
||||||
|
|
||||||
|
#### Github Applications
|
||||||
|
|
||||||
|
Github applications can ask for permissions to **access your github information or impersonate you** to perform specific actions over specific resources. In Github Apps you need to specify the repositories the app will have access to.
|
||||||
|
|
||||||
|
* To install a GitHub App, you must be an **organization owner or have admin permissions** in a repository.
|
||||||
|
* The GitHub App should **connect to a personal account or an organization**.
|
||||||
|
* You can create your own Github application in [https://github.com/settings/apps](https://github.com/settings/apps)
|
||||||
|
* You can see all the **Github applications that has access to your account** in [https://github.com/settings/apps/authorizations](https://github.com/settings/apps/authorizations)
|
||||||
|
|
||||||
|
Some security recommendations:
|
||||||
|
|
||||||
|
* A GitHub App should **take actions independent of a user** (unless the app is using a [user-to-server](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#user-to-server-requests) token). To keep user-to-server access tokens more secure, you can use access tokens that will expire after 8 hours, and a refresh token that can be exchanged for a new access token. For more information, see "[Refreshing user-to-server access tokens](https://docs.github.com/en/apps/building-github-apps/refreshing-user-to-server-access-tokens)."
|
||||||
|
* Make sure the GitHub App integrates with **specific repositories**.
|
||||||
|
* The GitHub App should **connect to a personal account or an organization**.
|
||||||
|
* Don't expect the GitHub App to know and do everything a user can.
|
||||||
|
* **Don't use a GitHub App if you just need a "Login with GitHub" service**. But a GitHub App can use a [user identification flow](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps) to log users in _and_ do other things.
|
||||||
|
* Don't build a GitHub App if you _only_ want to act as a GitHub user and do everything that user can do.
|
||||||
|
* If you are using your app with GitHub Actions and want to modify workflow files, you must authenticate on behalf of the user with an OAuth token that includes the `workflow` scope. The user must have admin or write permission to the repository that contains the workflow file. For more information, see "[Understanding scopes for OAuth apps](https://docs.github.com/en/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/#available-scopes)."
|
||||||
|
* **More** in [here](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-github-apps).
|
||||||
|
|
||||||
|
\
|
Loading…
Reference in a new issue