Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: specify how caching CMM should handle max plaintext length in Get Encryption Materials #159

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

alex-chew
Copy link
Contributor

Issue #, if available: #80 and #81

Description of changes:

The Get Encryption Materials operation accepts an optional max plaintext length parameter, but the specification does not state how the caching CMM should behave when the caller does not provide the parameter value. This change specifies that the caching CMM should bypass the cache in this case.

Also, when the caching CMM is performing a Get Encryption Materials operation for which no materials are cached, it MUST call its underlying CMM's Get Encryption Materials operation. The specification does not state what value of max plaintext length (if any) the caching CMM should pass to its underlying CMM. This change specifies that the caching CMM should pass its byte limit value as the max plaintext length parameter of the call to the underlying CMM.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alex-chew alex-chew requested review from mattsb42-aws and lavaleri and removed request for mattsb42-aws July 15, 2020 16:28
@alex-chew alex-chew force-pushed the caching-cmm-max-plaintext-length branch 2 times, most recently from 43c69f3 to 7c824aa Compare July 15, 2020 16:54
@alex-chew alex-chew changed the title doc: specify how caching CMM should handle max plaintext length in Get Encryption Materials docs: specify how caching CMM should handle max plaintext length in Get Encryption Materials Jul 15, 2020
Copy link
Contributor

@lavaleri lavaleri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good! Some comments.

framework/caching-cmm.md Outdated Show resolved Hide resolved
framework/caching-cmm.md Outdated Show resolved Hide resolved
framework/caching-cmm.md Outdated Show resolved Hide resolved
and caches the materials that it receives.
If a later Get Encryption Materials operation fetches those materials from the cache,
but has a `max plaintext length` value that exceeds `N`,
then the caching CMM returns those materials unsafely.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we mean by "unsafely"? We should say exactly what we mean here. By passing N to the underlying CMM, this CMM is signaling to the underlying CMM that it intends to only use the returned materials to encrypt up to N bytes. By then reusing those materials such that when it reuses the materials it encrypts plaintext with length exceeding N, this CMM is violating it's previous intent. This violation is why this supposed approach is bad.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an edge case here is 2 CMMs share a CMC (and entries via partitions) but have different max bytes?
If I'm right, is this something to worry about? I don't think that the byte limit passed to the CMM is include in the entry, perhaps it should?

Say:

CMM A max bytes = 100K
CMM B max bytes = 200K

CMM A puts in an entry but then will never touch it again.
CMM B will use the entry to exhaustion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lavaleri thanks, I've incorporated your wording to clarify the explanation.

After a discussion with @lavaleri, @seebees, and @mattsb42-aws offline, we think that the edge case that @seebees described requires more thought to resolve properly, and doing so may require changes to other parts of this PR. So we are moving the PR to a later milestone.

Copy link
Contributor

@acioc acioc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. +1 to @lavaleri 's comments.

Comment on lines 24 to 25
| Python | 0.1.0-preview | 1.3.0 | [materials_managers/caching.py](https://github.com/aws/aws-encryption-sdk-python/blob/master/src/aws_encryption_sdk/materials_managers/caching.py) |
| Java | 0.1.0-preview | 1.3.0 | [CachingCryptoMaterialsManager.java](https://github.com/aws/aws-encryption-sdk-java/blob/master/src/main/java/com/amazonaws/encryptionsdk/caching/CachingCryptoMaterialsManager.java) |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure I understand this, is 1.3.0 the version of the ESDK? So Python and Java are on 1.3.0 while C and JS are both on 0.1.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand it, these lines state that the Python ESDK version 1.3.0 is the minimum version that is confirmed to be compatible with spec version 0.1.0-preview, and likewise for the Java ESDK. Similarly, the C ESDK version 0.1.0 is the minimum version that is confirmed to be compatible with spec 0.1.0-preview, and likewise for the JS ESDKs.

@acioc
Copy link
Contributor

acioc commented Jul 15, 2020

Quick follow up. Make sure not-grep and prettier both work. I suspect they're pending because of the force-push.

and caches the materials that it receives.
If a later Get Encryption Materials operation fetches those materials from the cache,
but has a `max plaintext length` value that exceeds `N`,
then the caching CMM returns those materials unsafely.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an edge case here is 2 CMMs share a CMC (and entries via partitions) but have different max bytes?
If I'm right, is this something to worry about? I don't think that the byte limit passed to the CMM is include in the entry, perhaps it should?

Say:

CMM A max bytes = 100K
CMM B max bytes = 200K

CMM A puts in an entry but then will never touch it again.
CMM B will use the entry to exhaustion.

Comment on lines +118 to +120
This change will break any customer use case
that depends on the Caching CMM passing no `max plaintext length` parameter
to the underlying CMM on Get Encryption Materials calls.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good call-out, but you don't actually mention anywhere that this is what implementations currently do.


## Security Implications

This change SHOULD NOT have any security implications.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because our current implementations do not pass a max plaintext length value to the underlying CMM, and this is changing to now pass the byte limit value instead, the security implications for the value received from the underlying CMM are changing. This is both a security and operational change, as the underlying CMM could be making security decisions based on the max plaintext length value (or absence); for example if it is another caching CMM.

## Guide-level Explanation

When making a Get Encryption Materials call to the caching CMM,
the user may optionally specify a value for the `max plaintext length` parameter,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the user may optionally specify a value for the `max plaintext length` parameter,
the user MAY optionally specify a value for the `max plaintext length` parameter,

Comment on lines +128 to +130
If the user does not specify a `max plaintext length` value,
then the caching CMM will neither use cached materials
nor cache materials from its underlying CMM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify this to say something along the lines of "the caching CMM will pass through to the underlying CMM without involving the cache".

Comment on lines +134 to +135
So whenever the user can determine an appropriate upper bound for bytes they will encrypt,
they should specify the `max plaintext length` value.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
So whenever the user can determine an appropriate upper bound for bytes they will encrypt,
they should specify the `max plaintext length` value.
If the user can determine an appropriate upper bound for bytes they will encrypt,
they SHOULD specify the `max plaintext length` value.

Comment on lines +137 to +141
If the user customizes the underlying CMM of a caching CMM,
then whenever the caching CMM makes a Get Encryption Materials call
to the customized underlying CMM,
the Encryption Materials Request will have a `max plaintext length` value
equal to the `byte limit` value configured on the caching CMM.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does "customizes the underlying CMM" mean in this case? This statement is true regardless of what underlying CMM you use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants