aws / aws/aws-dynamodb-encryption-python

Upgrading "Do Nothing" model to one with a single action fails to decrypt old items

Open
#177 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
95
Forks
57
PR merge metrics
No merged PRs in 30d

Description

### Problem:

According to our documentation it should always be possible to add new attributes to our model without issue: https://docs.aws.amazon.com/dynamodb-encryption-client/latest/devguide/data-model.html#add-attribute

However, if you start with data encrypted using
```
actions = AttributeActions(
default_action=CryptoAction.DO_NOTHING
)
```

And update to using
```
actions = AttributeActions(
default_action=CryptoAction.DO_NOTHING, attribute_actions={"someNewField": CryptoAction.ENCRYPT_AND_SIGN}
)
```

You run into issues. This is because data under the first model doesn't have a material description or signature written with it. Once the model is updated to include an action other than `DO_NOTHING`, it always expects there to be a material description and signature, *even if the record it's attempting to decrypt doesn't include `someNewField` yet*.

### Solution:

We should probably update the logic here to also pass through if the item under decrypt specifically doesn't have attributes where encryption or signing is needed, even if the attributeActions includes an encrypt or sign action for a non-present field.

https://github.com/aws/aws-dynamodb-encryption-python/blob/25c7c3d80bfbe0deb661b4beb86f61b8b2f8545e/src/dynamodb_encryption_sdk/encrypted/item.py#L176-L178

https://github.com/aws/aws-dynamodb-encryption-python/blob/25c7c3d80bfbe0deb661b4beb86f61b8b2f8545e/src/dynamodb_encryption_sdk/structures.py#L137-L148

Contributor guide

Open the contributing guide

Research direction

Start in src/dynamodb_encryption_sdk/encrypted/item.py around lines 176-178 and src/dynamodb_encryption_sdk/structures.py around lines 137-148. Reproduce the transition from a DO_NOTHING-only AttributeActions model to one adding ENCRYPT_AND_SIGN for someNewField, then trace decryption of an older item without that field. Done means old items without attributes requiring encryption or signing can still be decrypted under the updated model.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.