I'm somewhat alarmed that the context that this bug was running in was capable of root login. Is there a reason that an SSH login process would, by default, have enough capabilities to facilitate direct root login?
There's Paramiko, but Python is still a huge liability in memory-constrained systems.