Skip to content

Commit c13bdd0

Browse files
committed
xmpp_sasl_scram: Handle "y" CB flag correctly
RFC 5802 says: | If the flag is set to "y" and the server supports channel binding, the | server MUST fail authentication. This is because if the client sets the | channel binding flag to "y", then the client must have believed that the | server did not support channel binding -- if the server did in fact | support channel binding, then this is an indication that there has been | a downgrade attack (e.g., an attacker changed the server's mechanism | list to exclude the -PLUS suffixed SCRAM mechanism name(s)). Therefore, let authentication fail if we offered the client PLUS methods and the client sets the "y" flag. Thanks to Thilo Molitor for spotting the issue.
1 parent f48eb94 commit c13bdd0

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/xmpp_sasl_scram.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,10 @@ cbind_valid(#state{channel_bindings = #{} = Bindings}, <<"p=", Binding/binary>>)
260260
maps:is_key(Binding, Bindings);
261261
cbind_valid(#state{channel_bindings = #{}}, _) ->
262262
false;
263-
cbind_valid(_, <<"y", _/binary>>) ->
263+
cbind_valid(#state{channel_bindings = not_available}, <<"y", _/binary>>) ->
264264
true;
265+
cbind_valid(_, <<"y", _/binary>>) ->
266+
false;
265267
cbind_valid(_, <<"n", _/binary>>) ->
266268
true;
267269
cbind_valid(_, _) ->

0 commit comments

Comments
 (0)