I'm looking to develop a "secure" application and as a security mitigation, I'd like to be able to discover if a debugger (GDB, LLDB...) is in use on the currently running application; aborting if detected.
How can I detect monitoring of a statically-linked C application?
- Walk the /proc tree
- ...
Just a crazy idea - load BPF program (assuming your binary has a capability to do it) to intercept
ptrace
syscall from process parent, and check if pid of process being traced match your process' pid, then you can either fail the syscall, preventing the debug, and send and event to userspace to stop your process.Although it won't work for attached process, so you'd need to intercept
ptrace
from all processes, I'm not sure BPF allows it, don't remember.