mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-17 07:11:47 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -4,30 +4,29 @@
|
||||
|
||||
## DynamoDB
|
||||
|
||||
### Basic Information
|
||||
### Información Básica
|
||||
|
||||
Amazon DynamoDB is presented by AWS as a **fully managed, serverless, key-value NoSQL database**, tailored for powering high-performance applications regardless of their size. The service ensures robust features including inherent security measures, uninterrupted backups, automated replication across multiple regions, integrated in-memory caching, and convenient data export utilities.
|
||||
Amazon DynamoDB es presentado por AWS como una **base de datos NoSQL de clave-valor, completamente gestionada y sin servidor**, diseñada para impulsar aplicaciones de alto rendimiento sin importar su tamaño. El servicio garantiza características robustas que incluyen medidas de seguridad inherentes, copias de seguridad ininterrumpidas, replicación automatizada en múltiples regiones, almacenamiento en caché en memoria integrado y utilidades convenientes para la exportación de datos.
|
||||
|
||||
In the context of DynamoDB, instead of establishing a traditional database, **tables are created**. Each table mandates the specification of a **partition key** as an integral component of the **table's primary key**. This partition key, essentially a **hash value**, plays a critical role in both the retrieval of items and the distribution of data across various hosts. This distribution is pivotal for maintaining both scalability and availability of the database. Additionally, there's an option to incorporate a **sort key** to further refine data organization.
|
||||
En el contexto de DynamoDB, en lugar de establecer una base de datos tradicional, **se crean tablas**. Cada tabla requiere la especificación de una **clave de partición** como un componente integral de la **clave primaria de la tabla**. Esta clave de partición, esencialmente un **valor hash**, juega un papel crítico tanto en la recuperación de elementos como en la distribución de datos a través de varios hosts. Esta distribución es fundamental para mantener tanto la escalabilidad como la disponibilidad de la base de datos. Además, hay una opción para incorporar una **clave de ordenación** para refinar aún más la organización de los datos.
|
||||
|
||||
### Encryption
|
||||
### Cifrado
|
||||
|
||||
By default, DynamoDB uses a KMS key that \*\*belongs to Amazon DynamoDB,\*\*not even the AWS managed key that at least belongs to your account.
|
||||
Por defecto, DynamoDB utiliza una clave KMS que **pertenece a Amazon DynamoDB,** ni siquiera la clave gestionada por AWS que al menos pertenece a tu cuenta.
|
||||
|
||||
<figure><img src="https://lh4.googleusercontent.com/JjtNS7aA-_GRMgZb4v93jWEQJi6DQdUPq0FEpzZPdeyCeNoG05p0NJiV9Zs-ULs_-Tfjmx0W1ZgsE2Ui2ljo7D-1a87Xny-gpLVQO0XmXdFoph9ci1RepbVNwaCe9oPruEZSEDxGTxF5dIv6pW1WpT6kWA=s2048" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Backups & Export to S3
|
||||
### Copias de Seguridad y Exportación a S3
|
||||
|
||||
It's possible to **schedule** the generation of **table backups** or create them on **demand**. Moreover, it's also possible to enable **Point-in-time recovery (PITR) for a table.** Point-in-time recovery provides continuous **backups** of your DynamoDB data for **35 days** to help you protect against accidental write or delete operations.
|
||||
Es posible **programar** la generación de **copias de seguridad de tablas** o crearlas **a demanda**. Además, también es posible habilitar **la recuperación en el tiempo (PITR) para una tabla.** La recuperación en el tiempo proporciona **copias de seguridad** continuas de tus datos de DynamoDB durante **35 días** para ayudarte a protegerte contra operaciones de escritura o eliminación accidentales.
|
||||
|
||||
It's also possible to export **the data of a table to S3**, but the table needs to have **PITR enabled**.
|
||||
También es posible exportar **los datos de una tabla a S3**, pero la tabla debe tener **PITR habilitado**.
|
||||
|
||||
### GUI
|
||||
|
||||
There is a GUI for local Dynamo services like [DynamoDB Local](https://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development/), [dynalite](https://github.com/mhart/dynalite), [localstack](https://github.com/localstack/localstack), etc, that could be useful: [https://github.com/aaronshaf/dynamodb-admin](https://github.com/aaronshaf/dynamodb-admin)
|
||||
|
||||
### Enumeration
|
||||
Hay una GUI para servicios locales de Dynamo como [DynamoDB Local](https://aws.amazon.com/blogs/aws/dynamodb-local-for-desktop-development/), [dynalite](https://github.com/mhart/dynalite), [localstack](https://github.com/localstack/localstack), etc., que podría ser útil: [https://github.com/aaronshaf/dynamodb-admin](https://github.com/aaronshaf/dynamodb-admin)
|
||||
|
||||
### Enumeración
|
||||
```bash
|
||||
# Tables
|
||||
aws dynamodb list-tables
|
||||
@@ -36,7 +35,7 @@ aws dynamodb describe-table --table-name <t_name> #Get metadata info
|
||||
|
||||
#Check if point in time recovery is enabled
|
||||
aws dynamodb describe-continuous-backups \
|
||||
--table-name tablename
|
||||
--table-name tablename
|
||||
|
||||
# Backups
|
||||
aws dynamodb list-backups
|
||||
@@ -54,8 +53,7 @@ aws dynamodb describe-export --export-arn <arn>
|
||||
# Misc
|
||||
aws dynamodb describe-endpoints #Dynamodb endpoints
|
||||
```
|
||||
|
||||
### Unauthenticated Access
|
||||
### Acceso No Autenticado
|
||||
|
||||
{{#ref}}
|
||||
../aws-unauthenticated-enum-access/aws-dynamodb-unauthenticated-access.md
|
||||
@@ -67,116 +65,100 @@ aws dynamodb describe-endpoints #Dynamodb endpoints
|
||||
../aws-privilege-escalation/aws-dynamodb-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### Post Explotación
|
||||
|
||||
{{#ref}}
|
||||
../aws-post-exploitation/aws-dynamodb-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### Persistencia
|
||||
|
||||
{{#ref}}
|
||||
../aws-persistence/aws-dynamodb-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## DynamoDB Injection
|
||||
## Inyección de DynamoDB
|
||||
|
||||
### SQL Injection
|
||||
### Inyección SQL
|
||||
|
||||
There are ways to access DynamoDB data with **SQL syntax**, therefore, typical **SQL injections are also possible**.
|
||||
Hay formas de acceder a los datos de DynamoDB con **sintaxis SQL**, por lo tanto, **inyecciones SQL típicas también son posibles**.
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/sql-injection
|
||||
{{#endref}}
|
||||
|
||||
### NoSQL Injection
|
||||
### Inyección NoSQL
|
||||
|
||||
In DynamoDB different **conditions** can be used to retrieve data, like in a common NoSQL Injection if it's possible to **chain more conditions to retrieve** data you could obtain hidden data (or dump the whole table).\
|
||||
You can find here the conditions supported by DynamoDB: [https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html)
|
||||
En DynamoDB se pueden usar diferentes **condiciones** para recuperar datos, como en una inyección NoSQL común, si es posible **encadenar más condiciones para recuperar** datos, podrías obtener datos ocultos (o volcar toda la tabla).\
|
||||
Puedes encontrar aquí las condiciones soportadas por DynamoDB: [https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_Condition.html)
|
||||
|
||||
Note that **different conditions** are supported if the data is being accessed via **`query`** or via **`scan`**.
|
||||
Ten en cuenta que **diferentes condiciones** son soportadas si los datos se acceden a través de **`query`** o a través de **`scan`**.
|
||||
|
||||
> [!NOTE]
|
||||
> Actually, **Query** actions need to specify the **condition "EQ" (equals)** in the **primary** key to works, making it much **less prone to NoSQL injections** (and also making the operation very limited).
|
||||
|
||||
If you can **change the comparison** performed or add new ones, you could retrieve more data.
|
||||
> De hecho, las acciones de **Query** necesitan especificar la **condición "EQ" (igual)** en la **clave primaria** para funcionar, lo que las hace mucho **menos propensas a inyecciones NoSQL** (y también limita mucho la operación).
|
||||
|
||||
Si puedes **cambiar la comparación** realizada o agregar nuevas, podrías recuperar más datos.
|
||||
```bash
|
||||
# Comparators to dump the database
|
||||
"NE": "a123" #Get everything that doesn't equal "a123"
|
||||
"NOT_CONTAINS": "a123" #What you think
|
||||
"GT": " " #All strings are greater than a space
|
||||
```
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/nosql-injection
|
||||
{{#endref}}
|
||||
|
||||
### Raw Json injection
|
||||
### Inyección de Json en bruto
|
||||
|
||||
> [!CAUTION]
|
||||
> **This vulnerability is based on dynamodb Scan Filter which is now deprecated!**
|
||||
> **¡Esta vulnerabilidad se basa en el Filtro de Escaneo de dynamodb que ahora está obsoleto!**
|
||||
|
||||
**DynamoDB** accepts **Json** objects to **search** for data inside the DB. If you find that you can write in the json object sent to search, you could make the DB dump, all the contents.
|
||||
|
||||
For example, injecting in a request like:
|
||||
**DynamoDB** acepta objetos **Json** para **buscar** datos dentro de la base de datos. Si descubres que puedes escribir en el objeto json enviado para buscar, podrías hacer un volcado de la base de datos, todo el contenido.
|
||||
|
||||
Por ejemplo, inyectando en una solicitud como:
|
||||
```bash
|
||||
'{"Id": {"ComparisonOperator": "EQ","AttributeValueList": [{"N": "' + user_input + '"}]}}'
|
||||
```
|
||||
|
||||
an attacker could inject something like:
|
||||
un atacante podría inyectar algo como:
|
||||
|
||||
`1000"}],"ComparisonOperator": "GT","AttributeValueList": [{"N": "0`
|
||||
|
||||
fix the "EQ" condition searching for the ID 1000 and then looking for all the data with a Id string greater and 0, which is all.
|
||||
|
||||
Another **vulnerable example using a login** could be:
|
||||
arreglar la condición "EQ" buscando el ID 1000 y luego buscando todos los datos con una cadena de Id mayor que 0, que es todo.
|
||||
|
||||
Otro **ejemplo vulnerable usando un inicio de sesión** podría ser:
|
||||
```python
|
||||
scan_filter = """{
|
||||
"username": {
|
||||
"ComparisonOperator": "EQ",
|
||||
"AttributeValueList": [{"S": "%s"}]
|
||||
},
|
||||
"password": {
|
||||
"ComparisonOperator": "EQ",
|
||||
"AttributeValueList": [{"S": "%s"}]
|
||||
}
|
||||
"username": {
|
||||
"ComparisonOperator": "EQ",
|
||||
"AttributeValueList": [{"S": "%s"}]
|
||||
},
|
||||
"password": {
|
||||
"ComparisonOperator": "EQ",
|
||||
"AttributeValueList": [{"S": "%s"}]
|
||||
}
|
||||
}
|
||||
""" % (user_data['username'], user_data['password'])
|
||||
|
||||
dynamodb.scan(TableName="table-name", ScanFilter=json.loads(scan_filter))
|
||||
```
|
||||
|
||||
This would be vulnerable to:
|
||||
|
||||
Esto sería vulnerable a:
|
||||
```
|
||||
username: none"}],"ComparisonOperator": "NE","AttributeValueList": [{"S": "none
|
||||
password: none"}],"ComparisonOperator": "NE","AttributeValueList": [{"S": "none
|
||||
```
|
||||
|
||||
### :property Injection
|
||||
|
||||
Some SDKs allows to use a string indicating the filtering to be performed like:
|
||||
|
||||
Algunos SDK permiten usar una cadena que indica el filtrado que se debe realizar, como:
|
||||
```java
|
||||
new ScanSpec().withProjectionExpression("UserName").withFilterExpression(user_input+" = :username and Password = :password").withValueMap(valueMap)
|
||||
```
|
||||
Necesitas saber que al buscar en DynamoDB para **sustituir** un **valor** de atributo en **expresiones de filtro** mientras se escanean los elementos, los tokens deben **comenzar** con el carácter **`:`**. Tales tokens serán **reemplazados** con el **valor de atributo real en tiempo de ejecución**.
|
||||
|
||||
You need to know that searching in DynamoDB for **substituting** an attribute **value** in **filter expressions** while scanning the items, the tokens should **begin** with the **`:`** character. Such tokens will be **replaced** with actual **attribute value at runtime**.
|
||||
|
||||
Therefore, a login like the previous one can be bypassed with something like:
|
||||
|
||||
Por lo tanto, un inicio de sesión como el anterior puede ser eludido con algo como:
|
||||
```bash
|
||||
:username = :username or :username
|
||||
# This will generate the query:
|
||||
# :username = :username or :username = :username and Password = :password
|
||||
# which is always true
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user