Skip to content

Conversation

@Fahnenfluchtige
Copy link
Contributor

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
@zhuizhuhaomeng zhuizhuhaomeng merged commit ee2422f into openresty:master Jun 21, 2025
2 of 3 checks passed
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.

2 participants