SSLContext#min_version= and #max_version= silently accept prefix strings and empty strings
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
The issue points to parse_proto_version() in ext/openssl/ossl_ssl.c and shows the current comparison and suggested length check. Read that function and locate its tests for SSLContext#min_version= and #max_version=. Add coverage for empty strings, prefixes, and embedded NUL bytes, and confirm they raise ArgumentError while full version names still work.
Written by the indexing model from the issue text.
Description
Description
parse_proto_version() in ext/openssl/ossl_ssl.c compares the input protocol version name using strncmp(map[i].name, RSTRING_PTR(str), RSTRING_LEN(str)) without verifying that the string lengths match.
// ext/openssl/ossl_ssl.c:879-882
for (i = 0; i < numberof(map); i++)
if (!strncmp(map[i].name, RSTRING_PTR(str), RSTRING_LEN(str)))
return map[i].version;
rb_raise(rb_eArgError, "unrecognized version %+"PRIsVALUE, str);
Actual Behavior
Because only RSTRING_LEN(str) bytes are compared:
""(empty string),"S", or"SSL"silently matches"SSL2"(SSL2_VERSION)"T","TLS", or:TLSsilently matches"TLS1"(TLS1_VERSION)- Strings with embedded NUL bytes (e.g.,
"TLS1\0_3") silently match"TLS1"(TLS1_VERSION)
Expected Behavior
Empty strings, partial prefixes, and strings containing embedded NUL bytes should raise ArgumentError (unrecognized version).
Suggested Fix
Verify that the string lengths are equal and compare using memcmp():
for (i = 0; i < numberof(map); i++)
if ((size_t)RSTRING_LEN(str) == strlen(map[i].name) &&
memcmp(map[i].name, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
return map[i].version;
(Discussed with @rhenium on [email protected] and agreed to track here as a regular bug.)
- Dominant language
- C
- Stars
- 276
- Forks
- 205
- Avg merge
- 21h 17m
- Merged PRs (30d)
- 17
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/openssl
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Maintainers usually reply within 1 day
-
Add OpenSSL::SSL::SSLContext#client_hello_cb= (binding for SSL_CTX_set_client_hello_cb())Possibly taken @kou claimed this 37 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 53/100
ruby/openssl#1125 · 6 comments ·
Maintainers usually reply within 1 day
-
Documenting how to use OpenSSL::SSL::SSLContext in PQC use casesPossibly taken @junaruga claimed this 23 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 55/100
ruby/openssl#1118 · 6 comments ·
Maintainers usually reply within 1 day
-
Expose XOFs like SHAKE128 and SHAKE256Possibly taken @rhenium claimed this 133 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
ruby/openssl#1082 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
ruby/openssl#1075 · 4 comments ·
Maintainers usually reply within 1 day
Similar issues
-
isolation2 lockmodes fails on cassert builds: extra AccessShareLock on partition rootPossibly taken @tuhaihe claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/cloudberry#2356 ·
Maintainers usually reply within 2 days
-
windows-artifacts: the win-arm64 job uses a Visual Studio generator missing from windows-11-armOpen
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
wasm-micro-runtime/wasm-micro-runtime#5217 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HandBrake/HandBrake#8278 · 1 comment ·
Maintainers usually reply within 1 day