OWASP / ASVS

Application Security Verification Standard
Creative Commons Attribution Share Alike 4.0 International
2.76k stars 671 forks source link

V6 - Discuss forward secrecy #2215

Open randomstuff opened 3 weeks ago

randomstuff commented 3 weeks ago

Some requirement(s) should require the usage of forward secrecy whenever it makes sense.

see https://github.com/OWASP/ASVS/pull/2212#issuecomment-2451664978

Possible impact:

danielcuthbert commented 2 weeks ago

I did address this with https://github.com/OWASP/ASVS/issues/2252

Do you think we need to clarify further @randomstuff

randomstuff commented 2 weeks ago

Both RSA and DHE do support PFS

Can you clarify (or provide reference) when you say that RSA supports PFS? Maybe we are not talking about the same thing?

randomstuff commented 2 weeks ago

My point is that we should have explicit requirements about forward secrecy which is currently not mentioned explicitly at all.

Proposed generic requirement:

9.2.X Verify than for all communications using an encrypted protocols (TLS, SSH) the communication provides forward secrecy with respect to the long term private keys when communicating with modern clients. Non-forward secret communication might still be supported only for compatibility with old client which do not support it and if such compatibility is required.

This generic requirement could be specialized into more specific requirement about TLS (?). Proposed requirement about forward secrecy with respect to the client private key

9.4.X Verify than for all communications using TLS provides forward secrecy with respect to server private key when communicating with modern clients. Key exchanges such as RSA transport, static diffie-hellman, static ECDH key exchanges must not be used for when communicating with modern clients.

Some questions/comments:

ImanSharaf commented 2 weeks ago

Should we enforce the use of ephemeral key exchange methods, such as ephemeral Diffie-Hellman (DHE) or Elliptic Curve Diffie-Hellman (ECDHE)? It can ensure that session keys are unique per session, preserving forward secrecy. In contrast, static key exchanges, like RSA or static Diffie-Hellman, do not provide forward secrecy and are therefore less secure.

randomstuff commented 2 weeks ago

@ImanSharaf, I think the requirement should focus on the goal which is to provide forward secrecy. In practice, this is typically achieved using DHE but could be achieved using other schemes (triple diffie hellman, some RSA based schemes, etc.).

randomstuff commented 2 weeks ago

See #2252

tghosth commented 5 days ago

@randomstuff what are the next steps on this issue?

randomstuff commented 5 days ago

Proposition:

9.2.X Verify that communications using in-transit encryption (for example using TLS, SSH, IPsec, QUIC), the encryption protocol provides forward secrecy. This can be achieved using an ephemeral Diffie-Hellman key exchange.

Somewhat more verbose (but possibly more precise) wording:

9.2.X Verify than for all communications using in-transit encryption (for example using TLS, SSH, IPsec, QUIC), the communication cannot be decrypted with any persistent secret (forward secrecy). This can be achieved using an ephemeral Diffie-Hellman key exchange.

Question: Any need for an exception for compatibility with old legacy external clients? ("[…] when communicating with up-to date clients […] Communication with external legacy clients which do not support forward secrecy can be used if such compatibility is required.")

Question: Add some hints about suitable TLS ciphersuites in appendix?

Question: Do we need to discuss about the impact of session resumption with respect to forward secrecy?

tghosth commented 3 days ago

My questions:

Question: Add some hints about suitable TLS ciphersuites in appendix?

Open to suggestions but that would be a separate issue on the appendix. I don't think it is critical.

Question: Do we need to discuss about the impact of session resumption with respect to forward secrecy?

Does it alter the requirement?

tghosth commented 3 days ago

@randomstuff

randomstuff commented 3 days ago

Question: Do we need to discuss about the impact of session resumption with respect to forward secrecy?

Does it alter the requirement?

Short answer: It's complicated. I'd say we can include the requirement as is. Id needed, we can talk about session resumption in another issue.

Long answer below:

Possibly, somewhat.

Explanation: The secrets stored by the TLS server for session resumption can typically be used to break the encryption of the resumed TLS session. If these are persisted (and replicated in order to allow the session to work on different instances of the TLS termination server), this may compromise forward secrecy.

