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

Encrypted walletstore and keystore #2426

Closed
wants to merge 3 commits into from
Closed

Conversation

mcdee
Copy link
Contributor

@mcdee mcdee commented Dec 4, 2019

No description provided.

@mcdee mcdee changed the title Initial version of encrypted store Encrypted walletstore and keystore #2426 Dec 4, 2019
@mcdee mcdee changed the title Encrypted walletstore and keystore #2426 Encrypted walletstore and keystore Dec 4, 2019

## Abstract

Ethereum [walletstore](https://eips.ethereum.org/EIPS/eip-2386) and [keystore](https://eips.ethereum.org/EIPS/eip-2335) files (hereafter just "stores") have various fields that some users may consider private (_e.g._ name, pubkey). In addition, there is always the risk of stores being stolen or made publicly accessible. To counteract potential issues this defines an encrypted format for stores.
Copy link
Member

Choose a reason for hiding this comment

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

https://eips.ethereum.org/EIPS/eip-2386

this link is a 404 for me

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see it references this: #2386 which is not merged yet

@paulmillr
Copy link
Contributor

@mcdee

  1. Why aes-ctr instead of aes-gcm?
  2. Why pbkdf2 instead of something else more modern?

@mcdee
Copy link
Contributor Author

mcdee commented Dec 9, 2019

@paulmillr main reason is because this is what is already used in the related ERCs, most especially #2335, so the same encryption/decryption code can be used for both.

@axic axic added the type: ERC label Dec 15, 2019
- iv: the initialization vector as generated above
- data: the store as supplied above

Finally, a _checksum_ is generated by appending the encrypted data to the last 16 bytes of the encryption key and calculating its [SHA-256](https://tools.ietf.org/html/rfc6234) hash.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not safe, use HMAC or AEAD instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for your comment. Please could you provide information regarding what specifically is unsafe so that it can be examined? Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can start by reading HMAC Design Principles

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm afraid I must ask again: what specifically is unsafe here?

Given the lack of information to date I will assume your concern is about a length extension attack on the checksum. However, the checksum is not a MAC: a successful length extension attack would not result in a valid keystore or walletstore, and as such would be immediately noticed.

If the concern is about something else please could you expand? And if my understanding above is incorrect please could you provide more detail? Thank you.

Copy link
Contributor

Choose a reason for hiding this comment

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

Your design is vulnerable to chosen cipher text attacks because the MAC can be forged by length extension. If you don't need to detect malicious modifications of the ciphertext before processing it then you don't need to include a secret in the hash input. If the modifications always result an invalid keystore then the impact of the potential attack is low but the impact can be higher in a future implementation with a slightly different use case. Chosen ciphertext attacks can have higher impact in Interactive systems or when they are used to create side channels.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your design is vulnerable to chosen cipher text attacks because the MAC can be forged by length extension.

But it's just a checksum, not a MAC.

If you don't need to detect malicious modifications of the ciphertext before processing it then you don't need to include a secret in the hash input.

This is true, but as per the spec it carries out the same process as #2335 to allow for re-use of code (hence less code hence easier testing).

If the modifications always result an invalid keystore then the impact of the potential attack is low but the impact can be higher in a future implementation with a slightly different use case.

This is true, although I don't see this being used elsewhere.

Paging @CarlBeek for his thoughts, as he's the author of #2335 and this vulnerability could have a higher impact there.

Encrypting the store requires the following information:

- the store to encrypt, which MUST be at least 16 bytes in length
- the passphrase, which MUST be at least 1 byte in length
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the point of accepting 1 byte "passphrases" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more of a "> 0" check, which catches many issues of bad coding where empty or null values are given as the passphrase. Picking an actual minimum passphrase length falls in to the realm of good security practice, which although important is not part of the ERC.

@github-actions
Copy link

github-actions bot commented Sep 8, 2020

There has been no activity on this pull request for two months. It will be closed in a week if no further activity occurs. If you would like to move this EIP forward, please respond to any outstanding feedback or add a comment indicating that you have addressed all required feedback and are ready for a review.

@github-actions github-actions bot added the stale label Sep 8, 2020
@github-actions
Copy link

This pull request was closed due to inactivity. If you are still pursuing it, feel free to reopen it and respond to any feedback or request a review in a comment.

@github-actions github-actions bot closed this Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants