---
title: "ngx_mruby v2.7.11"
language: "en"
documentation_version: "2.x"
channel: "maintenance"
release_context: {"latest_release_tag":"v2.7.12","unreleased_versions":[],"latest_release_revision":"49d26b879df732f8260f8454b90b0774789ef818"}
source_revision: "49d26b879df732f8260f8454b90b0774789ef818"
working_tree_clean: true
source_path: "docs/releases/v2.7.11.md"
source_sha256: "e1876e9a9db5ecdc7d2404533b2cc3721da65ead8afd14e1c123a38c6c39a131"
source_at_revision: true
source_url: "https://github.com/matsumotory/ngx_mruby/blob/49d26b879df732f8260f8454b90b0774789ef818/docs/releases/v2.7.11.md"
html_url: "https://ngx.mruby.org/v2/releases/v2.7.11/"
markdown_url: "https://ngx.mruby.org/v2/markdown/releases/v2.7.11.md"
last_updated: "2026-11-17"
---

# ngx_mruby v2.7.11

## Behavior changes: read before upgrading

### 1. Nginx::Var assigns a variable that has a set_handler, such as $args or $limit_rate

Security advisory (assigning a variable that has a set_handler through `Nginx::Var`): [GHSA-r7v5-479r-hmqr](https://github.com/matsumotory/ngx_mruby/security/advisories/GHSA-r7v5-479r-hmqr).

- Before: the `Nginx::Var` accessor (`v.name = value`) and `Nginx::Var#set(name, value)`,
  when the name is an nginx variable that has a set_handler — a changeable variable
  whose assignment nginx routes through a handler, such as `$args` or `$limit_rate` —
  allocated the value struct (`ngx_http_variable_value_t`) with `ngx_palloc` and called
  the set_handler before filling its fields. The set_handler read `len` and `data` from
  the uninitialised struct: `$limit_rate` parsed an uninitialised size, and `$args`
  copied an uninitialised length and pointer into `r->args`. The assigned value
  therefore did not take effect, and using the variable afterwards — reading it back, or
  sending `$args` toward a client — read uninitialised worker memory, which could end the
  worker process or send worker memory out.
- Now: ngx_mruby fills the value struct (its flags, `data` and `len`) before it calls the
  set_handler, as nginx does when it assigns such a variable. Both the accessor
  (`ngx_mrb_var_set_vector`) and `Nginx::Var#set` (`ngx_mrb_var_set_func`) are changed, so
  the assigned value takes effect for every variable that has a set_handler.
- Why it changed:
  - The defect: the set_handler was called with a value struct straight from `ngx_palloc`,
    whose fields were not set, so it read an uninitialised length and pointer.
  - Why the old behavior could not be kept: the assignment did not reach the variable, and
    the uninitialised read is memory-unsafety — on a reused worker the memory could hold
    fragments of earlier data and heap pointers, and `$args` can carry them toward a
    client.
  - What the documentation promised: the accessor,
    [`Nginx::Var#method_missing`](/v2/reference/ruby/#nginxvarmethod_missingsymbol--args---result),
    and [`Nginx::Var#set`](/v2/reference/ruby/#nginxvarsetname-value) say they set the
    value to the nginx variable. They do not say that assigning a variable that has a
    set_handler leaves it unset or reads other memory.
- Affected: a configuration whose mruby code assigns `$args`, `$limit_rate` or another
  variable that has a set_handler through `Nginx::Var` (the accessor or `#set`) and then
  uses the variable.
- What to do: nothing; the assignment works. On an earlier release that you cannot
  upgrade, set these variables through the nginx configuration instead of `Nginx::Var`.
- Tests: port 18104 (`test/t/cases/var_setter_init.rb`).

### 2. Deleting a request or response header stays inside the header list, matches the exact name, and keeps a header added afterwards

Security advisory (deleting a request or response header): [GHSA-2gcp-h74q-c9g6](https://github.com/matsumotory/ngx_mruby/security/advisories/GHSA-2gcp-h74q-c9g6).

- Before: `ngx_mrb_del_request_header` (`Nginx::Headers_in#delete` / `Nginx::Headers_out#delete`,
  and the `[]=` update path, which deletes before it adds) walked the header ngx_list and,
  on a match in the middle of a full part, split the part: it made a second part that
  pointed inside the part's array and set `headers->last` to it, so the next
  `ngx_list_push` wrote one element past the end of that array — a heap buffer overflow
  into adjacent worker-pool memory, which could end the worker process. It also compared
  only the requested name's length, so a name that is a prefix of a longer stored header
  matched and deleted that longer header, and a stored name shorter than the requested name
  was read past its end; and when the first part emptied
  while a second part existed, it adopted the next part without moving `headers->last`, so
  a header added afterwards was written into the detached part and could not be read back.
- Now: the delete removes the matching element without moving the other elements, so the
  pointers nginx caches into this list stay on the same headers: the `ngx_table_elt_t *` it
  keeps for a well-known header (`r->headers_in.user_agent` and the like) and the same-name
  `next` chains (for example Cookie or X-Forwarded-For). It keeps `headers->nalloc` at or
  below the number of elements the last part's array can hold from its current start (used
  elements included), so `ngx_list_push`, which starts a new part once a part reaches
  `nalloc`, does not write past the last part's array. It compares the length of
  the name before its bytes, so a name that is a prefix of a stored header no longer matches
  and the compare does not read past a shorter stored key. It keeps `headers->last` and
  `headers->nalloc` in step when an emptied part is unlinked and when the first part adopts
  the next.
- Why it changed:
  - The defect: the split left `headers->last` pointing inside a full array so the next
    push wrote past it; the compare ignored the stored name's length; and adopting the next
    part did not move `headers->last`.
  - Why the old behavior could not be kept: the out-of-bounds write is memory-unsafety
    (heap corruption that can end the worker); deleting a longer header by a prefix of its
    name is wrong; and a header added after the first part emptied was lost.
  - What the documentation promised:
    [`Nginx::Headers_in#delete`](/v2/reference/ruby/#nginxheaders_indeletestring) and
    [`Nginx::Headers_out#delete`](/v2/reference/ruby/#nginxheaders_outdeletestring) say delete removes the header of
    the given name. They do not say that it removes a header whose name only begins with
    the given name, that it writes past a list part, or that a header added afterwards can
    be lost.
- Affected: a configuration whose mruby code deletes request or response headers (and, for
  the overflow, adds headers to a request that already carries enough headers to fill a
  list part); and, for the prefix case, a configuration that deleted a header by a name
  that is a prefix of another header and relied on both being removed.
- What to do: nothing for the overflow and the lost header. For the prefix case, delete
  each header by its exact name.
- Tests: port 18105 (`test/t/cases/header_del.rb`).

## New features

None.

## Fixes

None.

## Build and test changes

- `test/t/cases/var_setter_init.rb` (with `test/conf/conf.d/72-var-setter-init.conf`,
  port 18104, and `test/html/var_setter_init.rb`) assigns `$args` through the setter of
  `Nginx::Var` and through `Nginx::Var#set` and reads it back ([GHSA-r7v5-479r-hmqr](https://github.com/matsumotory/ngx_mruby/security/advisories/GHSA-r7v5-479r-hmqr))
- `test/t/cases/header_del.rb` (with `test/conf/conf.d/73-header-del.conf`, port 18105, and
  `test/html/header_del.rb`) deletes a request header: a name that is a prefix of a header,
  emptying the full first part while a second part exists, deleting from the middle of
  a full part before adding headers, and deleting a middle header and then the first header
  so that a later `User-Agent` keeps the pointer nginx caches for it
  (`r->headers_in.user_agent`, which `$http_user_agent` reads) ([GHSA-2gcp-h74q-c9g6](https://github.com/matsumotory/ngx_mruby/security/advisories/GHSA-2gcp-h74q-c9g6))

## Upgrading

- No directive was added, renamed or removed. Rebuild the module with this release the way
  you built 2.7.10, and replace the binary or the dynamic module as usual.
  `Nginx.module_version` returns `2.7.11`.

Read "Behavior changes: read before upgrading" above before upgrading.
