Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition when creating/rotating keys (#123)
When we create/rotate keys using either the tangd-keygen and tangd-rotate-keys helpers, there is a small window between the keys being created and then the proper ownership permissions being set. This also happens when there are no keys and tang creates a pair of keys itself. In certain situations, such as the keys directory having wide open permissions, a user with local access could exploit this race condition and read the keys before they are set to more restrictive permissions. To prevent this issue, we now set the default umask to 0337 before creating the files, so that they are already created with restrictive permissions; afterwards, we set the proper ownership as usual. Issue reported by Brian McDermott of CENSUS labs. Fixes CVE-2023-1672 Reviewed-by: Sergio Arroutbi <sarroutb@redhat.com> Signed-off-by: Sergio Correia <scorreia@redhat.com>
- Loading branch information
8dbbed1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Sergio, having tested this patch previously, I can confirm it fixed the issue.