# Copyright 2026 Tailwind Resource Group # SPDX-License-Identifier: Apache-2.0 # Provided as is, with no warranty. License: https://everythingsfine.io/license/ # # n2s_reject_brotli_body # # Tested on BIG-IP 17.5.1.x. Start in log-only mode. # # Purpose: find, and optionally reject, HTTP requests that send a # Brotli-compressed body (Content-Encoding: br) to a Node.js application, # until the application runs Node.js 22.23.4, 24.22.1, 26.12.1 or later # (CVE-2026-111497, "Node2Shell"). # # This iRule does not replace the upgrade. It does not stop Brotli data # that reaches the application in other ways (file uploads, WebSocket # messages, queues), and it does not protect fetch() responses. # # Attach to: each virtual server in front of a Node.js application. # Scope: every request. The iRule reads headers only, not the body. # Log: /var/log/ltm, prefix "n2s:". The iRule does not log the body. when RULE_INIT { # 1 = log only. 0 = log and reject with HTTP 415. set static::n2s_log_only 1 } when HTTP_REQUEST priority 50 { set n2s_found 0 foreach n2s_value [HTTP::header values "Content-Encoding"] { foreach n2s_token [split [string tolower $n2s_value] ","] { if { [string trim $n2s_token " \t"] eq "br" } { set n2s_found 1 break } } if { $n2s_found } { break } } if { !$n2s_found } { return } log local0.warning "n2s: reason=brotli_request_body client=[IP::client_addr] vs=[virtual name] method=[HTTP::method] path=[HTTP::path] enforce=[expr {!$static::n2s_log_only}]" if { !$static::n2s_log_only } { HTTP::respond 415 content "Unsupported Media Type" "Content-Type" "text/plain" "Connection" "close" } }