Skip to content

[pull] master from dfinity:master - #4

Merged
pull[bot] merged 1 commit into
bit-cook:masterfrom
dfinity:master
Aug 5, 2021
Merged

pull[bot] merged 1 commit into
bit-cook:masterfrom
dfinity:master

Conversation

@pull

@pull pull Bot commented Aug 5, 2021 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

@pull pull Bot added the ⤵️ pull label Aug 5, 2021
@pull
pull Bot merged commit 074feaa into bit-cook:master Aug 5, 2021
pull Bot pushed a commit that referenced this pull request May 3, 2023
… 'master'

feat(crypto) CRP-1894: Zeroize old secret key store when writing new content

The way the SKS is currently updated is as follows:

1. On startup, the SKS is read from disk, and maintained in memory.
2. If changes are made to the SKS (new key generated, old key deleted), the changes are made in memory, and then written to disk. The writing to disk is performed as follows:
    1. Write the updated SKS to a new, temporary file.
    2. Atomically replace the existing SKS by moving/renaming the new SKS to the location of the existing SKS.

To zeroize the old SKS, the proposed approach when writing the new SKS to disk is as follows:

1. Create a hard link to the old SKS - same path and filename, but with “.old” suffix
2. Write the new SKS to disk using the temporary file and rename to replace the existing SKS as above.
3. Zeroize the old SKS file using the hard link created in step #1.
4. Remove the hard link created in step #1.

In case the node/process crashes while writing the new SKS (in practice, somewhere after step #1 but before step #4), some cleanup needs to be done:

- If the crash happened after #1 but before #2, the hard link with the “.old” suffix will point to the current SKS - in this case, simply remove the hard link to the SKS, but do not zeroize it.
- If the crash happened after #2, perform steps #3 and #4 from above (zeroize the old file and delete it).
 
The cleanup can be done when opening the SKS to read it. To determine which of the two cleanup actions should be done, check to see if a hard link with “.old” suffix exists, and if so, if it points to the same file (inode) as the current SKS - if yes, zeroize and delete the “.old” file; if no, simply delete the “.old” file.

One scenario where this zeroization introduces a new security exposure is in case we crash between steps #2 and #3 above, where the new keystore has been written, but there is still a hard link to the old keystore, and the old keystore has not been zeroized. 

See merge request dfinity-lab/public/ic!10724
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant