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

This commit is contained in:
Translator
2024-12-31 20:20:29 +00:00
parent 77a009d308
commit 4bcd54c1b6
245 changed files with 9959 additions and 12700 deletions

View File

@@ -4,126 +4,123 @@
## KMS - Key Management Service
AWS Key Management Service (AWS KMS) is presented as a managed service, simplifying the process for users to **create and manage customer master keys** (CMKs). These CMKs are integral in the encryption of user data. A notable feature of AWS KMS is that CMKs are predominantly **secured by hardware security modules** (HSMs), enhancing the protection of the encryption keys.
AWS Key Management Service (AWS KMS) wird als verwalteter Dienst präsentiert, der den Prozess für Benutzer vereinfacht, **Kundenmaster-Schlüssel** (CMKs) zu **erstellen und zu verwalten**. Diese CMKs sind integraler Bestandteil der Verschlüsselung von Benutzerdaten. Ein bemerkenswertes Merkmal von AWS KMS ist, dass CMKs überwiegend **durch Hardware-Sicherheitsmodule** (HSMs) **gesichert** sind, was den Schutz der Verschlüsselungsschlüssel verbessert.
KMS uses **symmetric cryptography**. This is used to **encrypt information as rest** (for example, inside a S3). If you need to **encrypt information in transit** you need to use something like **TLS**.
KMS verwendet **symmetrische Kryptographie**. Dies wird verwendet, um **Informationen im Ruhezustand zu verschlüsseln** (zum Beispiel in einem S3). Wenn Sie **Informationen während der Übertragung verschlüsseln** müssen, müssen Sie etwas wie **TLS** verwenden.
KMS is a **region specific service**.
KMS ist ein **regionsspezifischer Dienst**.
**Administrators at Amazon do not have access to your keys**. They cannot recover your keys and they do not help you with encryption of your keys. AWS simply administers the operating system and the underlying application it's up to us to administer our encryption keys and administer how those keys are used.
**Administratoren bei Amazon haben keinen Zugriff auf Ihre Schlüssel**. Sie können Ihre Schlüssel nicht wiederherstellen und helfen Ihnen nicht bei der Verschlüsselung Ihrer Schlüssel. AWS verwaltet einfach das Betriebssystem und die zugrunde liegende Anwendung; es liegt an uns, unsere Verschlüsselungsschlüssel zu verwalten und zu steuern, wie diese Schlüssel verwendet werden.
**Customer Master Keys** (CMK): Can encrypt data up to 4KB in size. They are typically used to create, encrypt, and decrypt the DEKs (Data Encryption Keys). Then the DEKs are used to encrypt the data.
**Kundenmaster-Schlüssel** (CMK): Können Daten mit einer Größe von bis zu 4 KB verschlüsseln. Sie werden typischerweise verwendet, um die DEKs (Data Encryption Keys) zu erstellen, zu verschlüsseln und zu entschlüsseln. Dann werden die DEKs verwendet, um die Daten zu verschlüsseln.
A customer master key (CMK) is a logical representation of a master key in AWS KMS. In addition to the master key's identifiers and other metadata, including its creation date, description, and key state, a **CMK contains the key material which used to encrypt and decrypt data**. When you create a CMK, by default, AWS KMS generates the key material for that CMK. However, you can choose to create a CMK without key material and then import your own key material into that CMK.
Ein Kundenmaster-Schlüssel (CMK) ist eine logische Darstellung eines Master-Schlüssels in AWS KMS. Neben den Identifikatoren des Master-Schlüssels und anderen Metadaten, einschließlich seines Erstellungsdatums, seiner Beschreibung und seines Schlüsselsstatus, **enthält ein CMK das Schlüsselmateriel, das zur Verschlüsselung und Entschlüsselung von Daten verwendet wird**. Wenn Sie ein CMK erstellen, generiert AWS KMS standardmäßig das Schlüsselmateriel für dieses CMK. Sie können jedoch wählen, ein CMK ohne Schlüsselmateriel zu erstellen und dann Ihr eigenes Schlüsselmateriel in dieses CMK zu importieren.
There are 2 types of master keys:
Es gibt 2 Arten von Master-Schlüsseln:
- **AWS managed CMKs: Used by other services to encrypt data**. It's used by the service that created it in a region. They are created the first time you implement the encryption in that service. Rotates every 3 years and it's not possible to change it.
- **Customer manager CMKs**: Flexibility, rotation, configurable access and key policy. Enable and disable keys.
- **AWS verwaltete CMKs: Werden von anderen Diensten zur Verschlüsselung von Daten verwendet**. Es wird von dem Dienst verwendet, der es in einer Region erstellt hat. Sie werden beim ersten Mal erstellt, wenn Sie die Verschlüsselung in diesem Dienst implementieren. Wechselt alle 3 Jahre und es ist nicht möglich, es zu ändern.
- **Kundenverwaltete CMKs**: Flexibilität, Rotation, konfigurierbarer Zugriff und Schlüsselrichtlinie. Aktivieren und Deaktivieren von Schlüsseln.
**Envelope Encryption** in the context of Key Management Service (KMS): Two-tier hierarchy system to **encrypt data with data key and then encrypt data key with master key**.
**Envelope Encryption** im Kontext des Key Management Service (KMS): Zweistufiges Hierarchiesystem zur **Verschlüsselung von Daten mit einem Datenschlüssel und dann zur Verschlüsselung des Datenschlüssels mit einem Master-Schlüssel**.
### Key Policies
### Schlüsselrichtlinien
These defines **who can use and access a key in KMS**.
Diese definieren **wer einen Schlüssel in KMS verwenden und darauf zugreifen kann**.
By **default:**
**Standardmäßig:**
- It gives the **IAM of the** **AWS account that owns the KMS key access** to manage the access to the KMS key via IAM.
- Es gibt dem **IAM des** **AWS-Kontos, das den KMS-Schlüssel besitzt, Zugriff**, um den Zugriff auf den KMS-Schlüssel über IAM zu verwalten.
Unlike other AWS resource policies, a AWS **KMS key policy does not automatically give permission any of the principals of the account**. To give permission to account administrators, the **key policy must include an explicit statement** that provides this permission, like this one.
Im Gegensatz zu anderen AWS-Ressourcenrichtlinien gewährt eine AWS **KMS-Schlüsselrichtlinie nicht automatisch Berechtigungen an eines der Prinzipale des Kontos**. Um den Kontoadministratoren Berechtigungen zu gewähren, **muss die Schlüsselrichtlinie eine explizite Aussage enthalten**, die diese Berechtigung bereitstellt, wie diese hier.
- Without allowing the account(`"AWS": "arn:aws:iam::111122223333:root"`) IAM permissions won't work.
- Ohne die Erlaubnis des Kontos (`"AWS": "arn:aws:iam::111122223333:root"`) funktionieren IAM-Berechtigungen nicht.
- It **allows the account to use IAM policies** to allow access to the KMS key, in addition to the key policy.
- Es **erlaubt dem Konto, IAM-Richtlinien zu verwenden**, um den Zugriff auf den KMS-Schlüssel zusätzlich zur Schlüsselrichtlinie zu ermöglichen.
**Without this permission, IAM policies that allow access to the key are ineffective**, although IAM policies that deny access to the key are still effective.
**Ohne diese Berechtigung sind IAM-Richtlinien, die den Zugriff auf den Schlüssel erlauben, ineffektiv**, obwohl IAM-Richtlinien, die den Zugriff auf den Schlüssel verweigern, weiterhin wirksam sind.
- It **reduces the risk of the key becoming unmanageable** by giving access control permission to the account administrators, including the account root user, which cannot be deleted.
**Default policy** example:
- Es **verringert das Risiko, dass der Schlüssel unverwaltbar wird**, indem es den Kontoadministratoren, einschließlich des Root-Benutzers des Kontos, der nicht gelöscht werden kann, Berechtigungen zur Zugriffskontrolle gewährt.
**Beispiel für eine Standardrichtlinie:**
```json
{
"Sid": "Enable IAM policies",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:root"
},
"Action": "kms:*",
"Resource": "*"
"Sid": "Enable IAM policies",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:root"
},
"Action": "kms:*",
"Resource": "*"
}
```
> [!WARNING]
> If the **account is allowed** (`"arn:aws:iam::111122223333:root"`) a **principal** from the account **will still need IAM permissions** to use the KMS key. However, if the **ARN** of a role for example is **specifically allowed** in the **Key Policy**, that role **doesn't need IAM permissions**.
> Wenn das **Konto erlaubt ist** (`"arn:aws:iam::111122223333:root"`), benötigt ein **Principal** aus dem Konto **trotzdem IAM-Berechtigungen**, um den KMS-Schlüssel zu verwenden. Wenn jedoch die **ARN** einer Rolle beispielsweise im **Schlüsselrichtlinie** **speziell erlaubt** ist, benötigt diese Rolle **keine IAM-Berechtigungen**.
<details>
<summary>Policy Details</summary>
<summary>Richtliniendetails</summary>
Properties of a policy:
Eigenschaften einer Richtlinie:
- JSON based document
- Resource --> Affected resources (can be "\*")
- Action --> kms:Encrypt, kms:Decrypt, kms:CreateGrant ... (permissions)
- Effect --> Allow/Deny
- Principal --> arn affected
- Conditions (optional) --> Condition to give the permissions
- JSON-basiertes Dokument
- Ressource --> Betroffene Ressourcen (kann "\*")
- Aktion --> kms:Encrypt, kms:Decrypt, kms:CreateGrant ... (Berechtigungen)
- Effekt --> Erlauben/Verweigern
- Principal --> betroffene arn
- Bedingungen (optional) --> Bedingung zur Erteilung der Berechtigungen
Grants:
- Allow to delegate your permissions to another AWS principal within your AWS account. You need to create them using the AWS KMS APIs. It can be indicated the CMK identifier, the grantee principal and the required level of opoeration (Decrypt, Encrypt, GenerateDataKey...)
- After the grant is created a GrantToken and a GratID are issued
- Erlaubt es, Ihre Berechtigungen an einen anderen AWS-Principal innerhalb Ihres AWS-Kontos zu delegieren. Sie müssen sie mit den AWS KMS-APIs erstellen. Es kann der CMK-Identifikator, der berechtigte Principal und das erforderliche Niveau der Operation (Decrypt, Encrypt, GenerateDataKey...) angegeben werden.
- Nach der Erstellung des Grants werden ein GrantToken und eine GrantID ausgegeben.
**Access**:
**Zugriff**:
- Via **key policy** -- If this exist, this takes **precedent** over the IAM policy
- Via **IAM policy**
- Via **grants**
- Über **Schlüsselrichtlinie** -- Wenn diese existiert, hat sie **Vorrang** vor der IAM-Richtlinie.
- Über **IAM-Richtlinie**
- Über **Grants**
</details>
### Key Administrators
### Schlüsseladministratoren
Key administrator by default:
Schlüsseladministrator standardmäßig:
- Have access to manage KMS but not to encrypt or decrypt data
- Only IAM users and roles can be added to Key Administrators list (not groups)
- If external CMK is used, Key Administrators have the permission to import key material
- Haben Zugriff zur Verwaltung von KMS, jedoch nicht zum Verschlüsseln oder Entschlüsseln von Daten.
- Nur IAM-Benutzer und -Rollen können zur Liste der Schlüsseladministratoren hinzugefügt werden (keine Gruppen).
- Wenn eine externe CMK verwendet wird, haben Schlüsseladministratoren die Berechtigung, Schlüsselmaterial zu importieren.
### Rotation of CMKs
### Rotation von CMKs
- The longer the same key is left in place, the more data is encrypted with that key, and if that key is breached, then the wider the blast area of data is at risk. In addition to this, the longer the key is active, the probability of it being breached increases.
- **KMS rotate customer keys every 365 days** (or you can perform the process manually whenever you want) and **keys managed by AWS every 3 years** and this time it cannot be changed.
- **Older keys are retained** to decrypt data that was encrypted prior to the rotation
- In a break, rotating the key won't remove the threat as it will be possible to decrypt all the data encrypted with the compromised key. However, the **new data will be encrypted with the new key**.
- If **CMK** is in state of **disabled** or **pending** **deletion**, KMS will **not perform a key rotation** until the CMK is re-enabled or deletion is cancelled.
- Je länger derselbe Schlüssel an Ort und Stelle bleibt, desto mehr Daten werden mit diesem Schlüssel verschlüsselt, und wenn dieser Schlüssel kompromittiert wird, desto größer ist der Gefahrenbereich der betroffenen Daten. Darüber hinaus steigt die Wahrscheinlichkeit eines Angriffs, je länger der Schlüssel aktiv ist.
- **KMS rotiert Kundenschlüssel alle 365 Tage** (oder Sie können den Prozess manuell durchführen, wann immer Sie möchten) und **Schlüssel, die von AWS verwaltet werden, alle 3 Jahre**, und diese Zeit kann nicht geändert werden.
- **Ältere Schlüssel werden aufbewahrt**, um Daten zu entschlüsseln, die vor der Rotation verschlüsselt wurden.
- Bei einem Bruch wird die Rotation des Schlüssels die Bedrohung nicht beseitigen, da es möglich sein wird, alle Daten zu entschlüsseln, die mit dem kompromittierten Schlüssel verschlüsselt wurden. Allerdings werden **neue Daten mit dem neuen Schlüssel verschlüsselt**.
- Wenn die **CMK** im Zustand **deaktiviert** oder **in der Löschung** **ausstehend** ist, wird KMS **keine Schlüsselrotation durchführen**, bis die CMK wieder aktiviert oder die Löschung abgebrochen wird.
#### Manual rotation
#### Manuelle Rotation
- A **new CMK needs to be created**, then, a new CMK-ID is created, so you will need to **update** any **application** to **reference** the new CMK-ID.
- To do this process easier you can **use aliases to refer to a key-id** and then just update the key the alias is referring to.
- You need to **keep old keys to decrypt old files** encrypted with it.
- Eine **neue CMK muss erstellt werden**, dann wird eine neue CMK-ID erstellt, sodass Sie **jede Anwendung aktualisieren** müssen, um die neue CMK-ID **zu referenzieren**.
- Um diesen Prozess zu erleichtern, können Sie **Aliase verwenden, um auf eine Schlüssel-ID zu verweisen** und dann einfach den Schlüssel aktualisieren, auf den der Alias verweist.
- Sie müssen **alte Schlüssel aufbewahren, um alte Dateien** zu entschlüsseln, die damit verschlüsselt wurden.
You can import keys from your on-premises key infrastructure .
Sie können Schlüssel aus Ihrer lokalen Schlüssel-Infrastruktur importieren.
### Other relevant KMS information
### Weitere relevante KMS-Informationen
KMS is priced per number of encryption/decryption requests received from all services per month.
KMS wird nach der Anzahl der pro Monat von allen Diensten empfangenen Verschlüsselungs-/Entschlüsselungsanfragen berechnet.
KMS has full audit and compliance **integration with CloudTrail**; this is where you can audit all changes performed on KMS.
KMS hat eine vollständige Audit- und Compliance-**Integration mit CloudTrail**; hier können Sie alle Änderungen, die an KMS vorgenommen wurden, überprüfen.
With KMS policy you can do the following:
Mit der KMS-Richtlinie können Sie Folgendes tun:
- Limit who can create data keys and which services have access to use these keys
- Limit systems access to encrypt only, decrypt only or both
- Define to enable systems to access keys across regions (although it is not recommended as a failure in the region hosting KMS will affect availability of systems in other regions).
- Einschränken, wer Datenkeys erstellen kann und welche Dienste Zugriff auf diese Schlüssel haben.
- Den Zugriff von Systemen auf nur Verschlüsselung, nur Entschlüsselung oder beides einschränken.
- Definieren, um Systemen den Zugriff auf Schlüssel über Regionen hinweg zu ermöglichen (obwohl dies nicht empfohlen wird, da ein Ausfall in der Region, die KMS hostet, die Verfügbarkeit von Systemen in anderen Regionen beeinträchtigen wird).
You cannot synchronize or move/copy keys across regions; you can only define rules to allow access across region.
Sie können Schlüssel nicht über Regionen hinweg synchronisieren oder verschieben/kopieren; Sie können nur Regeln definieren, um den Zugriff über Regionen hinweg zu ermöglichen.
### Enumeration
```bash
aws kms list-keys
aws kms list-key-policies --key-id <id>
@@ -132,7 +129,6 @@ aws kms describe-key --key-id <id>
aws kms get-key-policy --key-id <id> --policy-name <name> # Default policy name is "default"
aws kms describe-custom-key-stores
```
### Privesc
{{#ref}}
@@ -151,12 +147,8 @@ aws kms describe-custom-key-stores
../aws-persistence/aws-kms-persistence.md
{{#endref}}
## References
## Referenzen
- [https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html](https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-default.html)
{{#include ../../../banners/hacktricks-training.md}}