mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-06 17:53:37 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -2,128 +2,125 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## KMS - Key Management Service
|
||||
## KMS - Служба управління ключами
|
||||
|
||||
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 Служба управління ключами (AWS KMS) представлена як керована служба, що спрощує процес для користувачів **створювати та керувати основними ключами клієнта** (CMK). Ці CMK є невід'ємною частиною шифрування даних користувачів. Помітною особливістю AWS KMS є те, що CMK переважно **захищені апаратними модулями безпеки** (HSM), що підвищує захист шифрувальних ключів.
|
||||
|
||||
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 використовує **симетричну криптографію**. Це використовується для **шифрування інформації в спокої** (наприклад, всередині S3). Якщо вам потрібно **шифрувати інформацію в русі**, вам потрібно використовувати щось на зразок **TLS**.
|
||||
|
||||
KMS is a **region specific service**.
|
||||
KMS є **сервісом, специфічним для регіону**.
|
||||
|
||||
**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.
|
||||
**Адміністратори Amazon не мають доступу до ваших ключів**. Вони не можуть відновити ваші ключі і не допомагають вам з шифруванням ваших ключів. AWS просто адмініструє операційну систему та основний додаток, а нам потрібно адмініструвати наші шифрувальні ключі та контролювати, як ці ключі використовуються.
|
||||
|
||||
**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.
|
||||
**Основні ключі клієнта** (CMK): Можуть шифрувати дані розміром до 4KB. Вони зазвичай використовуються для створення, шифрування та дешифрування DEK (Ключі шифрування даних). Потім DEK використовуються для шифрування даних.
|
||||
|
||||
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.
|
||||
Основний ключ клієнта (CMK) є логічним представленням основного ключа в AWS KMS. На додаток до ідентифікаторів основного ключа та іншої метаданих, включаючи дату створення, опис та стан ключа, **CMK містить матеріал ключа, який використовується для шифрування та дешифрування даних**. Коли ви створюєте CMK, за замовчуванням AWS KMS генерує матеріал ключа для цього CMK. Однак ви можете вибрати створити CMK без матеріалу ключа, а потім імпортувати свій власний матеріал ключа в цей CMK.
|
||||
|
||||
There are 2 types of master keys:
|
||||
Існує 2 типи основних ключів:
|
||||
|
||||
- **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, керовані AWS: Використовуються іншими службами для шифрування даних**. Вони використовуються службою, яка їх створила в регіоні. Вони створюються перший раз, коли ви реалізуєте шифрування в цій службі. Обертаються кожні 3 роки, і їх неможливо змінити.
|
||||
- **CMK, керовані клієнтом**: Гнучкість, обертання, налаштовуваний доступ і політика ключів. Увімкнення та вимкнення ключів.
|
||||
|
||||
**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**.
|
||||
**Шифрування конвертів** в контексті Служби управління ключами (KMS): Двоярусна ієрархічна система для **шифрування даних за допомогою ключа даних, а потім шифрування ключа даних за допомогою основного ключа**.
|
||||
|
||||
### Key Policies
|
||||
### Політики ключів
|
||||
|
||||
These defines **who can use and access a key in KMS**.
|
||||
Ці політики визначають **хто може використовувати та отримувати доступ до ключа в KMS**.
|
||||
|
||||
By **default:**
|
||||
За **замовчуванням:**
|
||||
|
||||
- It gives the **IAM of the** **AWS account that owns the KMS key access** to manage the access to the KMS key via IAM.
|
||||
- Вона надає **IAM облікового запису AWS, який володіє ключем KMS доступ** для управління доступом до ключа KMS через 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.
|
||||
На відміну від інших політик ресурсів AWS, політика **ключа KMS не надає автоматично дозволу жодному з принципалів облікового запису**. Щоб надати дозвіл адміністраторам облікового запису, **політика ключа повинна містити явну заяву**, яка надає цей дозвіл, як ця.
|
||||
|
||||
- Without allowing the account(`"AWS": "arn:aws:iam::111122223333:root"`) IAM permissions won't work.
|
||||
- Без дозволу облікового запису(`"AWS": "arn:aws:iam::111122223333:root"`) дозволи IAM не працюватимуть.
|
||||
|
||||
- It **allows the account to use IAM policies** to allow access to the KMS key, in addition to the key policy.
|
||||
- Це **дозволяє обліковому запису використовувати політики IAM** для надання доступу до ключа KMS, на додаток до політики ключа.
|
||||
|
||||
**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.
|
||||
**Без цього дозволу політики IAM, які дозволяють доступ до ключа, є неефективними**, хоча політики IAM, які забороняють доступ до ключа, все ще є ефективними.
|
||||
|
||||
- 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:
|
||||
- Це **зменшує ризик того, що ключ стане некерованим**, надаючи дозвіл на контроль доступу адміністраторам облікового запису, включаючи кореневого користувача облікового запису, якого не можна видалити.
|
||||
|
||||
**Приклад політики за замовчуванням**:
|
||||
```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**.
|
||||
> Якщо **обліковому запису дозволено** (`"arn:aws:iam::111122223333:root"`), **суб'єкт** з облікового запису **все ще потребуватиме IAM дозволів** для використання KMS ключа. Однак, якщо **ARN** ролі, наприклад, **конкретно дозволено** в **Політиці ключа**, ця роль **не потребує IAM дозволів**.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Policy Details</summary>
|
||||
<summary>Деталі політики</summary>
|
||||
|
||||
Properties of a policy:
|
||||
Властивості політики:
|
||||
|
||||
- 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
|
||||
- Ресурс --> Підлягаючі ресурси (може бути "\*")
|
||||
- Дія --> kms:Encrypt, kms:Decrypt, kms:CreateGrant ... (дозволи)
|
||||
- Ефект --> Дозволити/Заборонити
|
||||
- Суб'єкт --> arn, що підлягає
|
||||
- Умови (необов'язково) --> Умова для надання дозволів
|
||||
|
||||
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
|
||||
- Дозволяє делегувати ваші дозволи іншому AWS суб'єкту у вашому обліковому записі AWS. Вам потрібно створити їх за допомогою AWS KMS API. Можна вказати ідентифікатор CMK, суб'єкт гранту та необхідний рівень операції (Decrypt, Encrypt, GenerateDataKey...)
|
||||
- Після створення гранту видаються GrantToken та GrantID
|
||||
|
||||
**Access**:
|
||||
**Доступ**:
|
||||
|
||||
- Via **key policy** -- If this exist, this takes **precedent** over the IAM policy
|
||||
- Via **IAM policy**
|
||||
- Via **grants**
|
||||
- Через **політику ключа** -- Якщо це існує, це має **пріоритет** над політикою IAM
|
||||
- Через **політику IAM**
|
||||
- Через **гранти**
|
||||
|
||||
</details>
|
||||
|
||||
### Key Administrators
|
||||
### Адміністратори ключів
|
||||
|
||||
Key administrator by default:
|
||||
Адміністратори ключів за замовчуванням:
|
||||
|
||||
- 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
|
||||
- Мають доступ для управління KMS, але не для шифрування або дешифрування даних
|
||||
- Тільки користувачі та ролі IAM можуть бути додані до списку Адміністраторів ключів (не групи)
|
||||
- Якщо використовується зовнішній CMK, Адміністратори ключів мають дозвіл на імпорт матеріалів ключа
|
||||
|
||||
### Rotation of CMKs
|
||||
### Ротація 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.
|
||||
- Чим довше той самий ключ залишається на місці, тим більше даних шифрується цим ключем, і якщо цей ключ буде зламано, то ширша зона ризику даних. Крім того, чим довше ключ активний, тим більше ймовірність його зламу.
|
||||
- **KMS ротує ключі клієнтів кожні 365 днів** (або ви можете виконати процес вручну, коли захочете) і **ключі, що керуються AWS, кожні 3 роки**, і цього разу змінити не можна.
|
||||
- **Старі ключі зберігаються** для дешифрування даних, які були зашифровані до ротації
|
||||
- У разі зламу, ротація ключа не усуне загрозу, оскільки буде можливість дешифрувати всі дані, зашифровані зламаним ключем. Однак, **нові дані будуть зашифровані новим ключем**.
|
||||
- Якщо **CMK** знаходиться в стані **вимкнено** або **в очікуванні** **видалення**, KMS **не виконає ротацію ключа**, поки CMK не буде повторно активовано або видалення не буде скасовано.
|
||||
|
||||
#### Manual 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.
|
||||
- Потрібно **створити новий CMK**, потім створюється новий CMK-ID, тому вам потрібно буде **оновити** будь-яку **застосунок**, щоб **посилатися** на новий CMK-ID.
|
||||
- Щоб спростити цей процес, ви можете **використовувати псевдоніми для посилання на key-id** і потім просто оновити ключ, на який посилається псевдонім.
|
||||
- Вам потрібно **зберігати старі ключі для дешифрування старих файлів**, зашифрованих з їх допомогою.
|
||||
|
||||
You can import keys from your on-premises key infrastructure .
|
||||
Ви можете імпортувати ключі з вашої локальної інфраструктури ключів.
|
||||
|
||||
### Other relevant KMS information
|
||||
### Інша релевантна інформація KMS
|
||||
|
||||
KMS is priced per number of encryption/decryption requests received from all services per month.
|
||||
KMS оцінюється за кількістю запитів на шифрування/дешифрування, отриманих від усіх служб за місяць.
|
||||
|
||||
KMS has full audit and compliance **integration with CloudTrail**; this is where you can audit all changes performed on KMS.
|
||||
KMS має повну аудиторську та комплаєнс **інтеграцію з CloudTrail**; тут ви можете перевірити всі зміни, виконані в KMS.
|
||||
|
||||
With KMS policy you can do the following:
|
||||
З політикою KMS ви можете зробити наступне:
|
||||
|
||||
- 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).
|
||||
- Обмежити, хто може створювати ключі даних і які служби мають доступ до використання цих ключів
|
||||
- Обмежити доступ систем до шифрування лише, дешифрування лише або обидва
|
||||
- Визначити, щоб системи могли отримувати доступ до ключів через регіони (хоча це не рекомендується, оскільки збій у регіоні, що хостить KMS, вплине на доступність систем в інших регіонах).
|
||||
|
||||
You cannot synchronize or move/copy keys across regions; you can only define rules to allow access across region.
|
||||
|
||||
### 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}}
|
||||
@@ -156,7 +152,3 @@ aws kms describe-custom-key-stores
|
||||
- [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