Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No implement crypto binding #1

Closed
sorz opened this issue Sep 21, 2014 · 3 comments
Closed

No implement crypto binding #1

sorz opened this issue Sep 21, 2014 · 3 comments

Comments

@sorz
Copy link
Owner

sorz commented Sep 21, 2014

Must verify certHash and macHash on sstpMsgCallConnectedReceived() to prevent MITM attack.

@sorz sorz added the bug label Sep 21, 2014
@sorz
Copy link
Owner Author

sorz commented Jul 21, 2015

Certificate hash is verifed since 1aa9a51.

For macHash, SSTPd have to parse and inspect LCP and authentication protocol
(MS-CHAPv2 & EAP) data flow. These are what we haven't done.

@tisj
Copy link
Contributor

tisj commented Jan 22, 2020

Hi @sorz,

To my understanding, the Higher Layer Authentication Key (HLAK) can not be snooped/derived from the authentication data flow (as the keys are not transferred over the wire). They can only be obtained from the process that created/maintains them (thus ppp daemon; or possibly in linux from the ppp_mppe kernel driver).

The sstp-client project dealt with the same difficulty, and implemented a solution by creating a special ppp plugin (called sstp-plugin), that snoops outgoing ppp packets for (CHAP) authentication success, if then the mppe send/recv keys are set by ppp it will expose them to the sstp-client program (by means of a unix socket), allowing to calculate the crypto bindings.

I made an implementation for sstp-server using that same technique (reusing their ppp plugin, and adding a unix socket to listen on). Thus it adds crypto binding support for both SHA-1 and SHA-256 operations, for MS-CHAPv2 and EAP-TLS (using MPPE Master{Send,Recv}Key). Normal EAP uses Client Master Session Key and Server Master Session Key, which are not captured by the sstp-plugin.

The implementation has been tested with the linux sstp-client, and microsoft sstp clients (w8 and w10). Let me know if you are interested...

@sorz
Copy link
Owner Author

sorz commented Feb 11, 2020

Thanks! You are right, these keys must not be snoopsable otherwise the crypto binding is meaningless.
PR is welcome!

tisj added a commit to axsguard/sstp-server that referenced this issue Jan 14, 2021
Implements the Crypto Binding Compound MAC (CMAC) verification,
when the Crypto Binding Attribute is present in the SSTP Call Connected
message.

The PPP (sub)process passes the MPPE send/receive keys when CHAP
authentication succeeds. When received by sstp-server, it installs them
as the Higher Layer Key (HLAK). In server mode the HLAK is obtained by
concatenating the master receive key with the send key. Ensure the key
is 32 bytes long (should be the case for MPPE) - zero-padded if needed.

The Crypto Binding CMAC is (re)calculated on server side and compared
with the value present in the Crypto Binding Attribute. In case they do
not match the connection is aborted.

CMAC uses HMAC using the Crypto Binding Hash algorithm negotiated (SHA1
or SHA256). Input for HMAC is the complete SSTP Call Connected message,
with CMAC field in Crypto Binding Attribute zeroed out. The key for the
HMAC operation is obtained using the PRF algorithm based on PRF+ from
IKEv2, called the Compound Mac Key (CMK).

CMK is obtained from the first iteration of PRF using the same HMAC
cryptographic operation. Input for CMK is the CMK seed 'SSTP inner
method derived CMK' concatenated with the little endian formatted length
of the cryptographic hash used and the iteration number, whereas the key
is HLAK.

In order to support sstp-server without sstp-pppd-plugin.so, CMAC is not
verified when plugin is not available.

Resolves sorz#1

Signed-off-by: Tijs Van Buggenhout <tijs.van.buggenhout@axsguard.com>
tisj added a commit to axsguard/sstp-server that referenced this issue Jan 14, 2021
Implements the Crypto Binding Compound MAC (CMAC) verification,
when the Crypto Binding Attribute is present in the SSTP Call Connected
message.

The PPP (sub)process passes the MPPE send/receive keys when CHAP
authentication succeeds. When received by sstp-server, it installs them
as the Higher Layer Key (HLAK). In server mode the HLAK is obtained by
concatenating the master receive key with the send key. Ensure the key
is 32 bytes long (should be the case for MPPE) - zero-padded if needed.

The Crypto Binding CMAC is (re)calculated on server side and compared
with the value present in the Crypto Binding Attribute. In case they do
not match the connection is aborted.

CMAC uses HMAC using the Crypto Binding Hash algorithm negotiated (SHA1
or SHA256). Input for HMAC is the complete SSTP Call Connected message,
with CMAC field in Crypto Binding Attribute zeroed out. The key for the
HMAC operation is obtained using the PRF algorithm based on PRF+ from
IKEv2, called the Compound Mac Key (CMK).

CMK is obtained from the first iteration of PRF using the same HMAC
cryptographic operation. Input for CMK is the CMK seed 'SSTP inner
method derived CMK' concatenated with the little endian formatted length
of the cryptographic hash used and the iteration number, whereas the key
is HLAK.

In order to support sstp-server without sstp-pppd-plugin.so, CMAC is not
verified when plugin is not available.

Resolves sorz#1

Signed-off-by: Tijs Van Buggenhout <tijs.van.buggenhout@axsguard.com>
tisj added a commit to axsguard/sstp-server that referenced this issue Jan 16, 2021
Implements the Crypto Binding Compound MAC (CMAC) verification,
when the Crypto Binding Attribute is present in the SSTP Call Connected
message.

The PPP (sub)process passes the MPPE send/receive keys when CHAP
authentication succeeds. When received by sstp-server, it installs them
as the Higher Layer Key (HLAK). In server mode the HLAK is obtained by
concatenating the master receive key with the send key. Ensure the key
is 32 bytes long (should be the case for MPPE) - zero-padded if needed.

The Crypto Binding CMAC is (re)calculated on server side and compared
with the value present in the Crypto Binding Attribute. In case they do
not match the connection is aborted.

CMAC uses HMAC using the Crypto Binding Hash algorithm negotiated (SHA1
or SHA256). Input for HMAC is the complete SSTP Call Connected message,
with CMAC field in Crypto Binding Attribute zeroed out. The key for the
HMAC operation is obtained using the PRF algorithm based on PRF+ from
IKEv2, called the Compound Mac Key (CMK).

CMK is obtained from the first iteration of PRF using the same HMAC
cryptographic operation. Input for CMK is the CMK seed 'SSTP inner
method derived CMK' concatenated with the little endian formatted length
of the cryptographic hash used and the iteration number, whereas the key
is HLAK.

In order to support sstp-server without sstp-pppd-plugin.so, CMAC is not
verified when plugin is not available.

Resolves sorz#1

Signed-off-by: Tijs Van Buggenhout <tijs.van.buggenhout@axsguard.com>
@sorz sorz closed this as completed in e60442d Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants