TExcelTAD
Home › Wireless, IoT & Mobile Security › Mini Project: Security Review of a Smart-Home Device and Its App

Mini Project: Security Review of a Smart-Home Device and Its App

You will carry out a complete product security review of a new smart-home device and its companion app, from scope to report, the way a vendor's product-security team does before release: the firmware image, the Android app's manifest, the BLE pairing design and the Wi-Fi behaviour. One program runs the checks of this course on all four artefacts, you rate and explain the findings, propose the fixes, retest the fixed version, and write the report with the template at the end. Every artefact is synthetic: the device, the app and their configurations exist only in this lesson.

The engagement

Product: LabPlug Pro, a smart plug with Wi-Fi and BLE, firmware 1.0.0, and the LabHome Android app 2.4.0 (test.lab.labhome), both from the course's fictional vendor.

Scope (signed by the vendor's head of product security): the firmware image supplied by the build team; the release APK's merged manifest; the BLE pairing configuration and GATT table from the firmware source; the device's Wi-Fi configuration (station mode on the customer's network, and the setup access point it opens for onboarding). Lab tests on two units on the bench and the emulator lab-emu-01. Out of scope: the cloud backend (separate test), customers' networks, other vendors' products. Window: one week; results go to the product team only.

Standards: ETSI EN 303 645 provisions, OWASP MASVS 2.x (profile MAS-L1 + L2: the app controls a physical device), the UK PSTI requirements and the EU CRA essential requirements as the release bar.

Step 1: understand the onboarding flow

How the plug joins a home, which is where most of its risk sits (threat model):

  1. Out of the box, the plug advertises over BLE and opens a setup access point.
  2. The app pairs with the plug over BLE, or joins the setup AP, and sends it the home Wi-Fi passphrase.
  3. The plug joins the home network as a Wi-Fi client and connects to the MQTT broker mqtt.lab.test.
  4. Afterwards, the app controls the plug through the cloud, or locally over BLE.

The home Wi-Fi passphrase crosses steps 2 and 3: whatever protects them protects the customer's whole network.

Step 2: run the review

The program contains the artefacts of version 1 (V1) and of the fixed version 2 (V2) as data, and one check function per artefact, each built from a lesson of the course: firmware (firmware analysis, update security, MQTT), manifest (Android manifest), BLE (pairing, GATT and privacy) and Wi-Fi (PMF, WPA3, AP hardening). It prints the version 1 findings in severity order, then retests version 2.

python · try it yourself
import hashlib, re, struct, zlib
import xml.etree.ElementTree as ET

# ---------- the artefacts of LabPlug Pro, version 1 (synthetic) ----------
def firmware(files, signed):
    fs = b"".join(struct.pack("<B", len(n)) + n.encode() + struct.pack("<I", len(d)) + d for n, d in files)
    body = zlib.compress(b"lab plug kernel " * 200, 9) + fs
    return struct.pack("<4sHI", b"LPFW", 64 if signed else 0, zlib.crc32(body)) + (bytes(64) if signed else b"") + body

V1 = {
    "firmware": firmware([("/etc/init.d/rcS", b"/usr/sbin/telnetd -p 23 &\n/usr/bin/plugd &\n"),
                          ("/etc/plug.conf", b"mqtt_host=mqtt.lab.test:1883\nmqtt_password=lab-only-plug-shared\n")], signed=False),
    "manifest": """<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="test.lab.labhome">
      <application android:allowBackup="true" android:usesCleartextTraffic="true">
        <receiver android:name=".PlugCommandReceiver" android:exported="true"/></application></manifest>""",
    "ble": {"secure_connections_only": False, "io": "NoInputNoOutput", "oob_qr": False, "mitm_flag": False,
            "pairing_window_s": None, "relay_write": "open", "adv_fields": ["name", "serial", "fw_version"]},
    "wifi": {"station_key_mgmt": "WPA-PSK", "station_pmf": 0, "setup_ap": "open", "setup_ap_always_on": True},
}
V2 = {  # after the fixes
    "firmware": firmware([("/usr/bin/plugd", b"plugd 2.0 (no shell services)\n")], signed=True),
    "manifest": """<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="test.lab.labhome">
      <application android:allowBackup="false">
        <receiver android:name=".PlugCommandReceiver" android:exported="false"/></application></manifest>""",
    "ble": {"secure_connections_only": True, "io": "NoInputNoOutput", "oob_qr": True, "mitm_flag": True,
            "pairing_window_s": 60, "relay_write": "auth", "adv_fields": ["name"]},
    "wifi": {"station_key_mgmt": "SAE WPA-PSK", "station_pmf": 1, "setup_ap": "owe", "setup_ap_always_on": False},
}

# ---------- the checks: each returns (severity, area, finding, reference) ----------
def check_firmware(img):
    out = []
    magic, sig_len, crc = struct.unpack_from("<4sHI", img)
    if sig_len == 0: out.append(("HIGH", "firmware", "image is not signed", "ETSI 5.7 / update-security"))
    if re.search(rb"telnetd", img): out.append(("HIGH", "firmware", "Telnet started at boot", "ETSI 5.6"))
    if re.search(rb"(?i)password\s*=\s*\S+", img): out.append(("HIGH", "firmware", "shared MQTT password in the image", "ETSI 5.4"))
    if re.search(rb":1883\b", img): out.append(("MED", "firmware", "MQTT without TLS (port 1883)", "ETSI 5.5"))
    return out

def check_manifest(xml):
    A = "{http://schemas.android.com/apk/res/android}"
    app, out = ET.fromstring(xml).find("application"), []
    if app.get(A + "allowBackup", "true") == "true": out.append(("MED", "app", "allowBackup on", "MASVS-STORAGE-2"))
    if app.get(A + "usesCleartextTraffic") == "true": out.append(("HIGH", "app", "cleartext traffic allowed", "MASVS-NETWORK-1"))
    for c in app:
        if c.get(A + "exported") == "true" and not c.get(A + "permission"):
            out.append(("HIGH", "app", f"{c.get(A + 'name')} exported without permission", "MASVS-PLATFORM-1"))
    return out

def check_ble(b):
    out = []
    authenticated = b["mitm_flag"] and (b["oob_qr"] or b["io"] != "NoInputNoOutput")
    if not b["secure_connections_only"]: out.append(("MED", "ble", "legacy pairing allowed", "ble-pairing"))
    if not authenticated: out.append(("HIGH", "ble", "only Just Works possible: no MITM protection", "ble-pairing"))
    if b["pairing_window_s"] is None: out.append(("MED", "ble", "pairing accepted at any time", "ble-pairing"))
    if b["relay_write"] != "auth": out.append(("HIGH", "ble", f"relay writable with '{b['relay_write']}' security", "ble-privacy-gatt"))
    leaks = [f for f in b["adv_fields"] if f in ("serial", "fw_version")]
    if leaks: out.append(("LOW", "ble", f"advertises {', '.join(leaks)}", "ble-privacy-gatt"))
    return out

def check_wifi(w):
    out = []
    if "SAE" not in w["station_key_mgmt"]: out.append(("MED", "wifi", "joins home Wi-Fi with WPA2-PSK only", "wpa3-sae"))
    if w["station_pmf"] == 0: out.append(("MED", "wifi", "PMF off", "wifi-frames-pmf"))
    if w["setup_ap"] == "open": out.append(("HIGH", "wifi", "setup access point is open (Wi-Fi passphrase sent in clear)", "ap-hardening"))
    if w["setup_ap_always_on"]: out.append(("MED", "wifi", "setup access point always on", "ap-hardening"))
    return out

def review(a):
    return check_firmware(a["firmware"]) + check_manifest(a["manifest"]) + check_ble(a["ble"]) + check_wifi(a["wifi"])

RANK = {"HIGH": 0, "MED": 1, "LOW": 2}
v1 = sorted(review(V1), key=lambda f: RANK[f[0]])
for i, (sev, area, text, ref) in enumerate(v1, 1):
    print(f"F{i:02d} {sev:4} {area:8} {text:60} [{ref}]")
