Skip to content

Commit bffd8c6

Browse files
fix: reject start.sh downloads signed by a revoked or expired key (#7090)
1 parent 82138d5 commit bffd8c6

2 files changed

Lines changed: 20 additions & 8 deletions

File tree

‎shell.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The script is available in the java-tron project at [github](https://github.com/
1010

1111
The script runs on x86_64 with JDK 8 and on ARM64 with JDK 17. It picks the JVM options for the Java version it finds, and downloads the release jars built for that architecture (`FullNode-aarch64.jar` on ARM64).
1212

13-
Downloaded release jars are verified against the GPG signature published with each release, made by the key listed under "Integrity Check" in the [README](./README.md), so `gpg` must be installed; a jar that fails verification is not used. The mainnet config is downloaded from java-tron and the Nile testnet config from [nile-testnet](https://github.com/tron-nile-testnet/nile-testnet).
13+
Downloaded release jars are verified against the GPG signature published with each release, made by the key listed under "Integrity Check" in the [README](./README.md), so `gpg` must be installed; a jar that fails verification is not used. A signature made by a revoked or expired release key fails verification. The mainnet config is downloaded from java-tron and the Nile testnet config from [nile-testnet](https://github.com/tron-nile-testnet/nile-testnet).
1414

1515
For each download the release key is fetched by its fingerprint from keys.openpgp.org, or from keyserver.ubuntu.com if the first server does not answer, so installing a release jar needs outbound HTTPS access (port 443) to one of these key servers. If neither can be reached, the signature cannot be checked and the downloaded jar is removed.
1616

‎start.sh‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,18 @@ specifyConfig(){
787787
}
788788

789789
# Verifies file $3 against the signature of asset $2 in release $1, which must be made
790-
# by the release key. Removes $3 if the signature is missing or invalid.
790+
# by the release key. Removes $3 if the signature is missing or invalid, or if the release
791+
# key is revoked or expired.
791792
checkSign() {
792793
info 'verify signature'
793794
local version=$1
794795
local asset=$2
795796
local file=$3
796797
local gnupg_home
797798
local server
799+
local status
800+
# gpg names the key of a signature by its long key id, the last 16 digits of the fingerprint.
801+
local key="(${RELEASE_KEY_FINGERPRINT: -16}|$RELEASE_KEY_FINGERPRINT)"
798802
local verified=false
799803
if type gpg >/dev/null 2>&1; then
800804
# Use a temporary keyring, so that the user's keyring is neither read nor changed.
@@ -806,12 +810,20 @@ checkSign() {
806810
gpg --homedir "$gnupg_home" --batch --quiet --keyserver "$server" \
807811
--keyserver-options timeout=10 --recv-keys "$RELEASE_KEY_FINGERPRINT" >/dev/null 2>&1 && break
808812
done
809-
# Download the detached signature. Only a VALIDSIG status line that carries the release
810-
# key fingerprint counts as verified.
811-
if download "$RELEASE_URL/download/$version/$asset.sig" "$file.sig" \
812-
&& gpg --homedir "$gnupg_home" --batch --status-fd 1 --verify "$file.sig" "$file" 2>/dev/null \
813-
| grep '^\[GNUPG:\] VALIDSIG ' | grep -q -w "$RELEASE_KEY_FINGERPRINT"; then
814-
verified=true
813+
# Download the detached signature. It counts as verified only when gpg reports the release
814+
# key's signature good and a VALIDSIG status line carries the release key fingerprint. gpg
815+
# also prints VALIDSIG, and exits with 0, for a signature made by a revoked or expired key,
816+
# which it reports as REVKEYSIG or EXPKEYSIG instead of GOODSIG.
817+
if download "$RELEASE_URL/download/$version/$asset.sig" "$file.sig"; then
818+
status=$(gpg --homedir "$gnupg_home" --batch --status-fd 1 --verify "$file.sig" "$file" 2>/dev/null)
819+
if grep -q -E "^\[GNUPG:\] REVKEYSIG $key " <<< "$status"; then
820+
warn 'the release key has been revoked'
821+
elif grep -q -E "^\[GNUPG:\] EXPKEYSIG $key " <<< "$status"; then
822+
warn 'the release key has expired'
823+
elif grep -q -E "^\[GNUPG:\] GOODSIG $key " <<< "$status" \
824+
&& grep '^\[GNUPG:\] VALIDSIG ' <<< "$status" | grep -q -w "$RELEASE_KEY_FINGERPRINT"; then
825+
verified=true
826+
fi
815827
fi
816828
# Stop the gpg daemons of the temporary keyring, then remove the keyring and the signature.
817829
gpgconf --homedir "$gnupg_home" --kill all >/dev/null 2>&1

0 commit comments

Comments
 (0)