2

I'm writing a webpage-monitoring program that, every hour, logs in to a website using Selenium and notifies me if the page has changed in a particular way. For example, this program can monitor my cell phone data usage and warn me if my usage is spiking. However, I'm concerned about having my plaintext password just sitting on a machine that's perpetually connected to the Internet.

Q: What is a responsible way to automate periodic website logins?

I've considered the following precautions, in order of increasing paranoid-ness:

  1. "Harden" the Linux distro -- turn off ping responses, CUPS, Java, SSH, Samba, and other unused services.

  2. Encrypt the password on disk and hard-code the key in the program (like, use XOR to obfuscate the password a little).

  3. Store the password only in RAM; that is, enter the password when I start the program. (So the program is always running; can't use cron)

  4. Turn off the machine's network when the program isn't running using ifdown and ifup.

  5. Use a timed electrical outlet to -- once an hour -- physically power up the machine, let it run for a few minutes, and power it down (say, using this Art Controller relay board).

(BTW, I have the basic program working on a Raspberry Pi using Python and pyvirtualdisplay as described here, and I'm using Selenium because some websites of interest require JavaScript.)

1 Answers1

3

Security is a tradeoff. As an extreme example, a system powered off, disconnected, and encased in a block of concrete is very secure but completely useless. You decide on which security measures you're willing to pay for (reduced usability, actual dollars spent, etc.) by analyzing how likely a breach is to occur, and how much it'll cost.

Since this is apparently a machine dedicated to the task, I'd personally just stick it in a text file (or, stored only in memory were these more valuable passwords, like bank accounts) and do your step 1 [which you almost always should; turning off unused services is basically free].

If it's possible to drive a web browser running as a different user, I'd do that—web browsers have a huge attack surface. And of course make sure your browser security updates are applied.

BTW: You missed some hardening steps, like iptables. Also, turning off ICMP echo IMO doesn't really give you any security, but makes network troubleshooting annoying. (Anything behind your firewall able to ping it could also do an ARP ping instead, which it has to respond to for Ethernet to work. Or any number of other protocol pings to see it's up.)

derobert
  • 109,670
  • Thanks for your response. Would ufw be a suitable alternative to iptables? Last time I looked, iptables had a pretty steep learning curve. – ConvexMartian Aug 21 '16 at 18:36
  • 1
    @ConvexMartian ufw is a front-end for iptables. So it's not really an alternative, just a different way to configure iptables. It should be fine. (As long as it's configured correctly, which is a caveat that applies to all firewalls). – derobert Aug 21 '16 at 18:40