counts = {s: sum(f[0] == s for f in v1) for s in RANK}
print("v1:", counts)
print("retest v2:", review(V2) or "no findings")
F01 HIGH firmware image is not signed                                          [ETSI 5.7 / update-security]
F02 HIGH firmware Telnet started at boot                                       [ETSI 5.6]
F03 HIGH firmware shared MQTT password in the image                            [ETSI 5.4]
F04 HIGH app      cleartext traffic allowed                                    [MASVS-NETWORK-1]
F05 HIGH app      .PlugCommandReceiver exported without permission             [MASVS-PLATFORM-1]
F06 HIGH ble      only Just Works possible: no MITM protection                 [ble-pairing]
F07 HIGH ble      relay writable with 'open' security                          [ble-privacy-gatt]
F08 HIGH wifi     setup access point is open (Wi-Fi passphrase sent in clear)  [ap-hardening]
F09 MED  firmware MQTT without TLS (port 1883)                                 [ETSI 5.5]
F10 MED  app      allowBackup on                                               [MASVS-STORAGE-2]
F11 MED  ble      legacy pairing allowed                                       [ble-pairing]
F12 MED  ble      pairing accepted at any time                                 [ble-pairing]
F13 MED  wifi     joins home Wi-Fi with WPA2-PSK only                          [wpa3-sae]
F14 MED  wifi     PMF off                                                      [wifi-frames-pmf]
F15 MED  wifi     setup access point always on                                 [ap-hardening]
F16 LOW  ble      advertises serial, fw_version                                [ble-privacy-gatt]
v1: {'HIGH': 8, 'MED': 7, 'LOW': 1}
retest v2: no findings

Sixteen findings for version 1, none for version 2. (The retest checks that a signature is present; that the device rejects a badly signed image is a separate bench test, below.)

Step 3: confirm, rate and explain

Tools produce candidates; the reviewer confirms each one with evidence and rates it by impact and exploitability for this product. Three examples of the reasoning:

  • F08, open setup access point (high). During onboarding the app sends the home Wi-Fi passphrase to the plug over an unencrypted network: anyone in radio range during setup reads it and gets onto the customer's network. Confirmed on the bench by observing the setup AP's beacons (no RSN element) with the lab sensor. Fix: onboarding over BLE with authenticated pairing, or a setup AP with OWE at minimum (better: WPA3 with a per-device password from the label), and the setup AP off after onboarding.
  • F06 and F07, Just Works pairing and an open relay characteristic (high). Anyone within BLE range can switch the plug, and anyone present during pairing can sit in the middle permanently. For a device that switches heaters and kettles, that is a safety issue as well as a security one. Fix: OOB pairing from a QR code on the plug, a 60-second pairing window after a button press, and authenticated permissions on the relay.
  • F03, shared MQTT password (high). The same password in every unit's image lets anyone who downloads the update file impersonate any plug to the broker. Fix: per-device client certificates provisioned at manufacturing, TLS on 8883 (closing F09 too), broker ACLs per device.

Step 4: bench tests for what code can't show

Lab session on the two bench units (synthetic transcript; scope as above):

console
bench test log, LabPlug Pro 1.0.0 (unit A) and 2.0.0 (unit B)
  T1  flash 1.0.0 image with one byte changed            unit A: accepted, boots     -> F01 confirmed
                                                         unit B: "signature invalid", stays on 2.0.0
  T2  serve signed 1.0.0 to unit B (rollback)            unit B: "version not newer", rejected
  T3  nmap -sT -p 23,1883,8883 plug.lab.test             unit A: 23 open, 1883 open    unit B: 8883 open only
  T4  BLE write to relay without pairing                 unit A: relay toggles         unit B: "insufficient authentication"
  T5  pairing outside the button window                  unit A: pairs (Just Works)    unit B: refused
  T6  setup AP beacon                                    unit A: open, always on       unit B: OWE, off after onboarding

Each test maps to findings and becomes part of the retest evidence.

Step 5: the fixes, by owner

Owner Findings Fix
firmware team F01, F02, F03, F09 signed images verified by the bootloader and updater with anti-rollback; Telnet removed from production builds; per-device certificates; MQTT over TLS
app team F04, F05, F10 cleartext off, receiver not exported, backups off or with exclusion rules
hardware/BLE team F06, F07, F11, F12, F16 Secure Connections Only, OOB via QR code, pairing window, authenticated relay permission, minimal advertisement
Wi-Fi/onboarding F08, F13, F14, F15 onboarding over authenticated BLE; setup AP with OWE only during setup; station supports SAE and PMF
compliance all the PSTI statement of support period and the vulnerability-disclosure contact published before sale

