Lesson 6 of 13 · 12m
USDT and Uprobes: Reading a Binary You Didn't Write
Compiled-in NOP probes versus breakpoint uprobes, per-hit overhead math, and the plaintext your TLS uprobes see.
Two different mechanisms get lumped together as "dynamic tracing," and the cost model splits cleanly on the difference. A uprobe is a breakpoint: the kernel patches a trap instruction (int3 on x86) over the target address in your userspace binary, and every time execution reaches it, the trap fires, the probe runs, and the original instruction is stepped out of line. A USDT probe is a NOP the developer compiled in ahead of time — it costs nothing until you attach to it. Same attach syntax in bpftrace, completely different physics.
USDT: probes the author left for you
USDT — userland statically defined tracing — comes from DTrace and SystemTap's sys/sdt.h. The compiler emits a NOP at the probe site plus an ELF note (.note.stapsdt, NT_STAPSDT) recording the provider, probe name, address, and argument layout. You can inventory them without running anything:
readelf -n /usr/bin/python3.12 | grep -A4 stapsdt
tplist -l /usr/bin/python3.12 # BCC's USDT listing tool
bpftrace -l 'usdt:/usr/bin/python3.12:*'Binaries that carry them: PostgreSQL built --enable-dtrace (transaction start/commit, query start), the JVM (-XX:+DTraceMethodProbes, -XX:+ExtendedDTraceProbes), Node built --with-dtrace, CPython built --with-dtrace (GC and function-entry probes), Ruby, and the BEAM VM. Attach with bpftrace -e 'usdt:/path/bin:probe_name { @[arg0] = count() }'. Some probes pair with an in-process "semaphore" counter the app increments while enabled, so expensive argument computation only runs when someone is actually listening. Arguments decode by position — arg0, arg1, typed per the note — so bpftrace -e 'usdt:/usr/bin/psql:transaction__start { @[comm] = count() }' works without touching source. The honest tradeoff: zero-cost until enabled, per-hit cost after — and a hot USDT site is still a hot site.
Uprobes: breakpoints on whatever you point at
Uprobes need no cooperation from the binary. Point one at PyEval_EvalFrameDefault in libpython and you get per-function tracing of a runtime that never shipped a probe. This is how some Python profilers and TLS-tracing tools work, and it's also where the cost model bites: a uprobe hit costs the trap plus dispatch, roughly microseconds versus a tracepoint's hundreds of nanoseconds. On a function called thousands of times a second, that's fine. On malloc, it's a self-inflicted DDoS — allocator hit rates run into the millions per second and you'll measure the slowdown before you finish Ctrl-C.
The same mechanism is a security boundary. sslsniff (BCC) and ecapture attach uprobes to SSL_read/SSL_write in libssl and read plaintext before encryption. As a debugging tool on your own host, that's how you inspect traffic without terminating TLS. As a posture statement, it means your observability tooling can bypass your transport security — treat probe privileges like the data access they are, and don't let a debug attach window become a standing capability.
Why you'd choose each
USDT first: stable ABI, author-intended semantics, arguments decoded in the note. Uprobes when nothing else exists, on cold-enough functions to afford the trap. For anything on a hot path, run funccount first — funccount -i 1 'c:malloc' counts hits per second — and look at the number before deciding the probe is free. In managed runtimes the uprobe target is the VM's interpreter frame (PyEval_EvalFrameDefault, the BEAM scheduler), which is how several Python and Erlang profilers trace code the language runtime never instrumented.
Practice
- Inventory with
tplistorreadelf -nbefore writing a uprobe by hand. - Bound attach windows; count hits with
funccountbefore adding payload. - Prefer tracepoints and USDT over kprobes/uprobes for the stable ABI.
- Remember
SSL_read/SSL_writeuprobes see plaintext — grantCAP_BPFlike it decrypts, because it does.
The runtime you didn't write is still legible. The kernel doesn't care whose symbol it patched.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Your Container Is Running SerialGC and Nobody Told You
You tuned G1 flags for a week. Your pod has one CPU, which means the JVM quietly picked a single-threaded collector at startup and ignored every flag you set. Here is the OpenJDK source that made that decision.
PostgreSQL 19 Is Out. REPACK Kept My Writes Running. The Docker Upgrade Will Stop Your App.
PostgreSQL 19 shipped on November 19 with REPACK (CONCURRENTLY), which removes table bloat without blocking writes. I measured it against VACUUM FULL, ran the upgrade from 18, and checked what breaks for self-hosters: Docker tags that refuse to start, a config setting that stops the server, and...
AWS Emulator Puts AWS on Your Laptop. Keep Your IAM Tests Off It.
AWS released AWS Emulator on November 11, a free local server that answers AWS API calls on 127.0.0.1 with per-run keys and fresh certificates.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.