Skip to content

Commit 93ece19

Browse files
authored
Fix read of uninitialized data (#155)
1 parent 219b603 commit 93ece19

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/ngx_http_auth_jwt_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ static ngx_int_t get_jwt_var_claim(ngx_http_request_t *r, ngx_http_variable_valu
355355

356356
ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "getting jwt var claim for var at index %l", *claim_idx);
357357

358-
if (ctx == NULL)
358+
if (ctx == NULL || ctx->validation_status != NGX_OK)
359359
{
360360
ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "no module context found while getting jwt value");
361361

test/test.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,13 @@ main() {
341341
-c 200 \
342342
-r 'sub: some-long-uuid$' \
343343
-x '--header "Authorization: Bearer ${JWT_HS256_VALID}"'
344+
345+
run_test -n 'fails gracefully when extracting single claim as var with no JWT, auth jwt enabled' \
346+
-p '/secure/extract-claim/body/sub' \
347+
-c 200 \
348+
-r 'sub: '
344349

345-
run_test -n 'fails gracefully when extracting single claim as var with no JWT' \
350+
run_test -n 'fails gracefully when extracting single claim as var with no JWT, auth jwt disbaled' \
346351
-p '/unsecure/extract-claim/body/sub' \
347352
-c 200 \
348353
-r 'sub: '

0 commit comments

Comments
 (0)