Skip to content

Commit 292d738

Browse files
authored
Merge pull request #1417 from 3scale/cve-2023-44487-rapid-reset
THREESCALE-10224 CVE-2023-44487 http/2 rapid reset
2 parents 8227112 + 4d1c3e6 commit 292d738

File tree

10 files changed

+52
-8
lines changed

10 files changed

+52
-8
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ executors:
105105
openresty:
106106
working_directory: /opt/app-root/apicast
107107
docker:
108-
- image: quay.io/3scale/apicast-ci:openresty-1.19.3-pr1379
108+
- image: quay.io/3scale/apicast-ci:openresty-1.19.3-23
109109
- image: redis:3.2.8-alpine
110110
environment:
111111
TEST_NGINX_BINARY: openresty

.codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,14 @@ ignore:
66
- t
77
- bin/busted.lua
88
- examples
9+
10+
coverage:
11+
status:
12+
project:
13+
default:
14+
target: auto
15+
threshold: 3%
16+
patch:
17+
default:
18+
target: auto
19+
threshold: 3%

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed CVE-2023-44487 (HTTP/2 Rapid Reset) [PR #1417](https://github.com/3scale/apicast/pull/1417) [THREESCALE-10224](https://issues.redhat.com/browse/THREESCALE-10224)
13+
1014
### Added
1115

1216
- Detect number of CPU shares when running on Cgroups V2 [PR #1410](https://github.com/3scale/apicast/pull/1410) [THREESCALE-10167](https://issues.redhat.com/browse/THREESCALE-10167)

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM registry.access.redhat.com/ubi8:8.5
22

3-
ARG OPENRESTY_RPM_VERSION="1.19.3-21.el8"
3+
ARG OPENRESTY_RPM_VERSION="1.19.3-23.el8"
44
ARG LUAROCKS_VERSION="2.3.0"
55
ARG JAEGERTRACING_CPP_CLIENT_RPM_VERSION="0.3.1-13.el8"
66

Dockerfile.devel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM registry.access.redhat.com/ubi8:8.5
22

3-
ARG OPENRESTY_RPM_VERSION="1.19.3-21.el8"
3+
ARG OPENRESTY_RPM_VERSION="1.19.3-23.el8"
44
ARG LUAROCKS_VERSION="2.3.0"
55
ARG JAEGERTRACING_CPP_CLIENT_RPM_VERSION="0.3.1-13.el8"
66

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ NPROC ?= $(firstword $(shell nproc 2>/dev/null) 1)
1313

1414
SEPARATOR="\n=============================================\n"
1515

16-
DEVEL_IMAGE ?= quay.io/3scale/apicast-ci:openresty-1.19.3-pr1379
16+
DEVEL_IMAGE ?= quay.io/3scale/apicast-ci:openresty-1.19.3-23
1717
DEVEL_DOCKERFILE ?= Dockerfile.devel
1818

1919
RUNTIME_IMAGE ?= quay.io/3scale/apicast:latest
@@ -64,9 +64,9 @@ export COMPOSE_PROJECT_NAME
6464
# The development image is also used in CI (circleCI) as the 'openresty' executor
6565
# When the development image changes, make sure to:
6666
# * build a new development image:
67-
# make dev-build IMAGE_NAME=quay.io/3scale/apicast-ci:openresty-1.19.3-pr{NUM}
67+
# make dev-build IMAGE_NAME=quay.io/3scale/apicast-ci:openresty-X.Y.Z-{release_number}
6868
# * push to quay.io/3scale/apicast-ci with a fixed tag (avoid floating tags)
69-
# docker push quay.io/3scale/apicast-ci:openresty-1.19.3-pr{NUM}
69+
# docker push quay.io/3scale/apicast-ci:openresty-X.Y.Z-{release_number}
7070
# * update .circleci/config.yaml openresty executor with the image URL
7171
.PHONY: dev-build
7272
dev-build: export OPENRESTY_RPM_VERSION?=1.19.3

docker-compose-devel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
version: '2.2'
33
services:
44
development:
5-
image: ${IMAGE:-quay.io/3scale/apicast-ci:openresty-1.19.3-pr1379}
5+
image: ${IMAGE:-quay.io/3scale/apicast-ci:openresty-1.19.3-23}
66
platform: "linux/amd64"
77
depends_on:
88
- redis

gateway/conf.d/apicast.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set_by_lua_block $deployment {
33
return require('apicast.user_agent').deployment()
44
}
55

6+
lua_check_client_abort on;
7+
68
# TODO: enable in the future when we support SSL
79
# ssl_certificate_by_lua_block { require('apicast.executor').call() }
810
# ssl_session_fetch_by_lua_block { require('apicast.executor').call() }

gateway/src/apicast/policy/apicast/apicast.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ end
3030

3131
function _M.cleanup()
3232
-- now abort all the "light threads" running in the current request handler
33+
ngx.log(ngx.INFO, "client closed the (downstream) connection prematurely.")
3334
ngx.exit(499)
3435
end
3536

3637
function _M:rewrite(context)
37-
ngx.on_abort(self.cleanup)
38+
local ok, err = ngx.on_abort(self.cleanup)
39+
if not ok then
40+
ngx.log(ngx.ERR, "failed to register the on_abort callback: ", err)
41+
ngx.exit(500)
42+
end
3843

3944
-- load configuration if not configured
4045
-- that is useful when lua_code_cache is off
@@ -87,6 +92,12 @@ function _M:post_action(context)
8792
end
8893

8994
function _M:access(context)
95+
local ok, err = ngx.on_abort(self.cleanup)
96+
if not ok then
97+
ngx.log(ngx.ERR, "failed to register the on_abort callback: ", err)
98+
ngx.exit(500)
99+
end
100+
90101
if context.skip_apicast_access then return end
91102

92103
-- Flag to run post_action() only when access() was executed.
@@ -108,6 +119,12 @@ function _M:access(context)
108119
end
109120

110121
function _M:content(context)
122+
local ok, err = ngx.on_abort(self.cleanup)
123+
if not ok then
124+
ngx.log(ngx.ERR, "failed to register the on_abort callback: ", err)
125+
ngx.exit(500)
126+
end
127+
111128
if not context[self].upstream then
112129
ngx.log(ngx.WARN, "Upstream server not found for this request")
113130
return errors.upstream_not_found(context.service)

spec/policy/apicast/apicast_spec.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
local _M = require 'apicast.policy.apicast'
22

33
describe('APIcast policy', function()
4+
local ngx_on_abort_stub
5+
6+
before_each(function()
7+
-- .access calls ngx.on_abort
8+
-- busted tests are called in the context of ngx.timer
9+
-- and that API ngx.on_abort is disabled in that context.
10+
-- this stub is mocking the call
11+
-- to prevent the internal error: API disabled in the context of ngx.timer
12+
ngx_on_abort_stub = stub(ngx, 'on_abort')
13+
end)
414

515
it('has a name', function()
616
assert.truthy(_M._NAME)

0 commit comments

Comments
 (0)