comparison src/http/v2/ngx_http_v2.c @ 7883:41f4bd4c51f1

Disabled control characters and space in header names. Control characters (0x00-0x1f, 0x7f), space, and colon were never allowed in header names. The only somewhat valid use is header continuation which nginx never supported and which is explicitly obsolete by RFC 7230. Previously, such headers were considered invalid and were ignored by default (as per ignore_invalid_headers directive). With this change, such headers are unconditionally rejected. It is expected to make nginx more resilient to various attacks, in particular, with ignore_invalid_headers switched off (which is inherently unsecure, though nevertheless sometimes used in the wild).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 28 Jun 2021 18:01:18 +0300
parents 63c66b7cc07c
children 51f463301f86
comparison
equal deleted inserted replaced
7882:b4073527be81 7883:41f4bd4c51f1
3455 || (ch == '_' && cscf->underscores_in_headers)) 3455 || (ch == '_' && cscf->underscores_in_headers))
3456 { 3456 {
3457 continue; 3457 continue;
3458 } 3458 }
3459 3459
3460 if (ch == '\0' || ch == LF || ch == CR || ch == ':' 3460 if (ch <= 0x20 || ch == 0x7f || ch == ':'
3461 || (ch >= 'A' && ch <= 'Z')) 3461 || (ch >= 'A' && ch <= 'Z'))
3462 { 3462 {
3463 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, 3463 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
3464 "client sent invalid header name: \"%V\"", 3464 "client sent invalid header name: \"%V\"",
3465 &header->name); 3465 &header->name);