Author: canutethegreat

  • Hardware hacking, part 2: the bench I work on and what each tool is for

    Hardware hacking, part 2: the bench I work on and what each tool is for

    Part 2 of 7 in the Hardware hacking series. Part 1: updating the firmware on a Pinecil V2.

    Nothing on my bench is expensive. I bought it one problem at a time, and that matters for this series. I’m not trying to show off lab gear. The point is how little it takes to look inside a device, and how little an attacker needs for the same job. If a cheap logic analyzer and a serial cable can show what a router prints at boot, then “nobody will ever open it” is not a security control.

    The rules before the tools

    Diagram: five device interfaces, the bench tool used to reach each, and the matching defender control

    I drew the diagram above. It links each interface a device exposes to the bench tool that reaches it and the control that closes it.

    Everything here happens on hardware I own and am allowed to take apart. No work devices, no borrowed ones, nothing that belongs to a neighbour or a client.

    I do not open, probe or connect anything that is plugged into mains. Many small devices, such as smart plugs, bulbs and some power bricks, have supplies that are not isolated from mains, so a board’s ground can sit at mains potential. I work on boards powered from a proper low-voltage adapter, a battery or USB, and if I am unsure what powers a board, I do not connect anything.

    Then the boring habits. Power down and unplug before soldering, swapping a chip or moving a probe onto a chip. For UART and logic captures I make the connections with the target off and power it up afterwards, from its own supply only, never from the serial cable as well. Ground goes on first and comes off last. I touch an earthed metal object, such as an unpowered PC case, before handling a board, and I hold boards by the edges, because static discharge can damage chips without any visible sign. If you use a wrist strap, use one with a built-in series resistor and never wear it near anything that could be connected to mains. Wear safety glasses when cutting leads or soldering, and keep some ventilation going.

    The iron: Pinecil V2

    I covered the firmware in part 1. It is a small USB-C powered iron running IronOS, and I use it for tinning wires, pin headers and joint rework. A hot tip burns skin and scorches a desk, so it sits in its stand while it is on, and I let it cool before putting it away.

    The logic analyzer: HiLetgo 24 MHz, 8 channels

    This is a cheap Saleae-style clone that works with the open source sigrok and PulseView software through the fx2lafw driver. It records when each of up to eight digital lines goes high or low. It does not measure voltage and it does not replace a multimeter. It gives you timing.

    Two things matter in practice. The sample rate tops out at 24 MHz, but a UART at 115200 baud has bits about 8.68 microseconds long, so at 24 MHz you get roughly 208 samples per bit, far more than needed. The other is voltage. I have not found a datasheet for mine, so I treat its inputs as unprotected with a threshold I cannot adjust. I measure the target’s logic level with a multimeter first, with the target powered from its own supply and nothing else connected, I connect the analyzer’s ground before any signal lead, and I do not expect it to read a 1.8V signal reliably.

    In part 6 I decode I2C and SPI with it. Here is PulseView with a capture loaded. This is a synthetic signal I generated with a Python script (8N1 at 115200 baud, written as a raw binary file and opened in PulseView), not a capture from a device.

    PulseView window with a synthetic 115200 baud UART signal on channel 0 and a millisecond time scale

    The trace is synthetic UART data on channel 0, with milliseconds along the top.

    The serial cable: FTDI FT232RL, 5V

    A USB-to-serial cable with an FTDI chip and a 6-pin 0.1 inch female header. It lets a PC talk to the UART console that many routers and embedded boards expose on a few unpopulated pads. A UART needs a transmit line, a receive line and a ground. The line idles high, and each byte is framed by a low start bit and a high stop bit. There is no clock, so both sides have to agree on the baud rate in advance.

    Mine is sold as a 5V cable, and I expect its data lines to be 5V too, not only the red power wire. I will confirm that by measuring the idle level of its TX line with the USB end plugged in. Many boards run their UART at 3.3V, and a 5V transmit line into a 3.3V receiver is the real risk, which leaving the red wire unconnected does not fix. I never connect the cable’s 5V wire to a target, I connect only ground, TX and RX (cable TX to target RX, target TX to cable RX), and I measure the target’s logic level first. Part 3 makes this cable safe on 3.3V targets, with the numbers worked out.

    The programmer: XGecu T48

    A universal programmer with a ZIF socket and a set of adapters (mine came with 19) for SPI and I2C EEPROM, NOR and NAND flash, microcontrollers and BIOS chips. Its software, Xgpro, is Windows only, so I won’t show screenshots of it here and I only download it from the vendor. Chips go in the socket once they’re off the board, which means desoldering, heat and a steady hand. Orientation and supply voltage have to be right before I start a read, because a chip in backwards or at the wrong voltage can be destroyed.

    The probe frame

    A small frame with four probe pens that holds against a board and touches the pads or pins of a chip without desoldering it. It is sold as a BDM frame, though it is just a probe holder and has nothing to do with Motorola’s debug interface. I use it when I can’t or won’t desolder something, and it is where most of my failed reads come from. The rest of the board is still attached to the chip, so other devices on the same bus can interfere. Back-powering can also damage the board or the programmer, so for in-circuit reads the board stays unpowered except for whatever the programmer supplies, at the voltage the chip expects. Part 5 covers reading in circuit, and why I read every chip twice and compare hashes before I trust a dump.

    The small stuff

    DOWELL micro flush cutters for trimming leads, always cutting away from my face because clipped leads fly. A pack of 120 Dupont jumper wires for temporary connections. A sheet of PTM7950 phase-change thermal pad for putting a device with a heatsink back together properly. A pad that has been removed gets replaced rather than reused, and old residue is cleaned off with isopropyl alcohol first.

    What is not on the bench

    No JTAG or SWD probe. Part 7 on debug ports is therefore about concepts, pinouts and how vendors lock those ports, not a walkthrough on my own hardware.

    Why a defender should care

    Every tool above is cheap and easy to buy, which is the whole argument. If your product ships with an open UART console, an unprotected SPI flash holding secrets in plain text, or a debug port that never got locked, assume someone with this bench will find it. The fixes are in the design: authenticate or close the console, encrypt and sign what is in flash, and fuse the debug port before shipping. The later parts show each of these on boards I own.

    Other parts of the Hardware hacking series: 1, updating the firmware on a Pinecil V2; 2, the bench I work on; 3, using my 5V FTDI cable on 3.3V UARTs; 4, finding the UART console on a router I own; 5, reading SPI flash without wrecking it; 6, decoding I2C and SPI with sigrok; 7, JTAG and SWD basics.

  • Horcrux dev log: breaking my own HA cluster on three old laptops

    Horcrux dev log: breaking my own HA cluster on three old laptops

    Part 7 in the Horcrux dev log series. Earlier parts: Part 1, Part 2, Part 3, Part 4, Part 5, Part 6.

    I build Horcrux, and this is my dev log for the week.

    I watched IONIC1K’s video where he hand-builds a Gentoo hypervisor on a $50 Dell R730 because Proxmox 8 to 9 upgrades keep breaking his VMs, RAID and clusters. I was a Debian Developer from 1999 to 2006 and have been on Gentoo ever since, so I’ve lived with both upgrade styles.

    What I was working on

    Horcrux is a Gentoo-based hypervisor with a web UI, written in Rust. It’s pre-1.0 and I’m the only one working on it. The week went into the cluster side: HA, live migration, node replacement and rolling upgrades, tested on three old laptops I keep as a lab. The laptops are wired and slow, which shows timing bugs nicely.

    My bar for HA: every scenario green ten runs in a row, guest back on a surviving node within 120 seconds of a crash, no data loss, never two copies of the same VM running. I’m at 0 of 10.

    What changed this week

    Hard crash failover went from 126 s (over my own limit) to 58.7 s on the first fixed build and 53.6 s on the latest run. Part of that was the manager not starting at boot on a crashed node and not being restarted when it died, so now it runs under supervise-daemon and the QEMU guests survive a manager kill.

    Live migration between two laptops works on hardware now: 62 s the first time and 3 s the second, both directions. I ran a checksummed workload inside the guest and it ended with exactly one copy of the VM and no missing records. In an earlier run a rolling upgrade (drain a node by live-migrating its guest away, upgrade it, next node) took 15, 56 and 47 s per node with the guest running the whole time.

    Partition handling got fixed too. In one scenario the minority node self-fenced at 37 s but the guest on it came back to life about a minute later, so for 34 s there were two copies. After the fixes the double-run time is 0 and the minority fences itself in 10 s.

    Using it on a demo box

    The lab laptops are busy with tests, so for the clips I installed the daily image in a throwaway VM (nested KVM) with demo names. Single node, so none of the cluster stuff is in these.

    ZFS first. The web UI has a Node Shell page, so I did this from the browser: a raidz1 pool across three disks, an encrypted dataset, a snapshot, delete the file, roll back.

    Creating a raidz1 pool, an encrypted dataset, a snapshot and a rollback from the Node Shell page. Real time.

    Next the everyday stuff: make a VM from an ISO in the library, boot it, open the console. The guest is Alpine.

    Creating a VM from an ISO and logging in on its console. The boot wait is cut out.

    And the update. The image has two binhosts configured, mine first and the official Gentoo one as fallback, so an emerge pulls binaries. The world update earlier was 19 packages, 18 of them binary and one pure-Python ebuild with nothing to compile. The clip is a second run in real time: four packages re-installed from the binhost in about 25 s (same versions, since the box was already updated).

    Four packages re-installed from the binhost. Real time.

    Screenshots, since the clips are small:

    Horcrux VM list with one running Alpine VM and buttons for console, start, save state, shutdown, reboot and stop
    The VM list with the Alpine guest running.
    Horcrux dashboard on a demo node: one VM, one cluster node, no alerts, 38.5 percent CPU
    The dashboard while the VM was booting.
    Storage pools page showing the ZFS pool tank-zfs with 0 B total and 0 B available
    The pool card that says 0 B. The pool is healthy in zpool.
    PCI passthrough page with a message that no IOMMU groups were found in the demo VM
    The passthrough page in a VM with no IOMMU, so nothing to pass through.

    What doesn’t work

    HA is not done. The 3-node suite can’t even run right now: one laptop is gone. I had a scheduler job doing an unattended bare-metal reinstall of the new daily image. It ran 4508 s and the laptop never came back on its address. It answers ping on a new DHCP address but every TCP port refuses, including 22. I don’t know yet whether the installed image lacks the lab sshd or it never left the installer. It needs me to walk over to it.

    Live migration failed after one of my quorum-loss scenarios with “Unable to write to socket: Connection reset by peer”. The cause was HA killing the migration receiver as a stale copy. Fixed and checked on hardware, but the CI run for that branch hadn’t finished when I wrote this, so it isn’t on main.

    Node replacement: when I replaced a node, the other member kept listing the new one as offline forever (“answered by a different Horcrux instance”), because it still pinned the identity of the old install. The fix is on a branch and verified on hardware. Removing a node now also gets announced to the other members.

    Stack stop: a test caught that stopping a compose stack could return success with a container still running 11 s later, when the container list had just been refreshed and overwrote a fresh “running” with a stale “stopped”. Fix is on the branch.

    Wake-on-LAN doesn’t work. Magic packets every 15 s for 10 minutes did nothing from a powered-off state, the laptop only came back at the RTC alarm 642 s later. So the power-off scenario is skipped for now. I think it’s a BIOS setting but I can’t read that from the OS.

    Watchdogs: I assumed the hardware watchdog on one laptop would reset it. It accepted pets and never reset the machine (I stopped the pet process for 7 minutes). So the test machine profile now arms softdog next to the hardware one. Measured resets after stopping the pet: 61 s, 58 s and 26 s on the three laptops. One laptop I called hung for two hours was suspended, which I only found by reading syslog.

    Things I hit while recording these clips, on the demo box:

    • I registered the ZFS pool in the Storage page and it shows 0 B total and 0 B available, and the create-VM form doesn’t offer it as a disk target (only the default storage). The pool itself is fine in zpool.
    • I started the update from the web shell and my browser connection dropped partway. The emerge died at package 13 of 19. I re-ran it over ssh and the last six took 1 min 28 s. Not proven that the shell kills its children on disconnect, it’s just what it looked like.
    • The shell page is root. Fine on my own box, but I want to look at that.
    • The GPU page says no IOMMU groups, which is correct for a VM, so I can’t show passthrough. The docs describe it and the API exists, but I haven’t done passthrough on real hardware with a real GPU.
    • Syncing the tree plus a dry-run resolve took 4 min 34 s on that VM before any package moved.
    • Parts of the UI are plain, some pages are barely styled.
    • No systemd image. The images are OpenRC only. The binhost has systemd lanes, but nobody can install a Horcrux ISO with systemd today.
    • No CPU-tuned binaries either, see below.
    • Root install is single disk or two-disk mirror. The raidz1 pool in the clip I made by hand.

    Design decisions

    Gentoo is here for the freedom to choose. USE flags are the main reason, and compiling for specific hardware is a secondary one. The ISOs are OpenRC only because systemd wants to run the world, and the cost is feature bloat.

    The manager and web UI are Rust for memory safety and compile time checks.

    ZFS boot environments and the automatic snapshot before an update are there for recovery, bit rot protection and resilience.

    On HA fencing, Horcrux has fencing agents for IPMI, Redfish, SNMP PDUs and SSH, but the lab machines are old laptops with no IPMI and no switched PDUs, so nothing there can cut another node’s power. What I can test on them is a node that loses quorum stopping its own guests after a timeout, which is the path in the partition results above. The power-off agents haven’t been run on real hardware (the Redfish one has only been tested against a mock BMC).

    Why some of it is the way it is

    ZFS is the default file system, but machines with under 8 GB of RAM get XFS on LUKS instead, because the ZFS cache competes with guests for memory. The root pool can use native encryption (aes-256-gcm, passphrase). The ESP and /boot stay unencrypted because GRUB has to read them. That’s all in the install docs.

    The binhost builds for x86-64-v2, not for any one CPU. Every x86 machine I own, including the old laptops, has SSE4.2, while v3 would break hosts without AVX2 and VMs using a generic CPU model. Separately, a target-cpu=native build crashed on an Intel machine on 2026-10-28, so the image pins v2 now (I haven’t re-checked that on the Intel box yet, see the roadmap).

    The binhost only compiles what the official Gentoo binhost doesn’t already have with matching USE flags, and signs what it publishes. My own number for a server rootfs emerge was 587 s with only the official binhost and 245 s with mine added.

    No default password anywhere: the installer makes you set one, and the web admin password is generated on first boot.

    Where it stands

    Pre-1.0. On my own roadmap checklist none of the nine 1.0 criteria are fully met: five partly, four not at all (last reviewed Oct 28). There’s no CI test that upgrades an installed system’s packages in place and rolls it back at the OS level, though boot environment snapshots exist and the emerge on the demo box took one by itself. The streak counters in the lab say upgrade-test is at 1 of 5, be-rollback-test 0 of 5, cluster-upgrade 1 of 5.

    Next

    Get the dead laptop back and re-run the HA suite with the fixed manager until it’s ten in a row or I find the next bug. Get the migration and rejoin branches through CI and into main. Find out why the reinstalled laptop has no open ports. Try passthrough on a machine with an IOMMU. Fix the 0 B pool card.

    The project page is at horcrux.errant.solutions.

  • Designing an Incident Response Runbook That Actually Gets Used Under Pressure

    Designing an Incident Response Runbook That Actually Gets Used Under Pressure

    Most incident response docs die the same death. Someone writes them once, during a calm retrospective, optimizing for completeness instead of usability. Six months later it’s 3 a.m., PagerDuty is screaming, there’s a VP in the Slack channel, and nobody opens the doc, because reading five paragraphs of prose to figure out what to do first is cognitively impossible under stress. I’ve watched competent engineers abandon a 40-page “IR plan” in under 90 seconds and just start guessing. The plan wasn’t wrong. It was unusable.

    A runbook that documents your incident process and a runbook that gets followed when your hands are shaking are two different documents.

    Why prose-heavy runbooks fail

    Decision flow diagram for a credential-leak incident response runbook

    Under acute stress, working memory collapses. You lose the ability to parse nested conditionals, skim for relevance, or hold context across paragraphs. That’s neurology, not a discipline problem. A document that reads like a design doc (“In the event that database replication lag exceeds acceptable thresholds, engineers should first consider…”) demands exactly the kind of sustained reading comprehension that incident stress destroys.

    I keep seeing the same three failure modes.

    No entry point. The doc assumes you already know which section applies. There’s no triage step that gets you from “something’s wrong” to “page 14” in under 10 seconds.

    Decisions buried in narrative. The actual decision (“page the DBA if X, roll back if Y”) sits in sentence four of paragraph three, surrounded by justification nobody needs mid-incident.

    Root-cause bias. The doc walks you toward understanding why before it tells you how to stop the bleeding. In a live incident, causality is a luxury. Containment is not.

    Better prose won’t fix this. Build runbooks as flowcharts and checklists first, and demote prose to footnotes and postmortem material.

    What a usable structure looks like

    Every runbook entry should be scannable top to bottom in the order a responder actually needs it, not the order that’s intellectually tidy.

    1. Trigger conditions: the literal alert names, dashboard thresholds, or symptom descriptions that mean “this runbook applies.” Not “if the database seems slow,” the actual PromQL alert name or Datadog monitor ID. Ambiguity here is the single biggest cause of wasted minutes.

    2. Severity tiers, defined by observable impact, not by vibes:

    SEV1: customer-facing outage or data integrity risk, all hands, exec notified
    SEV2: degraded service, workaround exists, on-call + lead notified
    SEV3: internal-only or single-component failure, on-call handles solo

    Tie the tier directly to escalation and comms obligations below. Don’t make the responder infer what SEV2 implies.

    3. First-5-minutes checklist: literal checkboxes, imperative verbs, zero interpretation required. This is the part people actually execute, so it has to survive being read by someone operating at 60% cognitive capacity.

    4. Escalation path: who, in what order, by what channel, with what SLA for response. Include a fallback if the primary doesn’t ack in N minutes. Name the PagerDuty schedule, the phone number, the backup. “Escalate” can’t be a vague gesture.

    5. Communication templates: pre-written, fill-in-the-blank status updates for internal Slack, status page, and customer-facing comms if applicable. Nobody should be composing prose for stakeholders while also fighting the fire.

    6. Containment and rollback steps, before root-cause investigation. This is the part teams get backwards most often. The runbook should assume the goal is “stop customer impact,” not “understand the bug.” Rollback, failover, feature-flag kill, traffic shedding, whatever gets you back to a known-good state comes before anyone opens a debugger or starts reading logs line by line. Root cause is a postmortem activity, not an incident-response one, unless root cause is the fix (killing a single bad host, say).

    Everything else, architecture diagrams, why the system is built this way, historical context, belongs in a linked reference doc, not the runbook itself. If it’s not actionable in the first 15 minutes, it doesn’t belong above the fold.

    Concrete example: suspected credential leak

    Take a credential or API key suspected to be exposed (committed to a public repo, leaked in a log, found in a pastebin).

    RUNBOOK: Suspected Credential Leak
    
    TRIGGER CONDITIONS
    - GitHub secret-scanning alert fired
    - Credential found in public repo, log aggregator, or third-party report
    - Any employee reports pasting a secret into a public channel/tool
    
    SEVERITY
    SEV1 if: production DB creds, cloud provider root/admin keys, payment
             processor keys
    SEV2 if: scoped service credentials, internal-only API keys
    SEV3 if: already-rotated or non-functional/test credentials
    
    FIRST 5 MINUTES (do these in order, do not skip to investigation)
    [ ] 1. Identify exact credential(s) exposed (name, system, scope)
    [ ] 2. Revoke/rotate the credential at the source NOW
           - AWS: `aws iam update-access-key --access-key-id <id> --status Inactive`
           - DB: rotate password, update secrets manager, do not wait for
             app redeploy to confirm, deactivate first
    [ ] 3. Check access/audit logs for USE of the credential since exposure
           timestamp (not since discovery timestamp)
    [ ] 4. If evidence of use: treat as active compromise, escalate to SEV1,
           page security on-call immediately
    [ ] 5. Post initial status in #incidents using template below
    
    ESCALATION
    - Page: Security on-call (PagerDuty "sec-oncall"), ack SLA 5 min
    - If no ack in 5 min: page Security team lead directly (see contacts doc)
    - SEV1: notify Eng Director + CISO via phone, not Slack
    
    COMMUNICATION TEMPLATE (#incidents channel)
        INCIDENT: Credential exposure - [system/service]
        Severity: [SEV1/2/3]
        Status: [Contained / Investigating / Monitoring]
        Credential rotated: [Y/N, timestamp]
        Evidence of misuse: [Y/N, details]
        Next update: [time]
        IC: [name]
    
    CONTAINMENT (before root-cause)
    [ ] Credential rotated/revoked (confirmed, not assumed)
    [ ] Dependent services redeployed with new credential and confirmed healthy
    [ ] If public repo: force-push history rewrite or purge via GitHub support;
        assume cached copies exist regardless (CDN/scraper mirrors), rotation
        is the real fix, not deletion
    [ ] If evidence of use: lock down affected resource (IP allowlist, disable
        key entirely) even if it breaks a dependent system, customer data
        risk outweighs availability here
    
    ROOT CAUSE (postmortem, after containment confirmed)
    - How did the credential reach a public/exposed location?
    - Was secret-scanning in place on this repo/pipeline? If not, why not?
    - Time from exposure to detection, and detection to rotation

    The excerpt leaves things out on purpose. It doesn’t explain OAuth, doesn’t lecture on secrets-management philosophy, doesn’t walk through how secret scanners work under the hood. All of that lives elsewhere. This section has one job: get a half-asleep on-call engineer from “alert fired” to “credential is dead and we know if it was misused” in under ten minutes, with zero ambiguity about who to call next.

    Keeping it alive

    A runbook this terse goes stale fast if nobody exercises it. I’ve seen teams write a beautiful one and then watch it rot for two years because it never got touched. Two practices help.

    Run it in tabletop exercises quarterly, with someone unfamiliar with the specific system reading it cold. If they get stuck or have to ask what a step means, that’s a bug in the doc, not the reader.

    Update it in the postmortem of every real incident it was used for. If a step was ambiguous or missing during the actual event, fix it that week. Runbooks nobody touches after a real use are already decaying, whether anyone notices or not.

    I’d take an unimpressive document that a tired, stressed, possibly junior engineer can execute correctly without me in the room. Write for that person, not for the auditor who’ll read it later.