Skip to content

Commit 004884c

Browse files
authored
feat: verify package signatures (#1220)
* feat: archive integrity verification WIP * feat: archive integrity verification in the aarch64 update script * chore: extract verification into a separate file * feat: add signature verification to all installation and update scripts * fix: pass correct filenames when invoking the verification script
1 parent 5b02fb9 commit 004884c

File tree

9 files changed

+166
-0
lines changed

9 files changed

+166
-0
lines changed

scripts/linux-aarch64/install.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-aarch64.tar.bz2"
4+
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
45
echo ""
56
echo ""
67
echo "⚡️ Welcome to Alby Hub"
@@ -17,6 +18,22 @@ cd $INSTALL_DIR
1718

1819
# download and extract the Alby Hub executable
1920
wget $ALBYHUB_URL
21+
22+
if [[ ! -f "verify.sh" ]]; then
23+
echo "Downloading the verification script..."
24+
if ! wget -q "$VERIFIER_URL"; then
25+
echo "❌ Failed to download the verification script." >&2
26+
exit 1
27+
fi
28+
chmod +x verify.sh
29+
fi
30+
31+
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
32+
if [[ $? -ne 0 ]]; then
33+
echo "❌ Verification failed, aborting installation"
34+
exit 1
35+
fi
36+
2037
tar xvf server-linux-aarch64.tar.bz2
2138
if [[ $? -ne 0 ]]; then
2239
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"

scripts/linux-aarch64/update.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ cp -r data albyhub-backup
5757

5858
echo "Downloading latest version"
5959
wget $ALBYHUB_URL
60+
61+
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
62+
if [[ $? -ne 0 ]]; then
63+
echo "❌ Verification failed, aborting installation"
64+
exit 1
65+
fi
66+
6067
tar -xvf server-linux-aarch64.tar.bz2
6168
rm server-linux-aarch64.tar.bz2
6269

scripts/linux-x86_64/install.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22

33
ALBYHUB_URL="https://getalby.com/install/hub/server-linux-x86_64.tar.bz2"
4+
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
45
echo ""
56
echo ""
67
echo "⚡️ Welcome to Alby Hub"
@@ -17,6 +18,22 @@ cd $INSTALL_DIR
1718

1819
# download and extract the Alby Hub executable
1920
wget $ALBYHUB_URL
21+
22+
if [[ ! -f "verify.sh" ]]; then
23+
echo "Downloading the verification script..."
24+
if ! wget -q "$VERIFIER_URL"; then
25+
echo "❌ Failed to download the verification script." >&2
26+
exit 1
27+
fi
28+
chmod +x verify.sh
29+
fi
30+
31+
./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2
32+
if [[ $? -ne 0 ]]; then
33+
echo "❌ Verification failed, aborting installation"
34+
exit 1
35+
fi
36+
2037
tar xvf server-linux-x86_64.tar.bz2
2138
if [[ $? -ne 0 ]]; then
2239
echo "Failed to unpack Alby Hub. Potentially bzip2 is missing"

scripts/linux-x86_64/update.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ cp -r data albyhub-backup
5757

5858
echo "Downloading latest version"
5959
wget $ALBYHUB_URL
60+
61+
./verify.sh server-linux-x86_64.tar.bz2 albyhub-Server-Linux-x86_64.tar.bz2
62+
if [[ $? -ne 0 ]]; then
63+
echo "❌ Verification failed, aborting installation"
64+
exit 1
65+
fi
66+
6067
tar -xvf server-linux-x86_64.tar.bz2
6168
rm server-linux-x86_64.tar.bz2
6269

scripts/pi-aarch64/install.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
2+
13
echo ""
24
echo ""
35
echo "⚡️ Welcome to Alby Hub"
@@ -10,6 +12,21 @@ sudo chown -R $USER:$USER /opt/albyhub
1012
cd /opt/albyhub
1113
wget https://getalby.com/install/hub/server-linux-aarch64.tar.bz2
1214

15+
if [[ ! -f "verify.sh" ]]; then
16+
echo "Downloading the verification script..."
17+
if ! wget -q "$VERIFIER_URL"; then
18+
echo "❌ Failed to download the verification script." >&2
19+
exit 1
20+
fi
21+
chmod +x verify.sh
22+
fi
23+
24+
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
25+
if [[ $? -ne 0 ]]; then
26+
echo "❌ Verification failed, aborting installation"
27+
exit 1
28+
fi
29+
1330
# Extract archives
1431
tar -xvf server-linux-aarch64.tar.bz2
1532
if [[ $? -ne 0 ]]; then

scripts/pi-aarch64/update.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ cp -r data albyhub-backup
1313

1414
wget https://getalby.com/install/hub/server-linux-aarch64.tar.bz2
1515

16+
./verify.sh server-linux-aarch64.tar.bz2 albyhub-Server-Linux-aarch64.tar.bz2
17+
if [[ $? -ne 0 ]]; then
18+
echo "❌ Verification failed, aborting installation"
19+
exit 1
20+
fi
21+
1622
# Extract archives
1723
tar -xvf server-linux-aarch64.tar.bz2
1824

scripts/pi-arm/install.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
VERIFIER_URL="https://getalby.com/install/hub/verify.sh"
2+
13
echo ""
24
echo ""
35
echo "⚡️ Welcome to Alby Hub"
@@ -10,6 +12,21 @@ sudo chown -R $USER:$USER /opt/albyhub
1012
cd /opt/albyhub
1113
wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
1214

15+
if [[ ! -f "verify.sh" ]]; then
16+
echo "Downloading the verification script..."
17+
if ! wget -q "$VERIFIER_URL"; then
18+
echo "❌ Failed to download the verification script." >&2
19+
exit 1
20+
fi
21+
chmod +x verify.sh
22+
fi
23+
24+
./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2
25+
if [[ $? -ne 0 ]]; then
26+
echo "❌ Verification failed, aborting installation"
27+
exit 1
28+
fi
29+
1330
# Extract archives
1431
tar -xvf server-linux-armv6.tar.bz2
1532
if [[ $? -ne 0 ]]; then

scripts/pi-arm/update.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ cp -r data albyhub-backup
1313

1414
wget https://getalby.com/install/hub/server-linux-armv6.tar.bz2
1515

16+
./verify.sh server-linux-armv6.tar.bz2 albyhub-Server-Linux-armv6.tar.bz2
17+
if [[ $? -ne 0 ]]; then
18+
echo "❌ Verification failed, aborting installation"
19+
exit 1
20+
fi
21+
1622
# Extract archives
1723
tar -xvf server-linux-armv6.tar.bz2
1824

scripts/verify.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
MANIFEST_URL="https://getalby.com/install/hub/manifest.txt"
4+
SIGNATURE_URL="https://getalby.com/install/hub/manifest.txt.asc"
5+
6+
verify_package() {
7+
local archive_file="${1}"
8+
local filename_in_manifest="${2}"
9+
local response=""
10+
11+
while true; do
12+
read -r -p "Verify package signature and integrity? (Y/N): " response
13+
case "$response" in
14+
[Yy]) break ;;
15+
[Nn]) echo "Verification skipped." ; return 0 ;;
16+
*) echo "Invalid input. Please enter Y or N." ;;
17+
esac
18+
done
19+
20+
for cmd in gpg sha256sum; do
21+
if ! command -v "$cmd" &>/dev/null; then
22+
echo "❌ Required command '$cmd' is not available." >&2
23+
return 1
24+
fi
25+
done
26+
27+
echo "Downloading manifest file..."
28+
if ! wget -q "$MANIFEST_URL"; then
29+
echo "❌ Failed to download manifest file." >&2
30+
return 1
31+
fi
32+
33+
echo "Downloading manifest signature file..."
34+
if ! wget -q "$SIGNATURE_URL"; then
35+
echo "❌ Failed to download manifest signature file." >&2
36+
return 1
37+
fi
38+
39+
if ! gpg --batch --verify "manifest.txt.asc" "manifest.txt"; then
40+
echo "❌ GPG signature verification failed!" >&2
41+
echo "Visit https://github.com/getAlby/hub/releases for more information on how to verify the release" >&2
42+
return 1
43+
fi
44+
45+
local expected_hash
46+
expected_hash=$(grep "${filename_in_manifest}" "manifest.txt" | awk '{print $1}') || true
47+
if [[ -z "$expected_hash" ]]; then
48+
echo "❌ No hash entry found for ${filename_in_manifest} in the manifest." >&2
49+
return 1
50+
fi
51+
52+
local actual_hash
53+
actual_hash=$(sha256sum "$archive_file" | awk '{print $1}')
54+
55+
if [[ "$expected_hash" != "$actual_hash" ]]; then
56+
echo "❌ SHA256 hash mismatch! The file may be corrupted or tampered with." >&2
57+
return 1
58+
fi
59+
60+
echo "✅ Verification successful. The package is authentic and intact."
61+
return 0
62+
}
63+
64+
if [[ $# -ne 2 ]]; then
65+
echo "Usage: $0 <archive_file> <filename_in_manifest>"
66+
exit 1
67+
fi
68+
69+
verify_package "$1" "$2"
70+
if [[ $? -ne 0 ]]; then
71+
exit 1
72+
fi

0 commit comments

Comments
 (0)