Giter Club home page Giter Club logo

hallow's Introduction

Hallow

Hallow is an OpenSSH Certificate Authority tightly coupled to AWS.

How does Hallow work?

Hallow uses AWS IAM to authenticate incoming requests via API Gateway to resolve the IAM identity of the requester. The API Gateway triggers a Lambda running Hallow, which will take the AWS IAM User ARN, and sign the provided SSH Public Key with an asymmetric key (currently only ECDSA keys are supported) stored in KMS.

Why did we build it?

Our goals in building a new SSH CA were:

  • Easy to deploy, even (perhaps especially) for small teams. That's why it has relatively few moving pieces, and comes with a terraform module.
  • Leverages an existing authentication system. That's why we use AWS IAM for authentication, making it trivial to require MFA for SSH.
  • Non-extractable private key. That's why we the CA private key lives in KMS.
  • Simple to understand. Security tools should make things easier, not more complicated. Hallow itself is under 500 lines of code.

What does it use as the SSH Principal?

Hallow will set the Principal to the User ARN of the incoming request. In most cases, this means that your User ARN in AWS that was used to hit the API endpoint will match the principal name in the Certificate.

The only exception is an sts assumed-role ARN. The Session Name (the last part of the ARN) is user-controlled, and usually set to something helpful (like the username of the person assuming the role, or the i-* instance ID), but is not significant, or any assertion of identity. As a result, session names are removed from assumed-role ARNs.

If you are using Assumed Roles, it is important to note that the principal in your certificate will be of the form arn:aws:sts::{account_id}:assumed-role/{role_name}. It will not be the ARN for the role itself (which is of the form arn:aws:iam::{account_id}:role/{role_name}).

Additionally, if you are authenticating to Hallow with an Assumed Role, Hallow will look at the tags on the role, and if there is a tag named hallow.additional_principals it will use that value as additional principals for the certificate. To pass multiple values comma separate them.

Deploying Hallow

The easiest way to deploy Hallow is with the Terraform module provided in the terraform/ directory. It will deploy all the AWS resources required for Hallow to work.

For your first deployment try our quickstart guide.

What do I need to do to my system to trust Hallow?

First, the /etc/ssh/sshd_config should be updated to add a few flags. The first is to add the SSH Certificate Authorities, and the second is to set which principals are allowed for which users on the system.

TrustedUserCAKeys is a list of SSH Public Keys in the authorized_keys format, separated by newlines. This file should contain Hallow's KMS Public Key in SSH format.

AuthorizedPrincipalsFile is a list of principals that are allowed to access the particular user that is being logged into. %u means the requested user, so it's a good idea to keep a directory full of files named after users of the system. Hallow will set the principal of the Certificate to the User ARN, so these files should specify the ARNs allowed to access the particular resources.

sshd_config

TrustedUserCAKeys=/etc/ssh/hallow_cas
AuthorizedPrincipalsFile=/etc/ssh/principals/%u

hallow_cas

Set this file to your own roots. This is an example file, and not the one you should put in your own file, unless you want the authors of this package to have root on your boxes.

ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBFvuBGdFLPNRg+xZkGfQ5u9V3FD6etx0cz0fx6HkjzAvZ0W/FF4HYZPsCkLpsJhjaRfF1Nm9mNXiyaHsrkfaKgQ=

principals/%u

arn:aws:iam::12345.....098:root

Configuration knobs

Environment Variable Usage
LOG_LEVEL Log Level for Logrus. Valid values are trace, debug, info, warn, error, fatal, panic
HALLOW_KMS_KEY_ARN ARN of the KMS asymmetric key. Currently must be an ECDSA key.
HALLOW_CERT_VALIDITY_DURATION Duration that Certificates issued by Hallow are valid for, in Go time.Duration syntax (1h, 20s). Default is 30m
HALLOW_ALLOWED_KEY_TYPES Space delimited list of supported ssh key types (default set is a sensible default of ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-ed25519

Security considerations

To get the most value out of Hallow, only give people the right to interact with Hallow via a role which is assumed with MFA. This gets you MFA for SSH.

Generate a fresh private key for every certificate. This reduces the damage that can be caused by a disclosed private key to the lifetime of the certificate.

Hallow does not need to be run in the same AWS account as the rest of your infrastructure.

hallow's People

Contributors

alex avatar chapem avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar jeff-predictwise avatar nick-ocurate avatar paultag avatar steiza avatar tomberek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hallow's Issues

discussion: v2 api?

Currently, we PUT an ssh key, in the authorized key format. This is very easy to implement and it makes me feel very satisfied in the API call. Send a public key, get a certificate.

I think it may be time to tweak the API though, perhaps sending JSON to the endpoint instead.

In particular, I'd like to change the API to look like:

{
    "public_key": {
        "type": "ssh-*",
        "bytes": "base64byteshere==",
    },
    "certificate_key_id": "user@host",
    "certificate_type": "user|host",
}

or perhaps

{
    "public_key_bytes": "base64byteshere==",
    "certificate_key_id": "user@host",
    "certificate_type": "user|host",
}

to allow Hallow to issue Host Certificates too.

Alternatively, we can set this in http X-Hallow-* headers. I like that slightly less.

As a stop-gap, we can support both inputs by checking the first byte, since { is not a valid ssh key type, and then drop the old format after we're sure all client binaries out there have been forward-ported.

Add a "Why" section to README

This project sounds really cool, but as someone who only knows a little about AWS, I think this would benefit from an explanation in the README about why it's useful and who the target audience is. Thanks!

hallow-cli logging to account for lambda issues

(Flagging this after going down a rabbit hole that ended up being caused by one of the actions-built zips (which when downloaded is named hallow.zip.zip btw) being corrupt somehow. Building from source fixed that issue.)

The hallow-cli logging is displayed in a way that makes it seem as if the respondent json, exit code, and error message comes directly from the hallow webserver, with a client-side hard coded "internal server error" for catchall failures:

FATA[0000] Got a non-200 exit code                       error="hallow/client: HTTP error from hallow. Status=502: {\"message\": \"Internal server error\"}" hallow.endpoint="someendpoint" hallow.publi
c_key.comment=somecomment hallow.public_key.type=ecdsa-sha2-nistp384

A great addition to hallow-cli would be to explicitly display where a log message comes from, whether an issue is lambda, hallow, or local environment/parsing related. Thanks in advance.

SSH certs supported by gpg-agent?

Using GPG's agent (using that to manage Yubikey), i attempted to sign an RSA key, which failed. That just needs to be enabled as a supported key type.

Next I attempted to obtain a key via hallow-cli ssh-add. I obtained a public key, but the cert was not added. Unsure if gpg-agent supports it, or if there is some API difference or what.

Testing with eval $(ssh-agent) worked fine.

Optionally set source-address critical extension?

Certs can set a critical extension source-address to an IP address, which is then the only IP allowed to use this certificate.

Since we're issuing short lived certs, roaming is probably not a concern. Would it make sense to automatically set this to the requesting client's IP?

Assumed role principal confusion

I thought my principal was going to be: arn:aws:iam::66...:role/<role-name>. It was actually... arn:aws:sts::66...:assumed-role/<role-name>!

This is confusing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.