Skip to content

Commit 219b040

Browse files
fix: Control default deny list via an env var (#5862)
* Control default deny list via an env var * fix: Control default deny list via an env var ---------
1 parent d6ee015 commit 219b040

8 files changed

Lines changed: 22 additions & 8 deletions

File tree

docker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ JWT_REFRESH_TOKEN_EXPIRY_IN_MINUTES=43200
183183
############################################################################################################
184184

185185
# HTTP_DENY_LIST=
186+
# HTTP_SECURITY_CHECK=true
186187
# CUSTOM_MCP_SECURITY_CHECK=true
187188
# CUSTOM_MCP_PROTOCOL=sse #(stdio | sse)
188189
# TRUST_PROXY=true #(true | false | 1 | loopback| linklocal | uniquelocal | IP addresses | loopback, IP addresses)

docker/docker-compose-queue-prebuilt.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ services:
147147
- CUSTOM_MCP_SECURITY_CHECK=${CUSTOM_MCP_SECURITY_CHECK}
148148
- CUSTOM_MCP_PROTOCOL=${CUSTOM_MCP_PROTOCOL}
149149
- HTTP_DENY_LIST=${HTTP_DENY_LIST}
150+
- HTTP_SECURITY_CHECK=${HTTP_SECURITY_CHECK}
150151
- TRUST_PROXY=${TRUST_PROXY}
151152
healthcheck:
152153
test: ['CMD', 'curl', '-f', 'http://localhost:${PORT:-3000}/api/v1/ping']
@@ -293,6 +294,7 @@ services:
293294
- CUSTOM_MCP_SECURITY_CHECK=${CUSTOM_MCP_SECURITY_CHECK}
294295
- CUSTOM_MCP_PROTOCOL=${CUSTOM_MCP_PROTOCOL}
295296
- HTTP_DENY_LIST=${HTTP_DENY_LIST}
297+
- HTTP_SECURITY_CHECK=${HTTP_SECURITY_CHECK}
296298
- TRUST_PROXY=${TRUST_PROXY}
297299
healthcheck:
298300
test: ['CMD', 'curl', '-f', 'http://localhost:${WORKER_PORT:-5566}/healthz']

docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ services:
132132
- CUSTOM_MCP_SECURITY_CHECK=${CUSTOM_MCP_SECURITY_CHECK}
133133
- CUSTOM_MCP_PROTOCOL=${CUSTOM_MCP_PROTOCOL}
134134
- HTTP_DENY_LIST=${HTTP_DENY_LIST}
135+
- HTTP_SECURITY_CHECK=${HTTP_SECURITY_CHECK}
135136
- TRUST_PROXY=${TRUST_PROXY}
136137
ports:
137138
- '${PORT}:${PORT}'

docker/worker/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ JWT_REFRESH_TOKEN_EXPIRY_IN_MINUTES=43200
183183
############################################################################################################
184184

185185
# HTTP_DENY_LIST=
186+
# HTTP_SECURITY_CHECK=true
186187
# CUSTOM_MCP_SECURITY_CHECK=true
187188
# CUSTOM_MCP_PROTOCOL=sse #(stdio | sse)
188189
# TRUST_PROXY=true #(true | false | 1 | loopback| linklocal | uniquelocal | IP addresses | loopback, IP addresses)

docker/worker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ services:
132132
- CUSTOM_MCP_SECURITY_CHECK=${CUSTOM_MCP_SECURITY_CHECK}
133133
- CUSTOM_MCP_PROTOCOL=${CUSTOM_MCP_PROTOCOL}
134134
- HTTP_DENY_LIST=${HTTP_DENY_LIST}
135+
- HTTP_SECURITY_CHECK=${HTTP_SECURITY_CHECK}
135136
- TRUST_PROXY=${TRUST_PROXY}
136137
ports:
137138
- '${WORKER_PORT}:${WORKER_PORT}'

packages/components/src/httpSecurity.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,25 @@ const DEFAULT_DENY_LIST = [
2727
]
2828

2929
/**
30-
* Gets the HTTP deny list, always including default protections plus any custom entries
31-
* @returns Array of denied IP addresses/CIDR ranges (always includes DEFAULT_DENY_LIST)
30+
* Gets the HTTP deny list.
31+
* When HTTP_SECURITY_CHECK=false, the default deny list is omitted and only
32+
* HTTP_DENY_LIST entries are used. Defaults to true (secure).
33+
* @returns Array of denied IP addresses, hostnames, or CIDR ranges
3234
*/
3335
function getHttpDenyList(): string[] {
36+
const securityCheckEnabled = process.env.HTTP_SECURITY_CHECK !== 'false'
3437
const httpDenyListString = process.env.HTTP_DENY_LIST
35-
if (httpDenyListString) {
36-
const customList = httpDenyListString
37-
.split(',')
38-
.map((s) => s.trim())
39-
.filter(Boolean)
38+
const customList = httpDenyListString
39+
? httpDenyListString
40+
.split(',')
41+
.map((s) => s.trim())
42+
.filter(Boolean)
43+
: []
44+
45+
if (securityCheckEnabled) {
4046
return [...new Set([...DEFAULT_DENY_LIST, ...customList])]
4147
}
42-
return DEFAULT_DENY_LIST
48+
return customList
4349
}
4450

4551
/**

packages/server/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ JWT_REFRESH_TOKEN_EXPIRY_IN_MINUTES=43200
183183
############################################################################################################
184184

185185
# HTTP_DENY_LIST=
186+
# HTTP_SECURITY_CHECK=true
186187
# CUSTOM_MCP_SECURITY_CHECK=true
187188
# CUSTOM_MCP_PROTOCOL=sse #(stdio | sse)
188189
# TRUST_PROXY=true #(true | false | 1 | loopback| linklocal | uniquelocal | IP addresses | loopback, IP addresses)

packages/server/src/commands/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export abstract class BaseCommand extends Command {
101101
CUSTOM_MCP_SECURITY_CHECK: Flags.string(),
102102
CUSTOM_MCP_PROTOCOL: Flags.string(),
103103
HTTP_DENY_LIST: Flags.string(),
104+
HTTP_SECURITY_CHECK: Flags.string(),
104105
TRUST_PROXY: Flags.string(),
105106

106107
// Auth

0 commit comments

Comments
 (0)