Skip to content

Commit a24ea67

Browse files
committed
Harden macOS uninstall script
WE2-1251 Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent f36a875 commit a24ea67

3 files changed

Lines changed: 48 additions & 8 deletions

File tree

debian/web-eid-firefox.postrm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ if [ ! -f ${POLICIES}/policies.json ]; then
99
else
1010
JQARGS=${POLICIES}/policies.json;
1111
fi
12+
# Block the extension so it can't be reinstalled from AMO without the native app, avoiding a
13+
# dangling, non-functional extension. Reinstalling web-eid-firefox overwrites this back to
14+
# "normal_installed" (see debian/web-eid-firefox.postinst), so this is not a permanent block.
1215
jq '.policies.ExtensionSettings["{e68418bc-f2b0-4459-a9ea-3e72b6751b07}"] = {"installation_mode": "blocked"}' ${JQARGS} > ${POLICIES}/policies.tmp
1316
mv ${POLICIES}/policies.tmp ${POLICIES}/policies.json
1417

install/uninstall.sh

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

3+
set -euo pipefail
4+
5+
echo "This will remove Web eID and its browser integration files. Administrator" \
6+
"privileges are required."
7+
read -r -p "Continue? [y/N] " confirm
8+
case "${confirm}" in
9+
[yY]|[yY][eE][sS]) ;;
10+
*) echo "Aborted."; exit 1 ;;
11+
esac
12+
13+
# Prompt for the admin password once up front; the sudo calls below reuse this ticket.
14+
sudo -v
15+
316
sudo rm -rf \
4-
/Applications/Utilities/web-eid.app \
5-
/Applications/Utilities/web-eid-safari.app \
6-
/Library/Google/Chrome/NativeMessagingHosts/eu.webeid.json \
7-
/Library/Application\ Support/Mozilla/NativeMessagingHosts/eu.webeid.json \
8-
/Library/Application\ Support/Google/Chrome/External\ Extensions/ncibgoaomkmdpilpocfeponihegamlic.json
17+
"/Applications/Utilities/web-eid.app" \
18+
"/Applications/Utilities/web-eid-safari.app" \
19+
"/Library/Google/Chrome/NativeMessagingHosts/eu.webeid.json" \
20+
"/Library/Application Support/Mozilla/NativeMessagingHosts/eu.webeid.json" \
21+
"/Library/Application Support/Google/Chrome/External Extensions/ncibgoaomkmdpilpocfeponihegamlic.json"
22+
923
PLIST=/Library/Preferences/org.mozilla.firefox.plist
10-
sudo defaults write ${PLIST} ExtensionSettings \
24+
# Block the extension so it can't be reinstalled from AMO without the native app, avoiding a
25+
# dangling, non-functional extension. Reinstalling Web eID overwrites this back to
26+
# 'normal_installed' (see install/macos-postinstall.in), so this is not a permanent block.
27+
sudo defaults write "${PLIST}" ExtensionSettings \
1128
-dict-add "'{e68418bc-f2b0-4459-a9ea-3e72b6751b07}'" "{ 'installation_mode' = 'blocked'; }"
29+
30+
echo "Web eID has been uninstalled."

install/web-eid.wxs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
Condition="FIREFOXINSTALL=1 AND NOT REMOVE=&quot;ALL&quot;" />
6464
<Custom Action="ExtensionSettingsNoInstall" Before="InstallFinalize"
6565
Condition="FIREFOXINSTALL=0 AND NOT REMOVE=&quot;ALL&quot;" />
66+
<!-- ExtensionSettingsRemove blocks the extension so it can't be reinstalled from AMO
67+
without the native app, avoiding a dangling, non-functional extension. Reinstalling
68+
Web eID runs ExtensionSettingsInstall above, which overwrites this back to allowed, so
69+
this is not a permanent block. -->
6670
<Custom Action="ExtensionSettingsRemove" Before="InstallFinalize"
6771
Condition="REMOVE=&quot;ALL&quot; AND NOT UPGRADINGPRODUCTCODE" />
6872
</InstallExecuteSequence>
@@ -110,12 +114,23 @@
110114
<RegistryValue Root="HKLM" Type="string" Name="update_url"
111115
Key="SOFTWARE\Google\Chrome\Extensions\ncibgoaomkmdpilpocfeponihegamlic"
112116
Value="https://clients2.google.com/service/update2/crx" />
113-
<!-- Block chrome-token-signing extension to avoid conflicts -->
117+
<!-- Block chrome-token-signing extension to avoid conflicts. Chromium's registry policy
118+
loader (RegistryDict::ConvertToJSON in registry_dict.cc) only reads list-policy
119+
entries whose value NAME is numeric (IsKeyNumeric) - non-numeric names are silently
120+
ignored - so this can't be replaced with a collision-free unique string (e.g. a hash
121+
of the extension ID) as one might expect. The name must stay a bare number, which
122+
means it can theoretically collide with another vendor's installer using the same
123+
number under this list; there's no registry-level namespacing for this policy.
124+
Worst case on collision is that this entry is silently overwritten/ignored, i.e. the
125+
legacy extension isn't blocked - a compatibility nicety, not a security control - so
126+
this is accepted as-is rather than solved with a heavier enumerate-and-pick-next-free-
127+
slot custom action. -->
114128
<RegistryValue Root="HKLM" Type="string" Name="56791"
115129
Key="SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlocklist"
116130
Value="ckjefchnfjhjfedoccjbhjpbncimppeg" />
117131
</Component>
118132
<Component Id="ChromePolicy" Transitive="yes" Condition="(CHROMEINSTALL = 1 AND CHROMEPOLICY = 1)" Bitness="always32">
133+
<!-- Same hardcoded-numeric-name caveat as the Blocklist entry above applies here. -->
119134
<RegistryValue Root="HKLM" Type="string" Name="56790"
120135
Key="SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist"
121136
Value="ncibgoaomkmdpilpocfeponihegamlic" />
@@ -124,12 +139,15 @@
124139
<RegistryValue Root="HKLM" Type="string" Name="update_url"
125140
Key="SOFTWARE\Microsoft\Edge\Extensions\gnmckgbandlkacikdndelhfghdejfido"
126141
Value="https://edge.microsoft.com/extensionwebstorebase/v1/crx" />
127-
<!-- Block chrome-token-signing extension to avoid conflicts -->
142+
<!-- Block chrome-token-signing extension to avoid conflicts. Same hardcoded-numeric-name
143+
caveat as the Chrome Blocklist entry above applies here (Edge's registry policy
144+
loader is Chromium-derived and behaves the same way). -->
128145
<RegistryValue Root="HKLM" Type="string" Name="56791"
129146
Key="SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallBlocklist"
130147
Value="fofaekogmodbjplbmlbmjiglndceaajh" />
131148
</Component>
132149
<Component Id="EdgePolicy" Transitive="yes" Condition="(EDGEINSTALL = 1 AND EDGEPOLICY = 1)" Bitness="always32">
150+
<!-- Same hardcoded-numeric-name caveat as the Blocklist entries above applies here. -->
133151
<RegistryValue Root="HKLM" Type="string" Name="56790"
134152
Key="SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallForcelist"
135153
Value="gnmckgbandlkacikdndelhfghdejfido" />

0 commit comments

Comments
 (0)