Step 6: write the report

Use this template; keep evidence short and exact, and write the executive summary for someone who reads nothing else.

text
PRODUCT SECURITY REVIEW: LabPlug Pro 1.0.0 + LabHome Android 2.4.0
Date, version of this report, authors, distribution (product team only)

1. Executive summary
   - Overall risk in two sentences; release recommendation (block / release with conditions / release)
   - Counts: 8 high, 7 medium, 1 low; retest status of version 2.0.0

2. Scope and method
   - Artefacts, units, app builds, environment (lab only), dates
   - Standards: ETSI EN 303 645, OWASP MASVS 2.x (MAS-L1 + L2), UK PSTI, EU CRA
   - Out of scope and limitations (cloud backend, customer networks)

3. Findings (one block each)
   ID / title / severity
   Affected component and version
   Description: mechanism in plain language
   Evidence: program output line, bench test ID, transcript excerpt
   Impact for the customer
   Reference: ETSI provision / MASVS control / lesson
   Recommendation and owner
   Retest result (version, date, evidence)

4. Positive observations (what was already done well)

5. Compliance summary
   PSTI: default passwords / disclosure contact / support period
   ETSI EN 303 645: provisions met, partly met, not met
   CRA readiness notes

6. Appendix: tool versions, checker code version, full test log

Assessment checklist

  • Every finding has evidence, a reference, an owner and a retest result.
  • Severity reflects this product (a relay that switches heaters is not a lamp).
  • False positives and accepted risks are listed with reasons, not deleted.
  • Nothing in the report or its evidence contains real customer data or secrets (redact the lab tokens too).
  • The report names what was not tested.

Practice

1. Add the check "GATT characteristic Wi-Fi Credentials writable with only encryption" to check_ble. Where does it come from, and what severity?

From the GATT lesson: with Just Works, "encryption required" lets anyone who pairs write the network credentials, so the plug could be moved onto an attacker's network. High in version 1 (only Just Works is possible); closed in version 2 by authenticated permissions with OOB pairing.

2. The vendor asks to ship version 1 with "known issues" documented. What do you answer, citing two rules?

Block the release: the MQTT password shared by every unit breaks ETSI EN 303 645 provision 5.4 (no hard-coded security parameters shared across devices) and the spirit of PSTI's ban on universal passwords, and Telnet plus unsigned images contradict the CRA's secure-by-default and integrity requirements, which apply from December 2027 and are the release bar the vendor set. Ship version 2 after its retest.

3. Write the finding block for F15 (setup AP always on).

F15, setup access point always on, medium. Component: Wi-Fi onboarding, firmware 1.0.0. Description: the plug keeps its setup AP running after onboarding, so anyone nearby can connect to it at any time. Evidence: bench test T6, beacons of the setup SSID one day after onboarding. Impact: a permanent unauthenticated entry point to the device. Reference: ETSI 5.6, AP hardening. Recommendation: start the setup AP only on a button press, stop it after onboarding or after 10 minutes; owner: Wi-Fi/onboarding. Retest: 2.0.0, T6 shows the AP off after onboarding.

Test yourself

Why is the open setup access point (F08) rated high?

  1. It uses channel 6
  2. The home Wi-Fi passphrase crosses it in clear text during onboarding
  3. It slows the plug
  4. It advertises the serial number

What does the retest of version 2 not prove by itself?

  1. That Telnet is gone
  2. That the device actually rejects a badly signed image
  3. That cleartext is off
  4. That pairing needs OOB

Which fix closes F03 (shared MQTT password) and F09 (MQTT without TLS) together?

  1. A longer password
  2. Per-device client certificates with MQTT over TLS on 8883
  3. Hiding the broker name
  4. Disabling MQTT

What belongs in every finding block of the report?

  1. Only the title
  2. Evidence, impact, reference, recommendation with owner, and retest result
  3. The tester's opinion only
  4. The raw tool output