TeslaGov / ngx-http-auth-jwt-module

Secure your NGINX locations with JWT
MIT License
317 stars 122 forks source link

Invalid "Authorization" header may lead to segmentation fault #40

Closed max-lt closed 3 years ago

max-lt commented 6 years ago

Invalid "Authorization" header may lead to segmentation fault:

2018/06/06 22:03:26 [emerg] 8#8: *10 malloc(18446744073709551611) failed (12: Out of memory), client: 172.17.0.1, server: localhost, request: "GET /secure-auth-header/ HTTP/1.1", host: "localhost:8000"
2018/06/06 22:03:27 [notice] 1#1: signal 17 (SIGCHLD) received from 8
2018/06/06 22:03:27 [alert] 1#1: worker process 8 exited on signal 11 (core dumped)
2018/06/06 22:03:27 [notice] 1#1: start worker process 9

How to reproduce:

Cause:

Line 422: authorizationHeaderStr.len = authorizationHeader->value.len - (sizeof("Bearer ") - 1); -> "len" can be negative and it will fail in the ngx_str_t_to_char_ptr function on memory allocation.

aaronesau-summit commented 4 years ago

@fitzyjoe is there any update on this? It seems like a trivial fix, and I think this might be able to be exploited as an out of bounds read vulnerability. I can submit a PR if you'd like.

JoshMcCullough commented 3 years ago

@fitzyjoe Can you review the #61 ?

eutychus commented 3 years ago

@JoshMcCullough @fitzyjoe I provided a PR that fixes this and updates the test case. Can I get this reviewed and merged?

fitzyjoe commented 3 years ago

Merged PR to fix this. Thanks!