Skip to content

Conversation

@codecov
Copy link

codecov bot commented Sep 5, 2020

Codecov Report

Merging #2797 into master will increase coverage by 0.34%.
The diff coverage is 92.68%.

@@            Coverage Diff             @@
##           master    #2797      +/-   ##
==========================================
+ Coverage   88.02%   88.36%   +0.34%     
==========================================
  Files         252      252              
  Lines       53671    53701      +30     
==========================================
+ Hits        47242    47455     +213     
+ Misses       6429     6246     -183     
Impacted Files Coverage Δ
scapy/layers/tls/session.py 84.43% <75.00%> (+0.10%) ⬆️
scapy/layers/tls/handshake.py 83.82% <87.50%> (+0.31%) ⬆️
scapy/layers/tls/crypto/prf.py 84.56% <100.00%> (+0.39%) ⬆️
scapy/layers/tls/keyexchange.py 86.93% <100.00%> (+0.17%) ⬆️
scapy/arch/windows/__init__.py 70.60% <0.00%> (-0.48%) ⬇️
scapy/layers/inet.py 74.13% <0.00%> (+0.08%) ⬆️
scapy/utils.py 80.81% <0.00%> (+0.33%) ⬆️
scapy/layers/tls/basefields.py 85.90% <0.00%> (+0.67%) ⬆️
... and 8 more

@gpotter2 gpotter2 closed this Sep 5, 2020
@gpotter2 gpotter2 reopened this Sep 5, 2020
super(TLSClientKeyExchange, self).tls_session_update(msg_str)

if self.tls_session.extms:
hash_object = self.tls_session.pwcs.hash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correctly fallback to MD5+SHA1 for TLS 1.0 - TLS 1.1 (as said chapter 3 of RFC 7627)?

I've got traffic examples for Extended-Master-Secret for TLS 1.0 & TLS 1.1 only with Encrypt-then-MAC.
So can't check it right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a 100% sure, will check that tonight. Should be defined over

class connState(object):
but this is usually pretty alright. This fallback is implemented for some parts like the PRF

Copy link
Contributor

@strayge strayge Sep 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked. Current implementation works only for TLS 1.2.
Here fix: https://github.com/strayge/scapy/commit/b6a97dccb880c0285c893a644fc3e57a74f89192

Also for testing I wrote POC of Encrypt-Then-MAC: https://github.com/strayge/scapy/commit/aee5f5712f287256a94ea34a46f577b9434374ae

with both this commits successfully decrypted: TLS 1.0 - TLS 1.2 with EMS + ETM extensions
(checked on AES-CBC & AES-GCM suites)

Copy link
Member Author

@gpotter2 gpotter2 Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PoC ! Looking good.
There are a few things that require changes (I'll go over that tommorow), such as the case where the server doesn't support ExtMS or EncryptThenMac, despite the client request, and everything related to building those packets, but it's a solid start.

Copy link
Contributor

@strayge strayge Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extensions detection placed in TLSServerHello class, so we detect it only if server support it (and client requested it).

Also in PoC missed implementation of Encrypt-Then-MAC for stream ciphers (for AEAD ciphers server must not send this extension, according to RFC).

@p-l-
Copy link
Member

p-l- commented Sep 10, 2020

@gpotter2 can you rebase against current master, since #2792 has been merged?

@gpotter2 gpotter2 marked this pull request as draft September 10, 2020 13:05
@gpotter2 gpotter2 force-pushed the 2403-improvement branch 2 times, most recently from 3dd92a9 to 529a526 Compare September 11, 2020 14:24
@strayge
Copy link
Contributor

strayge commented Sep 11, 2020

@gpotter2 should I made separated PR for Encrypt-then-MAC?

@gpotter2 gpotter2 marked this pull request as ready for review September 11, 2020 19:33
@gpotter2
Copy link
Member Author

That would probably be a good thing, thanks for the suggestion !

@strayge
Copy link
Contributor

strayge commented Sep 11, 2020

Also I found that current implementation of EMS does not work with TLS 1.2 + RC4.
Don't know why.
TLS 1.0 and TLS 1.1 works well with RC4 + extended_master_secret.

openssl 1.1.1g for client and server.
First Finished in 3rd packet is not decrypted.
Here is example. Key is the same.
tls12_rc4_ems.zip

load_layer("tls")
a = rdpcap("./tls12_rc4.pcap")
t1 = TLS(a[0].load)
t1.tls_session.server_rsa_key = PrivKey("./ssl.key")
t2 = TLS(a[1].load, tls_session=t1.tls_session.mirror())
t3 = TLS(a[2].load, tls_session=t2.tls_session.mirror())

@gpotter2
Copy link
Member Author

The RC4 example your provided has encrypt_then_mac so that's probably the issue.

@strayge
Copy link
Contributor

strayge commented Sep 14, 2020

The RC4 example your provided has encrypt_then_mac so that's probably the issue.

ServerHello does not contains encrypt_then_mac, so it should not be used.

image

P.S. But it's minor issue, as RC4 is not widely used nowadays. I'm happy with this PR and without RC4.

@gpotter2
Copy link
Member Author

I've provided a fix, feel free to try it out.

@strayge
Copy link
Contributor

strayge commented Sep 14, 2020

Thanks! Now it works for all my test cases.

@gpotter2 gpotter2 merged commit 26fd314 into secdev:master Oct 3, 2020
@gpotter2 gpotter2 deleted the 2403-improvement branch October 3, 2020 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants