{"record":{"id":"778604176ff1205b","repo":"nginx/nginx","slug":"ngx-log-alert-778604","errorCode":"NGX_LOG_ALERT","errorMessage":"unexpected secret len: %uz","messagePattern":"unexpected secret len: %uz","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/event/quic/ngx_event_quic_protection.c","lineNumber":689,"sourceCode":"    ngx_quic_md_t        key;\n    ngx_quic_hkdf_t      seq[3];\n    ngx_quic_secret_t   *peer_secret;\n    ngx_quic_ciphers_t   ciphers;\n\n    peer_secret = is_write ? &keys->secrets[level].server\n                           : &keys->secrets[level].client;\n\n    keys->cipher = SSL_CIPHER_get_id(cipher);\n\n    key_len = ngx_quic_ciphers(keys->cipher, &ciphers);\n\n    if (key_len == NGX_ERROR) {\n        ngx_ssl_error(NGX_LOG_INFO, log, 0, \"unexpected cipher\");\n        return NGX_ERROR;\n    }\n\n    if (sizeof(peer_secret->secret.data) < secret_len) {\n        ngx_log_error(NGX_LOG_ALERT, log, 0,\n                      \"unexpected secret len: %uz\", secret_len);\n        return NGX_ERROR;\n    }\n\n    peer_secret->secret.len = secret_len;\n    ngx_memcpy(peer_secret->secret.data, secret, secret_len);\n\n    key.len = key_len;\n    peer_secret->iv.len = NGX_QUIC_IV_LEN;\n    peer_secret->hp.len = key_len;\n\n    secret_str.len = secret_len;\n    secret_str.data = (u_char *) secret;\n\n    ngx_quic_hkdf_set(&seq[0], \"tls13 quic key\", &key, &secret_str);\n    ngx_quic_hkdf_set(&seq[1], \"tls13 quic iv\", &peer_secret->iv, &secret_str);\n    ngx_quic_hkdf_set(&seq[2], \"tls13 quic hp\", &peer_secret->hp, &secret_str);\n","sourceCodeStart":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/nginx/nginx/blob/3f6f7824d4e2eb1ac37dec76683d525ac0ff521c/src/event/quic/ngx_event_quic_protection.c#L671-L707","documentation":"In the set-encryption-secret path, nginx copies the secret handed over by the SSL library into the fixed-size buffer peer_secret->secret.data; if secret_len exceeds that size it logs ALERT 'unexpected secret len: %uz' and the handshake fails. Standard suites never exceed the buffer (SHA-384 secrets are 48 bytes), so a hit means the library emitted an unexpected secret length - almost always a build/runtime mismatch between nginx and its SSL library, or a nonstandard provider altering key derivation.","triggerScenarios":"nginx running against a different OpenSSL family than it was compiled with; custom ciphers or FIPS providers with altered secret sizes.","commonSituations":"Library swaps via LD_LIBRARY_PATH after deployment; containers where the base image OpenSSL changed under a copied nginx binary.","solutions":["Confirm the loaded library matches the build (ldd, nginx -V) and fix rpath or library paths","Rebuild nginx in the target environment against the exact SSL library it will load","If a custom provider is in play, verify its secret sizes against RFC 8446/9001 suites"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"nginx -V 2>&1 | grep 'built with OpenSSL'\nldd \"$(command -v nginx)\" | grep -E 'libssl|libcrypto'\n# the two must name the same library family/version","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build nginx in the same environment that runs it","Bake nginx and libssl into one immutable image; never mix release trains"],"tags":["nginx","quic","openssl","encryption-secret","build-mismatch","handshake-failure"],"backgroundTag":"openssl-api-mismatch","analyzedSha":"3f6f7824d4e2eb1ac37dec76683d525ac0ff521c","analyzedAt":"2026-08-22T03:09:46.447Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}