Skip to content

Cron trusts unverified Launchpad SSH host keys of other types #114

Closed

Description

@NopeCharon

The cron workflow tries to pin Launchpad's SSH host key, as added in 703ac32:

ssh-keyscan git.launchpad.net >> ~/.ssh/known_hosts
ssh-keygen -qlF git.launchpad.net | grep -xF 'git.launchpad.net RSA SHA256:UNOzlP66WpDuEo34Wgs8mewypV0UzqHLsIFoqwe8dYo'

ssh-keyscan without -t asks for every key type, so it writes every key the server offers (RSA, ECDSA, Ed25519) to known_hosts. The grep only checks that the expected RSA line is one of them. The other lines are trusted without any check.

Someone who can intercept the runner's connection to git.launchpad.net can return the real RSA public key next to their own Ed25519 key. ssh-keyscan records host keys before it checks the server's signature, so the attacker doesn't need Launchpad's private key for this. The fingerprint check passes. Then, during git push launchpad, OpenSSH prefers the key types already in known_hosts and accepts the attacker's Ed25519 key. The push, and the authenticated session using LAUNCHPAD_RSA, go to the attacker. Launchpad builds and publishes whatever is on those branches.

I reproduced this in an Ubuntu 24.04 container. I ran an sshd that only has an Ed25519 key and built known_hosts from its key plus the real RSA line:

fingerprint check: PASSED
[email protected]: Permission denied (publickey,password).   <- host key accepted, reached authentication

Launchpad currently serves only the RSA key, which is the one listed on https://help.launchpad.net/SSHFingerprints. So we can limit the scan to that type with ssh-keyscan -t rsa. Then known_hosts only contains the key the check verifies. A server that offers any other key is rejected with Host key verification failed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions