Secure C2 links
UAT 367 Cybersecurity, Command and Control Links and Unmanned Aircraft Systems Traffic Management
Lesson
By the end of this module you will be able to
- Explain the structure of MAVLink 2 signatures and the replay protection rules
- Create and verify MAVLink 2 frame signatures with SHA-256
- Distinguish authentication from encryption and use DTLS/TLS and AES-GCM correctly
- Design a dual-path C2 and assess its availability
- Encrypt and authenticate a telemetry message with AES-GCM using unique nonces, and state what autopilot signing does not protect
Why this matters
The C2 (command and control) link carries commands to the drone and status back. UAT 312 covered designing a link with enough signal and procedures for when it is lost. This module asks the next question: how does the drone know a command really came from its pilot? Without authentication, anyone with a radio on the same frequency who knows the protocol can send a land or reroute command. In Module 1’s threat model this threat scored 15, high risk.
MAVLink 2 signatures
The MAVLink guide specifies that a signed frame sets the first incompat flag (0x01) and appends a 13-byte signature block:
- Link ID, 1 byte, separating paths such as radio and LTE.
- Timestamp, 6 bytes, in units of 10 microseconds since 1 January 2015 GMT.
- Signature, 6 bytes: the first 48 bits of SHA-256 over the 32-byte secret key followed by the header, payload, CRC, link ID and timestamp.
Replay protection rules from the guide: the timestamp must be greater than that of the previous message on the same stream (system ID, component ID, link ID), and a message whose timestamp is more than 1 minute behind the receiver’s time must be rejected. Without these rules, an attacker could record a valid land command and resend it later. For unsigned messages, the system decides which types to accept, such as RADIO_STATUS from its own radio; all others should be rejected. The guide also warns that the key must never appear in parameters or logs.
Example 1 Signing and verifying a HEARTBEAT frame
The key is derived from a sample phrase for teaching only; a real key must come from a secure random source.
import hashlib
import struct
def crc_x25(data, crc=0xFFFF):
for b in data:
tmp = b ^ (crc & 0xFF)
tmp = (tmp ^ (tmp << 4)) & 0xFF
crc = ((crc >> 8) ^ (tmp << 8) ^ (tmp << 3) ^ (tmp >> 4)) & 0xFFFF
return crc
KEY = hashlib.sha256(b"lesson-demo-passphrase").digest() # 32 bytes, for teaching only
HEARTBEAT = struct.pack("<IBBBBB", 0, 2, 3, 0x81, 4, 3) # custom_mode, type, autopilot, base_mode, status, version
def sign(seq, payload, ts, link_id=0, sysid=1, compid=1, msgid=0, crc_extra=50):
hdr = bytes([0xFD, len(payload), 0x01, 0x00, seq, sysid, compid]) + msgid.to_bytes(3, "little")
crc = crc_x25(hdr[1:] + payload + bytes([crc_extra]))
tail = struct.pack("<H", crc) + bytes([link_id]) + ts.to_bytes(6, "little")
return hdr + payload + tail + hashlib.sha256(KEY + hdr + payload + tail).digest()[:6]
last_ts = {}
def verify(frame, now):
body, sig = frame[:-6], frame[-6:]
if hashlib.sha256(KEY + body).digest()[:6] != sig:
return "reject: bad signature"
ts = int.from_bytes(body[-6:], "little")
stream = (body[5], body[6], body[-7]) # system ID, component ID, link ID
if stream in last_ts and ts <= last_ts[stream]:
return "reject: replayed or out-of-order timestamp"
if ts < now - 6_000_000: # 1 minute = 6,000,000 units of 10 µs
return "reject: older than 1 minute"
last_ts[stream] = ts
return "accept"
now = 123_456_839
f1 = sign(7, HEARTBEAT, 123_456_789)
print(f"frame {len(f1)} bytes: {f1.hex()}")
print("first delivery ->", verify(f1, now))
print("same frame again ->", verify(f1, now))
tampered = bytearray(sign(8, HEARTBEAT, 123_456_800))
tampered[13] ^= 0x01 # flip 1 payload bit
print("tampered payload ->", verify(bytes(tampered), now))
print("old frame, link 1->", verify(sign(9, HEARTBEAT, now - 7_000_000, link_id=1), now))
frame 34 bytes: fd0901000701010000000000000002038104033bac0015cd5b070000c82d318a978f
first delivery -> accept
same frame again -> reject: replayed or out-of-order timestamp
tampered payload -> reject: bad signature
old frame, link 1-> reject: older than 1 minute
The frame is 10 + 9 + 2 + 13 = 34 bytes. The instructor checked that these bytes match the frame pymavlink 2.4.50 produces with the same key, timestamp and sequence. Changing a single payload bit breaks the signature, and the same frame sent again is rejected because its timestamp does not increase.
Authentication is not encryption
MAVLink signing provides authentication and integrity, but the content is still readable. Anyone who intercepts the signal sees the drone’s position and status. Data that must stay confidential, such as video or parcel data, needs encryption as well.
- On IP networks such as LTE, use DTLS 1.3 (RFC 9147) over UDP or TLS 1.3 (RFC 9846, which replaced RFC 8446 in July 2026) over TCP, which both encrypt and authenticate.
- If you design at packet level yourself, use a mode that both encrypts and authenticates, such as AES-GCM per NIST SP 800-38D, which warns that reusing an IV with the same key even once can open the door to forgeries, a requirement almost as important as keeping the key secret.
- Key management decides who generates keys, how they are distributed, where they are stored, when they are rotated and how they are revoked when a device is lost. It goes wrong more often than the algorithms do.
Dual-path C2
Using radio and LTE together raises availability, but watch for common-mode failures, such as a power cut at the control centre that takes out both paths at once. RTCA DO-362A sets minimum performance for terrestrial C2, and DO-400 gives guidance on lost-C2 procedures, which are still needed even with two paths.
Example 2 C2 availability
Availabilities are assumed values from route statistics; each flight lasts 30 minutes.
A_RADIO, A_LTE, P_COMMON = 0.97, 0.95, 0.002
FLIGHT_MIN = 30
options = {
"radio only": A_RADIO,
"radio + LTE (independent)": 1 - (1 - A_RADIO) * (1 - A_LTE),
"radio + LTE with common mode": (1 - P_COMMON) * (1 - (1 - A_RADIO) * (1 - A_LTE)),
}
for name, a in options.items():
print(f"{name:<30} availability {a:.4f} expected outage {(1 - a) * FLIGHT_MIN * 60:5.1f} s per flight")
radio only availability 0.9700 expected outage 54.0 s per flight
radio + LTE (independent) availability 0.9985 expected outage 2.7 s per flight
radio + LTE with common mode availability 0.9965 expected outage 6.3 s per flight
The second path cuts link outage time sharply, but a common-mode failure of just 0.2% more than doubles the outage compared with the independent case. Power, network and location of the two paths must be separated as far as possible.
Authentication and access control
MAVLink signing confirms that a message comes from someone holding the key, but not what that someone should be allowed to do. The NIST Cybersecurity Framework 2.0 covers this under Identity Management, Authentication and Access Control (PR.AA). The key principles are:
- Authentication proves a person or device is who it claims to be, for example individual ground-station accounts and a separate key per drone.
- Authorization sets what each role may do, following least privilege: only what the job needs.
- Review checks permissions regularly, revokes them as soon as someone changes role, and logs every parameter change.
Example 3 Checking permissions against least privilege
NEEDS = { # permissions each role actually needs
"pilot": {"view_telemetry", "arm", "fly", "upload_mission"},
"observer": {"view_telemetry"},
"maintainer": {"view_telemetry", "change_params", "update_firmware"},
}
GRANTED = { # permissions currently granted
"pilot": {"view_telemetry", "arm", "fly", "upload_mission", "change_params"},
"observer": {"view_telemetry", "upload_mission"},
"maintainer": {"view_telemetry", "change_params", "update_firmware"},
}
for role in NEEDS:
extra, missing = GRANTED[role] - NEEDS[role], NEEDS[role] - GRANTED[role]
status = "ok" if not extra and not missing else f"remove {sorted(extra)}" if extra else f"add {sorted(missing)}"
print(f"{role:<10} {status}")
pilot remove ['change_params']
observer remove ['upload_mission']
maintainer ok
The pilot should not change parameters during operations, because that is the maintainer’s job under configuration control, and the observer should not be able to upload missions. A check like this can run automatically whenever account settings change.
Encryption and integrity in practice
What signing covers on a real autopilot. The ArduPilot documentation states plainly that MAVLink 2 signing does not encrypt the data; it only decides whether the autopilot acts on a command. Once signing is on, a non-USB serial port that uses MAVLink 2 responds only to commands signed with the right key, but the telemetry downlink is unaffected, so any receiver in range can still read position and status. USB connections are also unaffected, so that the owner can remove or change a key, and ports still running MAVLink 1 are not protected at all. In ArduPilot SITL with MAVProxy, the command signing setup KEY sets the key on both MAVProxy and the vehicle, and the MAVProxy documentation warns that the key is sent to the vehicle in plaintext, so set it up only over a secure link such as USB or the local simulator connection.
Adding confidentiality. To keep the downlink, video or parcel data secret, the data must be encrypted with an AEAD (authenticated encryption with associated data) mode such as AES-GCM. One call does three jobs: it encrypts the payload, it attaches a tag (16 bytes in the Python cryptography library) that detects any change to the payload, and it also protects associated data, such as the header, that must stay readable for routing. NIST SP 800-38D recommends a 96-bit (12-byte) IV, notes that the ciphertext is the same length as the plaintext, and treats the uniqueness of the IV for each key as a core requirement. A common safe way to get unique nonces is the one TLS 1.3 uses (RFC 9846, section 5.3): the 64-bit record sequence number is padded to the IV length and XORed with a static IV agreed with the key, so the nonce changes with every packet as long as the counter never repeats. In practice, use DTLS 1.3 or TLS 1.3, which do all this for you, rather than building your own packet format; the example below only shows what happens inside.
Example 4. Encrypting a position report with AES-GCM
The key and IV are fixed values so that the output can be repeated in class; a real key must come from a secure random source and must never be written into code. The position is assumed. Install the library with pip install cryptography.
import struct
from cryptography.exceptions import InvalidTag
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
KEY = bytes(range(32)) # fixed 256-bit key for a repeatable lesson only
IV = bytes.fromhex("a1b2c3d4e5f60718293a4b5c") # 12-byte static IV agreed with the key
aes = AESGCM(KEY)
def nonce(seq): # as in TLS 1.3: sequence number XOR static IV
return bytes(a ^ b for a, b in zip(seq.to_bytes(12, "big"), IV))
def position(lat, lon, alt_m): # a 12-byte position report
return struct.pack("<iif", round(lat * 1e7), round(lon * 1e7), alt_m)
header = bytes([1, 0]) # system ID and link ID: readable but protected
p1 = position(13.9651, 100.5876, 60.0)
c1 = aes.encrypt(nonce(1), p1, header)
print(f"plaintext {len(p1)} B -> ciphertext + tag {len(c1)} B")
print("plaintext :", p1.hex())
print("ciphertext:", c1[:12].hex(), "tag:", c1[12:].hex())
print("receiver decrypts correctly:", aes.decrypt(nonce(1), c1, header) == p1)
tests = {"one bit of ciphertext flipped": (bytes([c1[0] ^ 1]) + c1[1:], header),
"system ID in header changed": (c1, bytes([2, 0]))}
for name, (data, hdr) in tests.items():
try:
aes.decrypt(nonce(1), data, hdr)
print(name, "-> accepted")
except InvalidTag:
print(name, "-> InvalidTag, packet dropped")
p2 = position(13.9660, 100.5880, 62.0)
c2 = aes.encrypt(nonce(1), p2, header) # mistake: the same nonce used twice
leak = bytes(a ^ b for a, b in zip(c1, c2))[:12] == bytes(a ^ b for a, b in zip(p1, p2))
print("nonce reused: C1 xor C2 equals P1 xor P2 ->", leak)
for hz in (10, 50):
print(f"{hz} Hz: 16-byte tag adds {16 * 8 * hz / 1000:.1f} kbit/s "
f"(13-byte MAVLink signature {13 * 8 * hz / 1000:.1f} kbit/s)")
plaintext 12 B -> ciphertext + tag 28 B
plaintext : b8e752082073f43b00007042
ciphertext: 797726525f40621abaab30b6 tag: cf87d0fad48d19508d7bc5b66673b764
receiver decrypts correctly: True
one bit of ciphertext flipped -> InvalidTag, packet dropped
system ID in header changed -> InvalidTag, packet dropped
nonce reused: C1 xor C2 equals P1 xor P2 -> True
10 Hz: 16-byte tag adds 1.3 kbit/s (13-byte MAVLink signature 1.0 kbit/s)
50 Hz: 16-byte tag adds 6.4 kbit/s (13-byte MAVLink signature 5.2 kbit/s)
The 12-byte ciphertext is the same length as the plaintext, and the 16-byte tag is added on top. An eavesdropper sees only bytes with no visible latitude or longitude, while the header stays readable but cannot be changed without detection. When the nonce is reused, XORing the two ciphertexts removes the encryption and leaves the XOR of the two plaintexts; anyone who knows or guesses one position report can then read the other, and reuse also opens the door to forged tags. This is why NIST makes a unique IV per key a core requirement. The cost in bandwidth is small, similar to that of signing.
Module lab
Lab: enabling signing and testing in SITL
- Run the code from Example 1 and compare with the frame pymavlink produces using the same key and timestamp.
- Enable MAVLink signing in SITL following the ArduPilot or PX4 guide and the GCS software in use (in ArduPilot SITL with MAVProxy:
signing setup KEYover the local connection only). - Send commands from a script without the key, check that they are rejected and record the log.
- Replay a recorded frame on loopback and check that replay protection works.
- Write a key management plan for the medical delivery network and compute availability with Example 2.
- Run Example 4, then change it: flip a bit, change the header and reuse a nonce, and record what happens. List which data in the delivery network still travels unencrypted with signing alone (such as the telemetry downlink) and which protocol will protect it.
Common mistakes
Watch out
- Thinking signing encrypts the data.
- Accepting every unsigned message type for convenience.
- Storing the key in parameters or logs.
- Setting up the signing key over the radio link, where it travels in plaintext.
- Reusing an IV in AES-GCM.
- Assuming two paths remove the need for lost-C2 procedures.
Summary
- The MAVLink 2 signature block is 13 bytes; the signature is SHA-256 over a 32-byte key and the frame, truncated to 6 bytes.
- Increasing timestamps per stream and the 1-minute limit protect against replay.
- Signing authenticates but does not hide content; use DTLS/TLS or AES-GCM when confidentiality is needed.
- Dual-path C2 raises availability, but common-mode failures must be reduced and lost-C2 procedures are still required.
- Autopilot signing leaves the telemetry downlink readable; AES-GCM (inside DTLS/TLS) encrypts and adds a 16-byte tag, and a nonce must never repeat under one key.
- Keep authentication separate from authorization, grant least privilege by role, and review permissions regularly
Check your understanding
- What makes up the MAVLink 2 signature block, and how many bytes is it?
- Two AES-GCM packets are sent with the same key and the same nonce. What can an eavesdropper learn?
- Why is a replayed frame rejected even though every byte is valid?
- Two independent paths each have availability 0.9. What is the combined availability?
- What can someone intercepting a signed radio link still see?
Answers
- Link ID 1 byte, timestamp 6 bytes and signature 6 bytes, 13 bytes in total.
- XORing the two ciphertexts gives the XOR of the two plaintexts, so knowing one message reveals the other; forged tags also become possible.
- Its timestamp is not greater than the latest timestamp on the same stream.
- All of the content, such as position and status, because signing does not encrypt.
Key formulas
| MAVLink 2 signature | |
| Availability of two paths |
Key references
- MAVLink Development Team. Message signing (authentication). MAVLink developer guide. link
- Dworkin, M. (2007). Recommendation for block cipher modes of operation: Galois/Counter Mode (GCM) and GMAC (NIST SP 800-38D). National Institute of Standards and Technology. link
- Rescorla, E., Tschofenig, H., & Modadugu, N. (2022). The Datagram Transport Layer Security (DTLS) protocol version 1.3 (RFC 9147). RFC Editor. link
- Rescorla, E. (2026). The Transport Layer Security (TLS) protocol version 1.3 (RFC 9846). RFC Editor. link
- RTCA. (2020). Command and control (C2) data link minimum operational performance standards (MOPS) (terrestrial) (RTCA DO-362A; replaces DO-362 of 2016). link
- RTCA. (2023). Guidance material: Lost C2 link procedures (DO-400). link
- National Institute of Standards and Technology. (2024). The NIST cybersecurity framework (CSF) 2.0. link
- ArduPilot Dev Team. MAVLink2 signing. ArduPilot Copter documentation. link
- ArduPilot Dev Team. Packet signing (signing module). MAVProxy documentation. link
- Python Cryptographic Authority. Authenticated encryption (AESGCM). cryptography documentation. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Intensive lab and field practice recorded in a lab notebook
Learning evidence: Lab notebook signed by the instructor