Repository navigation
Prevent oversize TLS labels. - #11577
bernd-edlinger wants to merge 1 commit into
Conversation
|
I don't think this change is correct. It would actually change the behaviour of the So, syntactically labels of up 249 bytes in length are fine. The particular text in the RFC that you mention in your comment is only saying that labels defined in that spec are 12 or less. It says nothing about labels defined elsewhere. There are in fact a number of labels defined in the IANA TLS Exporter Label registry which are longer than 12. See: |
|
Ah, okay, that was the problem, so which one is the longest valid |
The longest valid label allowed by the spec is 249 bytes. |
|
Okay, but who uses 249 bytes? |
No one currently. The longest in the IANA registry that I can see is 31. But there is nothing preventing IANA from registering a longer one. |
|
We seem to have already had to increase this value once, even, in 0fb2815 (though it's not quite the scenario that I was initially remembering). |
As a by-product of some other related changes draft 20 increased the effective maximum label length from 246 to 249 (because it shortened the "prefix" used on the label from "TLS 1.3, " (9 characters to "tls13 " (6 characters)). But we didn't notice the impact on the max label length straight away - until the commit you mentioned. |
|
To quote #7712:
Tor invokes this function with a 44-byte label
|
|
Ah, thanks; Kurt found the one I was thinking of (that |
|
Not every exported label has to be registered. I could envision some apps using generated exporters that come close to the length. For example, using long German compound words for service names, or punycode of long asian words :) |
|
I would call TOR illegal use of OpenSSL. |
So which is the longest IANA Approved Label then? |
Longest current one is: EXPORTER-ETSI-TC-M2M-Connection |
No - I don't think so. |
|
Excuse me, Terrorists use the TOR browser to purchase weapons, So excuse me, when I DO NOT ACCEPT THAT STUPID IDEA. |
|
@bernd-edlinger cutting down the supported length just because currently the longest registered one has a given length is exactly the kind of behavior that led to the big mess in TLS 1.3 to mimic TLS 1.2 just because middleboxes hard-coded stuff and checks that were not mandated by the standard. We want openssl to be a compliant library and toolkit, and we don't want to be part of the ossification problem or one of those implementations that claim to be compliant with standards but then cut some corners due to their own unilateral interpretation of them. From my part this PR would have a -1 vote. The discussion of merits and demerits of TOR (or any other application or library that is a user of OpenSSL) does not belong here, and supporting it or not is a personal matter: as a project we currently are a free libre open source project, and we do not limit the freedom of any of our users to copy, modify, or redistribute our source code (within the boundaries of our license), and we do not prevent anyone from becoming a user of OpenSSL; the OMC would have to vote to change this, if changing it is even possible according to the project bylaws. |
|
Sorry, is there no other SSL library than OpenSSL which supports TOR? |
|
It’s not open source if you limit how it can be used, even if some find some uses distasteful.
|
|
I've added the hold label based on @romen's comment. |
I believe it's up to @bernd-edlinger to write a proposal of what the OTC should decide upon for this PR. |
|
Okay, will do, it may take me some time to think about the right wording. Meanwhile I just want to quote what I signed in my ICLA: "You accept and agree to the following terms and conditions for Your present and future So what I consider the dark net is contrary to the public benefit ? |
|
So what I consider the dark net is contrary to the public benefit ?
Can I withdraw my ICLA in that case ?
The ICLA also says:
in 2) perpetual [...] irrevocable copyright license
in 6) without [...] conditions [...] including [...] fitness for a
particular purpose
It's my understanding that the ICLA can not be terminated. But you
can stop contributing code. And if you want we can disable the
ICLA so that no new contributions are merged.
That being said, almost any technology can be used for both good and
bad, and things like tor, OpenSSL and encryption are clearly no
exception.
|
it is a contract, if one side does not fulfill it, the other side does not fulfill it either. I am not a lawyer, but I am sure a lawyer will call me on my phone and ask |
|
It definitely isn't a contract, it lacks "consideration" (which is a really complicated legal term that's the basis of contract law). Your ICLA granted exactly what @kroeckx wrote: a perpetual irrevocable license to your contributions. |
|
Nice try. |
|
Exactly, and I believe WE (i mean the world) should start to make peace. The challenge we have is to understand each other, communicate |
@bernd-edlinger I don't think this is the right way to approach the entire question. Basically we produce software that is open source and available for use. We don't place any restrictions on its use other than those contained in the license. We make no judgement about how the software is used - we don't work to preclude any specific use of the software. If you wanted to place limitations on who can use software you release for a specific purpose then that would have to be encoded in the license being used and you would have to check each user and any of their users. That certainly isn't practical and very much isn't the open source model. Thinking in a more practical sense - if you wanted to control who uses you software you simply shouldn't release it as open source. Anyone who is performing what you would consider illegal activities (in however you define those) doesn't have to make much of a leap to ignore any license terms you might add. Exerting greater control over your users is very much a commercial closed source style approach - but even then you aren't able to achieve a perfect solution in terms of complete control (e.g. software piracy). We aim to be apolitical in our approach and that extends (in my view) to basically accepting that there will be people who we disagree with that will benefit from the efforts we have performed. We accept that as part of the overwhelming greater benefits to those who aren't in that category - and also accept that each one of us has a different view point on whom we would find objectionable. This is a community effort and not that of a single person and with all communities comes the price of accepting the "community" view in order to participate. If the balance doesn't meet any specific persons needs, they are also free to form a new community or direct their efforts elsewhere. It is sad to see any member of the community frustrated with how the resulting software is used - but that is simply one of the costs of a broad community and the open source model. I think the balance remains overwhelmingly positive. |
|
I understand that they can still use the software for whatever they like, |
|
@InfoHunter do you remember? |
|
Hmm, I am thinking about how could we reach a consensus instead of a majority The motivation of the original patch was conserve stack space, Thinking about it I came to this idea: Maybe we can get to a consensus if we make it a per config parameters What do you think, could this make way for a consensus? |
|
@bernd-edlinger I don't think we should support this behavior, not even as a config option. Limiting this size, even in constrained devices, is applying an arbitrary non-regulated restriction to the TLS 1.3 standard. If the embedded developer decided to limit this size to 12 or 31 (or whatever below the limit designed in the standard), and that device ends up becoming a network appliance, it's going to create problems for everyone once a widely adopted label requires to use a longer and valid length. This kind of "optimizations" are harmful for the ecosystem and must be considered for what they are (in TLS 1.2 and earlier we failed to do so, and the evidence of the cost of it is quite clear in the last year or so of proceedings for the TLS 1.3 design before its release): the creation of products that claim compliance with a standard while being non-compliant by design. |
|
Okay, as I said, you are asking me to leave the project? |
@bernd-edlinger absolutely not! I am only trying to explain, to the best of my ability, why I think this change should not be part of OpenSSL, for the technical reasons I mentioned. I am really sorry this is coming across as personal, and I apologize for not being able to convey my message in a better way. |
|
@romen do I read your message correct, you are opposed to this PR even if |
|
In all honesty, the fact that you are trying to use the "longest currently assigned value in the IANA registry" as a criterion makes me inclined to go ask IANA to register a lable of the longest length allowed by the protocol. The only real barrier to doing so is the opinion of the designated experts for that registry, and given the existence of RFC 8701 I expect them to be amneable to proposals designed to ensure that the TLS protocol remains as flexible in practice as it is intended to be. |
|
On the other hand I can understand the concern about the stack-size occupied with the buffer in embedded application where the actual application using the openssl build is well known and does not require anything more than the regular TLS-1.3 labels. So if the default is changed to 249 and the comment adjusted accordingly, in my opinion it would be acceptable for merge. |
My personal opinion is that even for devices at the edge, the approach of "today this is the max size we need to satisfy our requirements, let's claim we are TLS compliant even if we introduce constraints explicitly in contrast with the letter of the standard" with the corollary of "let the users and engineers of tomorrow face the potential future compatibility issues" is not justifiable and shouldn't be endorsed by the OpenSSL project by providing a configure option to do so. I would rather prefer that embedded developers and engineers that want to do this to save costs and optimize things today shifting the cost of the issues to the future were to do so by patching on their own the OpenSSL source code, and completely owning the responsibility for doing so so that the project does not have any blame in fostering this anti-pattern. In my opinion it's fine to have this as a define that requires minimal intervention (one line change that replaces the value 249 to 32 or whatever) by the adopters, so we are not making their life intentionally more complicate than it needs to be, yet it clearly makes a statement that the project does not endorse such choice and takes no responsibility if the developers prefer to create products that are not compliant with the standards. As I mentioned in private correspondence with @bernd-edlinger , this is my personal opinion and feedback I am providing now that the proposition for a discussion is being formulated so that who proposes it is well aware in advance of some of the critiques that might be raised. Also, I am definitely not a TLS expert, I am discussing this mostly as a matter of principle based on my personal impression of what I consider systemic malpractices highlighted during the troubled design process of TLS 1.3, and I admit I may have a distorted perception of what could be the potential consequences to the infrastructure, the end-users, and the project if we were to adopt the decision of limiting the label length based on the longest currently assigned value: I am completely open to the idea that justified pragmatic reasons might take a precedence here, or that I might be completely wrong. |
@bernd-edlinger I missed this yesterday, sorry. Yes, I would be opposed to having this as a configure option, for the reasons stated above. Before this PR a developer that wants to use OpenSSL but decides to be intentionally non-compliant with the letter of the spec, can already apply a patch such as this: diff --git a/ssl/tls13_enc.c b/ssl/tls13_enc.c
index e81f3656ee..0122356456 100644
--- a/ssl/tls13_enc.c
+++ b/ssl/tls13_enc.c
@@ -14,7 +14,7 @@
#include <openssl/kdf.h>
#include <openssl/core_names.h>
-#define TLS13_MAX_LABEL_LEN 249
+#define TLS13_MAX_LABEL_LEN 31
/* Always filled with zeros */
static const unsigned char default_zeros[EVP_MAX_MD_SIZE];Plus a similar change to "cheat" on the Often embedded developers use Yocto or similar systems to customize and tweak software source, compilation options, etc. for the target platforms, so I don't think that adding such a trivial patch to the list of patches applied in one of the layers is going to be an excessive burden for developers of constrained systems. |
|
Sorry, but an embedded device should know which labels are needed. |
This is an interoperability issue. That makes it bigger than a mere openssl problem. Please don't ignore that aspect.
I for one love consensus work. However, you have to recognise that it's hard to reach consensus when two opposing views keep on standing their ground. |
|
@bernd-edlinger , I'll answer point to point, assuming the various items are directed at my own comments.
I admit my scarce knowledge in this area, I defer to whatever it is that people more expertise than me on the matter have to say about it.
I stated that personally I would prefer if OpenSSL did not have a configure option that results in a non-compliant implementation of TLS 1.3. I am not advocating that nobody can alter the source code to do what they want with their modified version of OpenSSL. I am rather expressing my personal opinion that the project should avoid official support for configurations resulting in non-compliance, as I see non-compliance as a bug. The fact that I express this personal opinion does not mean that I believe the project MUST do what I say because I said so. In my limited experience, so far I am under the impression that the Project has welcomed consensus whenever possible, and has public bylaws that clearly state how to resolve situations when a unanimous consensus is not reached in a reasonable time.
On this specific matter, as far as I am aware, the Project has not taken yet any vote or decision overruling a minority. I say OTC or OMC because, to me, it seems like we are mixing 2 separate issues in this discussion:
I would rather discuss the second matter in a dedicated issue, because it is tangent to what this PR was originally about, and it is also related to personal feelings and beliefs that are not really helping reaching a decision on the more technical matter.
I am not assuming I am a representative of the majority, and I am not trying to silence you personally, or a minority. I apologize if the way I wrote my previous comments was perceived as if I was implying that you must personally accept the majority decision in virtue of the fact that it aligns with my personal preference. When/if there will be votes on the technical matter and on the policy matter, I will accept the outcome because I personally trust and value the contributors to the project and I am confident that the processes that are in place to find a solution when unanimous consensus is not achieved will deliver the optimal compromise, even if it is against my initial position.
I am sorry, I don't think I am acting against looking for consensus. This is actually in fairness to whoever proposes a change (in this case, your position), rather than to who wants to keep things as they currently are (in this case, my position): the alternative would be that a PR stagnates forever while a hard-to-reach consensus is pursued, favoring who opposes change. So, if I indeed wanted to abuse our bylaws to prevent this change to be merged I would be more effective if I actively pushed for reaching unanimous consensus and delaying a majority vote.
If I keep discussing here on GitHub and via personal emails is because I want to understand your reasons and your feelings, I am not trying to ignore yours. Regarding the technical matter of this PR, it seems to me that your feelings are less involved than for the policy matter. Splitting the two things and treating them separately might help in avoiding to feel like I am actively trying to ignore your feelings. |
|
I have an alternative proposal that I believe satisfies both @bernd-edlinger's objectives and @romen's concerns. IIUC @bernd-edlinger is concerned about stack space. We can allocate a smaller stack space if diff --git a/ssl/tls13_enc.c b/ssl/tls13_enc.c
index e81f3656ee..026221b69c 100644
--- a/ssl/tls13_enc.c
+++ b/ssl/tls13_enc.c
@@ -14,7 +14,8 @@
#include <openssl/kdf.h>
#include <openssl/core_names.h>
-#define TLS13_MAX_LABEL_LEN 249
+#define TLS13_MAX_LABEL_LEN 249
+#define TLS13_MAX_TYPICAL_LABEL_LEN 31
/* Always filled with zeros */
static const unsigned char default_zeros[EVP_MAX_MD_SIZE];
@@ -42,7 +43,7 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
OSSL_PARAM params[5], *p = params;
int mode = EVP_PKEY_HKDEF_MODE_EXPAND_ONLY;
const char *mdname = EVP_MD_name(md);
- int ret;
+ int ret = 0;
size_t hkdflabellen;
size_t hashlen;
/*
@@ -50,9 +51,16 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
* prefix and label + bytes for the label itself + 1 byte length of hash
* + bytes for the hash itself
*/
- unsigned char hkdflabel[sizeof(uint16_t) + sizeof(uint8_t)
- + (sizeof(label_prefix) - 1) + TLS13_MAX_LABEL_LEN
- + 1 + EVP_MAX_MD_SIZE];
+#define HKDF_LABEL_OVERHEAD (sizeof(uint16_t) + sizeof(uint8_t) \
+ + (sizeof(label_prefix) - 1) \
+ + 1 + EVP_MAX_MD_SIZE)
+#ifdef OPENSSL_SMALL_FOOTPRINT
+ unsigned char hkdflabelst[HKDF_LABEL_OVERHEAD + TLS13_MAX_TYPICAL_LABEL_LEN];
+#else
+ unsigned char hkdflabelst[HKDF_LABEL_OVERHEAD + TLS13_MAX_LABEL_LEN];
+#endif
+ unsigned char *hkdflabel = hkdflabelst;
+ size_t hkdflabelsize = sizeof(hkdflabelst);
WPACKET pkt;
kctx = EVP_KDF_CTX_new(kdf);
@@ -71,13 +79,28 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
*/
SSLerr(SSL_F_TLS13_HKDF_EXPAND, SSL_R_TLS_ILLEGAL_EXPORTER_LABEL);
}
- EVP_KDF_CTX_free(kctx);
- return 0;
+ goto err;
+ }
+#ifdef OPENSSL_SMALL_FOOTPRINT
+ if (labellen > TLS13_MAX_TYPICAL_LABEL_LEN) {
+ hkdflabelsize = HKDF_LABEL_OVERHEAD + labellen;
+ hkdflabel = OPENSSL_malloc(hkdflabelsize);
+ if (hkdflabel == NULL) {
+ if (fatal) {
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_HKDF_EXPAND,
+ ERR_R_MALLOC_FAILURE);
+ } else {
+ SSLerr(SSL_F_TLS13_HKDF_EXPAND, ERR_R_MALLOC_FAILURE);
+ }
+ goto err;
+ }
}
+#endif
+
hashlen = EVP_MD_size(md);
- if (!WPACKET_init_static_len(&pkt, hkdflabel, sizeof(hkdflabel), 0)
+ if (!WPACKET_init_static_len(&pkt, hkdflabel, hkdflabelsize, 0)
|| !WPACKET_put_bytes_u16(&pkt, outlen)
|| !WPACKET_start_sub_packet_u8(&pkt)
|| !WPACKET_memcpy(&pkt, label_prefix, sizeof(label_prefix) - 1)
@@ -86,14 +109,13 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
|| !WPACKET_sub_memcpy_u8(&pkt, data, (data == NULL) ? 0 : datalen)
|| !WPACKET_get_total_written(&pkt, &hkdflabellen)
|| !WPACKET_finish(&pkt)) {
- EVP_KDF_CTX_free(kctx);
WPACKET_cleanup(&pkt);
if (fatal)
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_HKDF_EXPAND,
ERR_R_INTERNAL_ERROR);
else
SSLerr(SSL_F_TLS13_HKDF_EXPAND, ERR_R_INTERNAL_ERROR);
- return 0;
+ goto err;
}
*p++ = OSSL_PARAM_construct_int(OSSL_KDF_PARAM_MODE, &mode);
@@ -105,12 +127,10 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
hkdflabel, hkdflabellen);
*p++ = OSSL_PARAM_construct_end();
- ret = EVP_KDF_CTX_set_params(kctx, params) <= 0
- || EVP_KDF_derive(kctx, out, outlen) <= 0;
-
- EVP_KDF_CTX_free(kctx);
+ ret = EVP_KDF_CTX_set_params(kctx, params) > 0
+ && EVP_KDF_derive(kctx, out, outlen) > 0;
- if (ret != 0) {
+ if (!ret) {
if (fatal)
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS13_HKDF_EXPAND,
ERR_R_INTERNAL_ERROR);
@@ -118,7 +138,13 @@ int tls13_hkdf_expand(SSL *s, const EVP_MD *md, const unsigned char *secret,
SSLerr(SSL_F_TLS13_HKDF_EXPAND, ERR_R_INTERNAL_ERROR);
}
- return ret == 0;
+ err:
+#ifdef OPENSSL_SMALL_FOOTPRINT
+ if (hkdflabel != hkdflabelst)
+ OPENSSL_free(hkdflabel);
+#endif
+ EVP_KDF_CTX_free(kctx);
+ return ret;
}
/* |
|
I could not imagine any use case where SSL_export_keying_material is
used at all.
SSL_export_keying_material() is used to do channel or token binding.
For instance binding an oauth token or a cookie to a specific TLS
session, so that it can't be used in an other session. Other
examples that make use of that is FIDO, SRTP, WPA and NTP's NTS.
|
Thanks @mattcaswell for trying to bridge the gap! To me this looks like a reasonable compromise, it guarantees that for constrained devices waste is minimal in the common case, without compromising interoperability! |
2459a12 to
0ae6773
Compare
I see no valid use case in such labels. [extended tests]
0ae6773 to
63ac1b6
Compare
|
Interesting, I never saw travis fail with a "No space left on device" error: |
|
I applied the OTC hold. I'm the only person who can remove it without a vote being held. I've called an OTC vote for this. |
|
The vote is effectively finished:
The vote to merge this failed. |
topic: Accept and merge #11577.
comment: #11577 reduces the maximum length of TLS labels.
It also breaks standards compliance.
Personal notes:
- My vote is against the current implementation of #11577, which does
break standard compliance.
I wouldn't be against an hybrid solution like Matt's at
openssl/openssl#11577 (comment)
but I am not capable of saying if the added complexity would be
balanced by the effective benefits for platforms with limited stack
resources.
- My vote here is only on the matter of breaking standards compliance.
It has nothing to do with the other concerns raised alongside the
technical discussion in #11577: as I see it, those matters are not
within the OTC responsibility.
I see no valid use case in such labels.
[extended tests]
Checklist