See for reference : https://timtaubert.de/blog/2014/11/the-sad-state-of-server-side-tls-session-resumption-implementations/

Note: This is fixed in TLS 1.3 when if a Diffie-Hellman key exchange is done as part of the session resumption (psk_dhe_ke).

So for this proposed requirement:

9.2.X Verify than for all communications using in-transit encryption (for example using TLS, SSH, IPsec, QUIC), the communication cannot be decrypted with any persistent secret (forward secrecy). This can be achieved using an ephemeral Diffie-Hellman key exchange.

could be interpreted as implying that session secrets must be not persisted.

tghosth commented 1 day ago

Ok so how about my other questions @randomstuff :

randomstuff commented 1 day ago

Summary of forward secrecy support depending on TLS versions and ciphersuites:

TLS Ciphersuites Forward secrecy?
A 1.3 - yes
B 1.2 TLS_DHE_*, TLS_ECDHE_* yes
C 1.2 TLS_RSA_*, TLS_DH_*, TLS_ECDH_* no

(Assuming the DH contributions are really ephemeral. And if we skip the question of session resumption. If we skip the exotic ciphersuites such as PSK, etc.)

We have two options for this proposed requirement:

  1. the current proposed requirement says "always use forward secrecy";
  2. another option would be "use forward secrecy with compatible clients (but keep less secure option for compatibility with old external legacy clients)"

Option 1: always use forward secrecy → This mean you would have to disable the ciphersuites in (C).

Option 2: support forward secrecy → this means that at least (B) must be supported. This should work out of the box on modern systems unless:

randomstuff commented 1 day ago

Mozilla SSL server configuration has three modes:

So the question is. Can we require the usage of an "intermediate or higher" level (→ option 1)?

If I look at several servers:

tghosth commented 1 day ago

So I would suggest the following:

9.4.1 [MODIFIED, MOVED FROM 9.1.2] Verify that only the latest recommended cipher suites are enabled, with the strongest cipher suites set as preferred. For L3 applications, only cipher suites which support forward secrecy should supported.

what do you think @randomstuff

randomstuff commented 1 day ago

[MODIFIED, MOVED FROM 9.1.2] Verify that only the latest recommended cipher suites are enabled, with the strongest cipher suites set as preferred.

"latest recommended cipher suites are enabled" is somewhat vague but maybe that's the point.

Moreover, this wording seems to be (implicitly) about TLS ("ciphersuites") but we might want it to apply to other protocols as well.

For L3 applications, only cipher suites which support forward secrecy should supported.

Is the "should" instead of "must" intentional here? Not that I am against saying "should" here.

I'd want to focus more on forward-secrecy as an explicit goal.

tghosth commented 20 hours ago

"latest recommended cipher suites are enabled" is somewhat vague but maybe that's the point.

Yes as this guidance changes.

Moreover, this wording seems to be (implicitly) about TLS ("ciphersuites") but we might want it to apply to other protocols as well.

Seems like TLS is probably the vast majority of cases so I prefer to include it there.

Is the "should" instead of "must" intentional here? Not that I am against saying "should" here.

Agree it should be a little clearer:

9.4.1 [MODIFIED, MOVED FROM 9.1.2] Verify that only the latest recommended cipher suites are enabled, with the strongest cipher suites set as preferred. L3 applications must only support cipher suites which provide forward secrecy.

randomstuff commented 14 hours ago

Seems like TLS is probably the vast majority of cases so I prefer to include it there.

Wouldn't it make sense to have (also) general requirement about this?

randomstuff commented 14 hours ago

(musing)

The forward secrecy requirement could apply to these web-compatible flows as well (which are not completely niche):

More generally some of the transport security requirements might apply to WebRTC. There is not so much we can do about for browser-to-browser communications but for browser-to-server WebRTC, it might be relevant.

(If this does make sense, this should belong to the WeRTC appendix, though.)

tghosth commented 9 hours ago

Wouldn't it make sense to have (also) general requirement about this?

In theory but I see the other examples as a lot more niche and I'd rather focus on the main relevant example.

For WebRTC, we have a guy who did those requirements so maybe open a separate issue and I will ping him :)