mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-07 02:03:45 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -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) è presentato come un servizio gestito, semplificando il processo per gli utenti di **creare e gestire le chiavi master dei clienti** (CMK). Queste CMK sono fondamentali per la crittografia dei dati degli utenti. Una caratteristica notevole di AWS KMS è che le CMK sono prevalentemente **protette da moduli di sicurezza hardware** (HSM), migliorando la protezione delle chiavi di crittografia.
|
||||
|
||||
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 utilizza **crittografia simmetrica**. Questa viene utilizzata per **crittografare le informazioni a riposo** (ad esempio, all'interno di un S3). Se hai bisogno di **crittografare le informazioni in transito**, devi utilizzare qualcosa come **TLS**.
|
||||
|
||||
KMS is a **region specific service**.
|
||||
KMS è un **servizio specifico per regione**.
|
||||
|
||||
**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.
|
||||
**Gli amministratori di Amazon non hanno accesso alle tue chiavi**. Non possono recuperare le tue chiavi e non ti aiutano con la crittografia delle tue chiavi. AWS semplicemente amministra il sistema operativo e l'applicazione sottostante; spetta a noi amministrare le nostre chiavi di crittografia e gestire come vengono utilizzate.
|
||||
|
||||
**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.
|
||||
**Chiavi Master dei Clienti** (CMK): Possono crittografare dati fino a 4KB di dimensione. Sono tipicamente utilizzate per creare, crittografare e decrittografare le DEK (Data Encryption Keys). Poi le DEK vengono utilizzate per crittografare i dati.
|
||||
|
||||
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.
|
||||
Una chiave master dei clienti (CMK) è una rappresentazione logica di una chiave master in AWS KMS. Oltre agli identificatori della chiave master e ad altri metadati, inclusi la data di creazione, la descrizione e lo stato della chiave, una **CMK contiene il materiale della chiave utilizzato per crittografare e decrittografare i dati**. Quando crei una CMK, per impostazione predefinita, AWS KMS genera il materiale della chiave per quella CMK. Tuttavia, puoi scegliere di creare una CMK senza materiale della chiave e poi importare il tuo materiale della chiave in quella CMK.
|
||||
|
||||
There are 2 types of master keys:
|
||||
Ci sono 2 tipi di chiavi master:
|
||||
|
||||
- **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.
|
||||
- **CMK gestite da AWS: Utilizzate da altri servizi per crittografare i dati**. Viene utilizzata dal servizio che l'ha creata in una regione. Vengono create la prima volta che implementi la crittografia in quel servizio. Ruotano ogni 3 anni e non è possibile cambiarle.
|
||||
- **CMK gestite dal cliente**: Flessibilità, rotazione, accesso configurabile e politica delle chiavi. Abilita e disabilita le chiavi.
|
||||
|
||||
**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**.
|
||||
**Crittografia a Involucro** nel contesto del Key Management Service (KMS): Sistema gerarchico a due livelli per **crittografare i dati con la chiave dei dati e poi crittografare la chiave dei dati con la chiave master**.
|
||||
|
||||
### Key Policies
|
||||
### Politiche delle Chiavi
|
||||
|
||||
These defines **who can use and access a key in KMS**.
|
||||
Queste definiscono **chi può utilizzare e accedere a una chiave in KMS**.
|
||||
|
||||
By **default:**
|
||||
Per **impostazione predefinita:**
|
||||
|
||||
- It gives the **IAM of the** **AWS account that owns the KMS key access** to manage the access to the KMS key via IAM.
|
||||
- Fornisce all'**IAM dell'** **account AWS che possiede la chiave KMS accesso** per gestire l'accesso alla chiave KMS tramite IAM.
|
||||
|
||||
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.
|
||||
A differenza di altre politiche delle risorse AWS, una **politica della chiave KMS di AWS non concede automaticamente permessi a nessuno dei principi dell'account**. Per concedere permessi agli amministratori dell'account, **la politica della chiave deve includere una dichiarazione esplicita** che fornisca questo permesso, come questa.
|
||||
|
||||
- Without allowing the account(`"AWS": "arn:aws:iam::111122223333:root"`) IAM permissions won't work.
|
||||
- Senza consentire all'account(`"AWS": "arn:aws:iam::111122223333:root"`) i permessi IAM non funzioneranno.
|
||||
|
||||
- It **allows the account to use IAM policies** to allow access to the KMS key, in addition to the key policy.
|
||||
- **Consente all'account di utilizzare le politiche IAM** per consentire l'accesso alla chiave KMS, oltre alla politica della chiave.
|
||||
|
||||
**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.
|
||||
**Senza questo permesso, le politiche IAM che consentono l'accesso alla chiave sono inefficaci**, sebbene le politiche IAM che negano l'accesso alla chiave siano ancora efficaci.
|
||||
|
||||
- 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:
|
||||
- **Riduce il rischio che la chiave diventi ingovernabile** dando permessi di controllo accesso agli amministratori dell'account, incluso l'utente root dell'account, che non può essere eliminato.
|
||||
|
||||
**Esempio di politica predefinita**:
|
||||
```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**.
|
||||
> Se l'**account è autorizzato** (`"arn:aws:iam::111122223333:root"`), un **principale** dell'account **avrà comunque bisogno di permessi IAM** per utilizzare la chiave KMS. Tuttavia, se l'**ARN** di un ruolo, ad esempio, è **specificamente autorizzato** nella **Politica della Chiave**, quel ruolo **non ha bisogno di permessi IAM**.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Policy Details</summary>
|
||||
<summary>Dettagli della Politica</summary>
|
||||
|
||||
Properties of a policy:
|
||||
Proprietà di una politica:
|
||||
|
||||
- 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
|
||||
- Documento basato su JSON
|
||||
- Risorsa --> Risorse interessate (può essere "\*")
|
||||
- Azione --> kms:Encrypt, kms:Decrypt, kms:CreateGrant ... (permessi)
|
||||
- Effetto --> Consenti/Nega
|
||||
- Principale --> arn interessato
|
||||
- Condizioni (opzionale) --> Condizione per concedere i permessi
|
||||
|
||||
Grants:
|
||||
Concessioni:
|
||||
|
||||
- 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
|
||||
- Consente di delegare i propri permessi a un altro principale AWS all'interno del proprio account AWS. È necessario crearli utilizzando le API AWS KMS. Può essere indicato l'identificatore CMK, il principale beneficiario e il livello richiesto di operazione (Decrypt, Encrypt, GenerateDataKey...)
|
||||
- Dopo che la concessione è stata creata, vengono emessi un GrantToken e un GrantID
|
||||
|
||||
**Access**:
|
||||
**Accesso**:
|
||||
|
||||
- Via **key policy** -- If this exist, this takes **precedent** over the IAM policy
|
||||
- Via **IAM policy**
|
||||
- Via **grants**
|
||||
- Tramite **politica della chiave** -- Se esiste, questa ha **precedenza** sulla politica IAM
|
||||
- Tramite **politica IAM**
|
||||
- Tramite **concessioni**
|
||||
|
||||
</details>
|
||||
|
||||
### Key Administrators
|
||||
### Amministratori delle Chiavi
|
||||
|
||||
Key administrator by default:
|
||||
Amministratore delle chiavi per impostazione predefinita:
|
||||
|
||||
- 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
|
||||
- Ha accesso per gestire KMS ma non per crittografare o decrittografare dati
|
||||
- Solo gli utenti e i ruoli IAM possono essere aggiunti all'elenco degli Amministratori delle Chiavi (non i gruppi)
|
||||
- Se viene utilizzato un CMK esterno, gli Amministratori delle Chiavi hanno il permesso di importare materiale di chiave
|
||||
|
||||
### Rotation of CMKs
|
||||
### Rotazione dei CMK
|
||||
|
||||
- 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.
|
||||
- Più a lungo la stessa chiave rimane in uso, più dati vengono crittografati con quella chiave, e se quella chiave viene compromessa, allora l'area di esplosione dei dati è a rischio. Inoltre, più a lungo la chiave è attiva, maggiore è la probabilità che venga compromessa.
|
||||
- **KMS ruota le chiavi dei clienti ogni 365 giorni** (o puoi eseguire il processo manualmente quando vuoi) e **le chiavi gestite da AWS ogni 3 anni** e questo tempo non può essere cambiato.
|
||||
- **Le chiavi più vecchie vengono mantenute** per decrittografare i dati che sono stati crittografati prima della rotazione
|
||||
- In caso di compromissione, ruotare la chiave non rimuoverà la minaccia poiché sarà possibile decrittografare tutti i dati crittografati con la chiave compromessa. Tuttavia, i **nuovi dati saranno crittografati con la nuova chiave**.
|
||||
- Se il **CMK** è in stato di **disabilitato** o **in attesa di** **cancellazione**, KMS **non eseguirà una rotazione della chiave** fino a quando il CMK non sarà riattivato o la cancellazione non sarà annullata.
|
||||
|
||||
#### Manual rotation
|
||||
#### Rotazione manuale
|
||||
|
||||
- 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.
|
||||
- È necessario **creare un nuovo CMK**, quindi viene creato un nuovo CMK-ID, quindi dovrai **aggiornare** qualsiasi **applicazione** per **riferirsi** al nuovo CMK-ID.
|
||||
- Per semplificare questo processo, puoi **utilizzare alias per riferirti a un key-id** e poi semplicemente aggiornare la chiave a cui si riferisce l'alias.
|
||||
- Devi **mantenere le vecchie chiavi per decrittografare i vecchi file** crittografati con essa.
|
||||
|
||||
You can import keys from your on-premises key infrastructure .
|
||||
Puoi importare chiavi dalla tua infrastruttura di chiavi on-premises.
|
||||
|
||||
### Other relevant KMS information
|
||||
### Altre informazioni rilevanti su KMS
|
||||
|
||||
KMS is priced per number of encryption/decryption requests received from all services per month.
|
||||
KMS è tariffato in base al numero di richieste di crittografia/decrittografia ricevute da tutti i servizi al mese.
|
||||
|
||||
KMS has full audit and compliance **integration with CloudTrail**; this is where you can audit all changes performed on KMS.
|
||||
KMS ha una completa integrazione di audit e conformità **con CloudTrail**; qui puoi auditare tutte le modifiche effettuate su KMS.
|
||||
|
||||
With KMS policy you can do the following:
|
||||
Con la politica KMS puoi fare quanto segue:
|
||||
|
||||
- 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).
|
||||
- Limitare chi può creare chiavi dati e quali servizi hanno accesso a utilizzare queste chiavi
|
||||
- Limitare l'accesso ai sistemi per crittografare solo, decrittografare solo o entrambi
|
||||
- Definire per abilitare i sistemi ad accedere alle chiavi attraverso le regioni (anche se non è raccomandato poiché un guasto nella regione che ospita KMS influenzerà la disponibilità dei sistemi in altre regioni).
|
||||
|
||||
You cannot synchronize or move/copy keys across regions; you can only define rules to allow access across region.
|
||||
|
||||
### Enumeration
|
||||
Non puoi sincronizzare o spostare/copiare chiavi tra le regioni; puoi solo definire regole per consentire l'accesso tra le regioni.
|
||||
|
||||
### Enumerazione
|
||||
```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
|
||||
## Riferimenti
|
||||
|
||||
- [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}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user