Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Write connection details to TTY on boot #53

Merged
merged 19 commits into from
Jul 27, 2020

Conversation

lukechilds
Copy link
Member

@lukechilds lukechilds commented Jul 20, 2020

When an HDMI monitor is connected to the Pi, it'll write the Tor hidden service address directly to the TTY without requiring the user to login.

This solves the problem of setting up a device on an untrusted network. We use the HDMI display as a secure channel to write out an ascii QR code that the user can scan to start the setup process securely via Tor.

Currently the setup is done over unencrypted HTTP on the local network. This is fine if the user trusts the network, however many people have smart devices on their local networks such as Chromecast/Sonos/Smart TV/etc and we can't verify how they work and that they aren't malicious.

So with that in mind it's probably not safe to assume the user's network is secure. Most users networks are probably insecure and they just don't know it.

It's impossible to bootstrap a secure connection over an insecure connection without any previous communication. If we show the hidden service address on the HTTP server and tell the user to continue there, there's no way they can verify someone hasn't MITMd the initial connection and injected a false address.

A self signed SSL cert doesn't really achieve anything here because if we generate it randomly the user doesn't know the expected fingerprint for the real cert, and if we hardcode it an attacker can just extract the private key from the source and use that to imitate the real server.

We need a secure communication channel to do some sort of initial information share so that we can establish a secure channel, and HDMI seems like the simplest solution.

Here's an example of what the ascii output looks like:

20200720_200636

@lukechilds lukechilds force-pushed the connection-details branch from 7868f8a to 529c2a7 Compare July 20, 2020 13:26
@mayankchhabra
Copy link
Member

Concept and implementation ACK!

What a beautiful and creative solution to the pressing problem of bootstrapping initial connection. Pretty sure many OGs and hardcoiners are going to love it!

Unfortunately, I don't have a micro HDMI cable at my disposal currently, so I cannot test it. Meanwhile, @nolim1t: if you could test it out that'd be wonderful. Else we can directly proceed to merge it because we trust, and don't verify.

@nolim1t
Copy link
Contributor

nolim1t commented Jul 20, 2020

We should have it show the IP address too. umbrel.local doesn't work with windows or android (without installing special stuff). .local is only supported on MacOS or Linux

@mayankchhabra
Copy link
Member

We should have it show the IP address too

+1. That's a very good point.

@lukechilds
Copy link
Member Author

lukechilds commented Jul 20, 2020

Raspbian/Pi OS already logs the IP, you can see it in the photo just below the 6th [ OK ] print from the bottom.

We could pull it in to the ascii output to neaten it up but I didn't think the dashboard was available via IP address due to it not being in the origin whitelist?

@mayankchhabra
Copy link
Member

mayankchhabra commented Jul 20, 2020

Ah yes, you're right.

We can export the IP as an environment variable called DEVICE_IP on the boot, and set DEVICE_HOST: "http://${DEVICE_IP}" inside docker-compose.yml since http://umbrel.local is hardcoded in the CORS whitelist of both manager and middleware.

@lukechilds
Copy link
Member Author

Yeah that's a good idea.

Copy link

@meeDamian meeDamian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some small notes. Cool stuff! 👌🏻

Only other thought is that having logo, and QR horizontally will get them both terribly scrambled on a screen that's not wide enough. But I guess most TVs should be fine and guessing some smaller displays are not supported, and/or would require some extra changes.

stage2/01-sys-tweaks/files/rc.local Outdated Show resolved Hide resolved
stage2/06-connection-details/01-run.sh Outdated Show resolved Hide resolved
stage2/06-connection-details/01-run.sh Outdated Show resolved Hide resolved
@lukechilds
Copy link
Member Author

@meeDamian

Only other thought is that having logo, and QR horizontally will get them both terribly scrambled on a screen that's not wide enough. But I guess most TVs should be fine and guessing some smaller displays are not supported, and/or would require some extra changes.

Yeah, my thinking was that most HDMI displays are 16:9 and a good chunk of those will be exactly 1920x1080.

So its probably safe to assume most users will see it how we've tested it.

Also, remember this is writing directly to the TTY, it's not a proper terminal, AFAIK there is no scroll buffer. So if we put them underneath each other and something goes out of view there's no way for the user to scroll it back in. Since most diaplys will be 16:9, we actually have more horizontal real estate than vertical, so displaying things horizontally instead of vertically increases the amount of things we can show before they get cut off.

@nolim1t
Copy link
Contributor

nolim1t commented Jul 23, 2020

LGTM..

@meeDamian
Copy link

Only thing I can see making any sense would be removing some horizontal whitespace between, and around them, but again… probably really not worth bothering with.

Alternatively, spend an evening writing a custom QR-generator that puts umbrel logo in the middle 😝.

@mayankchhabra
Copy link
Member

Alternatively, spend an evening writing a custom QR-generator that puts umbrel logo in the middle 😝.

@meeDamian stop giving him ideas 🤫

Comment on lines 7 to 9
on_chroot << EOF
pip3 install qrcode
EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding python3-qrcode to packages instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wooaaaah, I've been messing around for ages trying to get pipenv to install system packages as root so we can install securely and verify against a checksum, had no idea it was available via apt!

@@ -73,4 +73,12 @@ if [ ! -f /home/umbrel/statuses/service-configured ]; then
fi
fi

# Display connection details on the TTY
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a clear here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should clear the TTY here since there could be useful log output on the screen that we don't want to overwrite.

Comment on lines 14 to 15
chmod +x files/connection-details
cp files/connection-details "${ROOTFS_DIR}"/usr/local/bin/connection-details
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install -m 755 files/connection-details "${ROOTFS_DIR}"/usr/bin/connection-details would probably work better here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, was not aware of install!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants