Skip to content

Commit 2f76608

Browse files
zeripathlunny
andauthored
Prevent security failure due to bad APP_ID (#18678)
WebAuthn may cause a security exception if the provided APP_ID is not allowed for the current origin. Therefore we should reattempt authentication without the appid extension. Also we should allow [u2f] as-well as [U2F] sections. Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Lunny Xiao <[email protected]>
1 parent 4160aff commit 2f76608

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

modules/setting/setting.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -1061,11 +1061,14 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
10611061
}
10621062

10631063
// FIXME: DEPRECATED to be removed in v1.18.0
1064+
U2F.AppID = strings.TrimSuffix(AppURL, "/")
10641065
if Cfg.Section("U2F").HasKey("APP_ID") {
10651066
log.Error("Deprecated setting `[U2F]` `APP_ID` present. This fallback will be removed in v1.18.0")
1067+
U2F.AppID = Cfg.Section("U2F").Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/"))
1068+
} else if Cfg.Section("u2f").HasKey("APP_ID") {
1069+
log.Error("Deprecated setting `[u2]` `APP_ID` present. This fallback will be removed in v1.18.0")
1070+
U2F.AppID = Cfg.Section("u2f").Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/"))
10661071
}
1067-
sec = Cfg.Section("U2F")
1068-
U2F.AppID = sec.Key("APP_ID").MustString(strings.TrimSuffix(AppURL, "/"))
10691072
}
10701073

10711074
func parseAuthorizedPrincipalsAllow(values []string) ([]string, bool) {

web_src/js/features/user-auth-webauthn.js

+13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ export function initUserAuthWebAuthn() {
2424
.then((credential) => {
2525
verifyAssertion(credential);
2626
}).catch((err) => {
27+
// Try again... without the appid
28+
if (makeAssertionOptions.publicKey.extensions && makeAssertionOptions.publicKey.extensions.appid) {
29+
delete makeAssertionOptions.publicKey.extensions['appid'];
30+
navigator.credentials.get({
31+
publicKey: makeAssertionOptions.publicKey
32+
})
33+
.then((credential) => {
34+
verifyAssertion(credential);
35+
}).catch((err) => {
36+
webAuthnError('general', err.message);
37+
});
38+
return;
39+
}
2740
webAuthnError('general', err.message);
2841
});
2942
}).fail(() => {

0 commit comments

Comments
 (0)