Package: release.debian.org Severity: normal Tags: bookworm User: release.debian....@packages.debian.org Usertags: pu X-Debbugs-Cc: t...@packages.debian.org Control: affects -1 + src:tang
[ Reason ] Fix https://security-tracker.debian.org/tracker/CVE-2023-1672 for Debian 12 ("bookworm"), tagged "no-dsa (minor)" by the security team. The problem of creating key material without restrictive file permissions probably existed upstream since always. Up to and including Debian 10 ("buster") however, this situation was caught by enforcing restrictive permissions on the key directory. With Debian 11 ("bullseye") a change in the creation of that directory caused it to be created with a too permissive mode. That will be addressed in a separature upload that requires more testing. For Debian 12 ("bookworm"), this request here, stricter permissions were already implemented and they are enforced during upgrade, however with a small window during installation of the package. [ Impact ] The small time window as mentioned above will stay. Also this would continue to put users at risk who configured a different key directory but did not enforce restrictive access permissions. [ Tests ] None that I'm aware of. [ Risks ] The changes are small and rather straight-forward. I'd be surprised if they introduce problems. [ Checklist ] [x] *all* changes are documented in the d/changelog [x] I reviewed all changes and I approve them [x] attach debdiff against the package in stable [x] the issue is verified as fixed in unstable (14.1) [ Changes ] * Assert restrictive permissions of the key directory in Debian's postinst. For regular users and new instaaltions. * Upstream's change to create the key file with restrictive permissions. Mostly for users who configure a different key directory. Regards, Christoph
diff -Nru tang-11/debian/changelog tang-11/debian/changelog --- tang-11/debian/changelog 2022-10-15 15:00:56.000000000 +0200 +++ tang-11/debian/changelog 2023-07-08 12:49:07.000000000 +0200 @@ -1,3 +1,11 @@ +tang (11-2+deb12u1) bookworm; urgency=medium + + * Fix CVE-2023-1672. Closes: #1038119 + - Cherry-pick "Fix race condition when creating/rotating keys" + - Assert restrictive permissions on tang's key directory + + -- Christoph Biedl <debian.a...@manchmal.in-ulm.de> Sat, 08 Jul 2023 12:49:07 +0200 + tang (11-2) unstable; urgency=medium * Tighten access permissions of the key directory diff -Nru tang-11/debian/patches/bookworm/1686750800.v13-3-g8dbbed1.fix-race-condition-when-creating-rotating-keys-123.patch tang-11/debian/patches/bookworm/1686750800.v13-3-g8dbbed1.fix-race-condition-when-creating-rotating-keys-123.patch --- tang-11/debian/patches/bookworm/1686750800.v13-3-g8dbbed1.fix-race-condition-when-creating-rotating-keys-123.patch 1970-01-01 01:00:00.000000000 +0100 +++ tang-11/debian/patches/bookworm/1686750800.v13-3-g8dbbed1.fix-race-condition-when-creating-rotating-keys-123.patch 2023-07-08 12:49:07.000000000 +0200 @@ -0,0 +1,66 @@ +Subject: Fix race condition when creating/rotating keys (#123) +Origin: v13-3-g8dbbed1 <https://github.com/latchset/tang/commit/v13-3-g8dbbed1> +Upstream-Author: Sergio Correia <scorr...@redhat.com> +Date: Wed Jun 14 10:53:20 2023 -0300 + + 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 <sarro...@redhat.com> + Signed-off-by: Sergio Correia <scorr...@redhat.com> + +--- a/src/keys.c ++++ b/src/keys.c +@@ -307,6 +307,9 @@ + { + const char* alg[] = {"ES512", "ECMR", NULL}; + char path[PATH_MAX]; ++ ++ /* Set default umask for file creation. */ ++ umask(0337); + for (int i = 0; alg[i] != NULL; i++) { + json_auto_t* jwk = jwk_generate(alg[i]); + if (!jwk) { +--- a/src/tangd-keygen.in ++++ b/src/tangd-keygen.in +@@ -38,6 +38,10 @@ + [ $# -eq 3 ] && sig=$2 && exc=$3 + + THP_DEFAULT_HASH=S256 # SHA-256. ++ ++# Set default umask for file creation. ++umask 0337 ++ + jwe=$(jose jwk gen -i '{"alg":"ES512"}') + [ -z "$sig" ] && sig=$(echo "$jwe" | jose jwk thp -i- -a "${THP_DEFAULT_HASH}") + echo "$jwe" > "$1/$sig.jwk" +--- a/src/tangd-rotate-keys.in ++++ b/src/tangd-rotate-keys.in +@@ -79,6 +79,10 @@ + + # Create a new set of keys. + DEFAULT_THP_HASH="S256" ++ ++ # Set default umask for file creation. ++ umask 0337 ++ + for alg in "ES512" "ECMR"; do + json="$(printf '{"alg": "%s"}' "${alg}")" + jwe="$(jose jwk gen --input "${json}")" diff -Nru tang-11/debian/patches/series tang-11/debian/patches/series --- tang-11/debian/patches/series 2022-01-01 00:56:31.000000000 +0100 +++ tang-11/debian/patches/series 2023-07-08 12:49:07.000000000 +0200 @@ -10,3 +10,7 @@ debian/2021-04-19.non-usrmerged.patch debian/2021-09-30.use-var-lib.patch debian/2021-09-30.xinetd-support.patch + +# cherry-picked after the stable release +# CVE-2023-1672 +bookworm/1686750800.v13-3-g8dbbed1.fix-race-condition-when-creating-rotating-keys-123.patch diff -Nru tang-11/debian/tang-common.postinst tang-11/debian/tang-common.postinst --- tang-11/debian/tang-common.postinst 2022-02-16 08:23:31.000000000 +0100 +++ tang-11/debian/tang-common.postinst 2023-07-08 12:49:07.000000000 +0200 @@ -33,8 +33,9 @@ fi # assert db directory - mkdir -p "$DB_DIR" + mkdir -m0750 -p "$DB_DIR" chown _tang:_tang "$DB_DIR" + # assert restrictive permissions upon upgrade chmod 0750 "$DB_DIR" ;;
signature.asc
Description: PGP signature