Skip to content

fixes: add error check for SSL_set_tlsext_status_type #374

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Fahnenfluchtige
Copy link

The Svace static analysis tool identified a potential issue in the function ngx_stream_lua_socket_tcp_sslhandshake. The call to SSL_set_tlsext_status_type() was made without checking its return value.

This can lead to a situation where OCSP stapling fails silently, possibly resulting in an incomplete TLS configuration.

The fix adds an explicit check for the return value of SSL_set_tlsext_status_type(). If the function returns error, a Lua error is raised

index 2cddfd9..396e308 100644
--- a/src/ngx_stream_lua_socket_tcp.c
+++ b/src/ngx_stream_lua_socket_tcp.c
@@ -1792,8 +1792,10 @@ ngx_stream_lua_socket_tcp_sslhandshake(lua_State *L)
                 if (n >= 5) {
                     if (lua_toboolean(L, 5)) {
 #ifdef NGX_STREAM_LUA_USE_OCSP
-                        SSL_set_tlsext_status_type(c->ssl->connection,
-                                                   TLSEXT_STATUSTYPE_ocsp);
+                        if (SSL_set_tlsext_status_type(c->ssl->connection,
+                                TLSEXT_STATUSTYPE_ocsp) != 1) {
+                            return luaL_error(L, "failed to enable OCSP stapling");
+                        }
 #else
                         return luaL_error(L, "no OCSP support");
 #endif

@Fahnenfluchtige Fahnenfluchtige changed the title Adding error checking fixes: add error check for SSL_set_tlsext_status_type May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant