Git Product home page Git Product logo

google / hiba Goto Github PK

View Code? Open in Web Editor NEW
361.0 12.0 16.0 146 KB

HIBA is a system built on top of regular OpenSSH certificate-based authentication that allows to manage flexible authorization of principals on pools of target hosts without the need to push customized authorized_users files periodically.

Home Page: https://github.com/google/hiba

License: BSD 3-Clause "New" or "Revised" License

Makefile 0.93% C 64.77% Shell 12.54% M4 6.46% Roff 15.29%
ssh authorization

hiba's Introduction

HIBA: Host Identity Based Authorization

Pronounce: /hiːba/

What is HIBA

HIBA is a system built on top of regular OpenSSH certificate-based authentication that allows to manage flexible authorization of principals on pools of target hosts without the need to push customized authorized_users files periodically.

The authorization is performed directly on the target host based on the user certificate content and the local host identity only. Not accessing external services makes it suitable for low dependency, last resort, SSH access.

For more details on how authorization is computed, see PROTOCOL.authorizations.

Concepts

HIBA defines two concepts: host identity and grants. See PROTOCOL.extensions for the exact specifications.

Host identity

This is a custom extension attached to host certificates that describes the main properties of a target host. The format is flexible and only mandates one field, domain, to help isolate different pools of hosts managed using the same CA keys.

An example of a host identity could be:

  • domain: dmz.example.com
  • owner: frontend-team
  • location: US

Grants

This is also a custom extension, attached to user certificates that describes which hosts this certificate should be accepted on. The grant contains a set of constraints that a host must match for the access to be authorized. These constraints are compared to the host identity at connection time by the hiba-chk helper. Due to the flexible nature of the host identity, the following semantics apply:

  • Any field present in the grant and missing for the host identity is considered invalid and will prevent access.
  • Any field missing from the grant and present in the host identity is ignored for authorization purposes (equivalent to a wildcard).

Mechanism

HIBA relies on a few properties provided by OpenSSH:

  • Certificate based authentication: a HIBA grant is a custom extension attached to the certificate. This means the CA is responsible for verifying the scope of the grant before attaching it. Similarly, the host identity is attached to the host certificate by the CA and must represent the target host.
  • AuthorizedPrincipalsCommand: this option of the sshd_config allows invoking an external tool to dynamically generate the content of authorized_users. This option is used to invoke hiba-chk, which knows how to extract the HIBA extensions from user and host certificates and grants or denies access based on the comparison.

GRL (Grant Revocation List)

HIBA allows revoking individual grants rather than the whole certificate. See PROTOCOL.grl for more information.

Note: revocations at the grant granularity are not yet supported. The rationale for not prioritizing these: full SSH certificate revocation is already supported by OpenSSH, only the finer granularity is lacking. Also, it is good practice to rely on short lived certificates, which often expire before the revocation list makes it to the target host.

Prerequisites

HIBA works on top of OpenSSH certificates. It relies on:

  • The AuthorizedPrincipalsCommand option that was added to OpenSSH 6.9
  • The %u and %k tokens that were added to OpenSSH 7.4

For compilation, configuration and installation instructions, see INSTALL.md.

Developers

The HIBA library can be used to add support for HIBA to a certificate authority.

Note: None of this code is thread safe, and it is the responsibility of the caller to ensure proper locking when accessing individual HIBA structures.

Generating HIBA enabled certificates

HIBA enabled certificates are generated using the HIBA API defined in extensions.h and the OpenSSH API defined in sshkey.h.

  • Using libhiba:
    • Import or generate the required HIBA extensions (identity or grant)
    • Serialize them into an sshbuf
  • Using libssh:
    • Import or generate the SSH public key
    • Attach generated extensions
    • Sign the certificate with the CA private key
    • Serialize it

For a simple local test setup see the testing section of INSTALL.md.

Reading HIBA enabled certificates

HIBA extensions can be extracted from existing certificates by relying on OpenSSH to decode/verify the certificate, extracting the HIBA extensions and interpreting them with HIBA.

  • Using libssh:
    • Import certificate
    • Verify certificate signature
    • List and extract relevant extensions
  • Using libhiba:
    • Parse extensions
    • Extract extensions' content

libhiba provides convenience functions to parse and extract HIBA extensions directly from a certificate, but it does not verify the certificate. It assumes the certificate was validated by a prior stage.

Example CA

See the CA documentation for a basic example of how the tools provided with HIBA can be used to manage extensions and certificates.

hiba's People

Contributors

blunderer avatar c0d3d avatar grihit avatar hallgrimurhg avatar joelferrier avatar jonathanpittman avatar sourcequench avatar wltu 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hiba's Issues

Revocations, invalid use of undefined type 'struct sshbuf'

Gathering fresh sources for openssh-portable, openssl, and hiba I run into a build error.

Following the instructions on INSTALL.md, I gathered sources

$ git clone [email protected]:openssh/openssh-portable.git
$ git clone [email protected]:sourcequench/hiba.git
$ git clone git://git.openssl.org/openssl.git

Building openssl and openssh (with the addition of LD_LIBRARY_PATH=../openssl) worked out fine.

The autogen.sh and configure steps worked fine for hiba, but make ended in sadness - looks like an issue with untyped struct for revocations.

make
make  all-am
make[1]: Entering directory '/home/ryanshea/git/hiba'
  CC       libhiba_la-revocations.lo
In file included from revocations.c:15:
revocations.c: In function 'hibagrl_decode':
revocations.c:173:80: error: invalid use of undefined type 'struct sshbuf'
  173 |                 debug3("hibagrl_decode: serial list section content @%zu", blob->off);
      |                                                                                ^~
../openssh-portable/log.h:88:100: note: in definition of macro 'debug3'
   88 | #define debug3(...)             sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
      |                                                                                                    ^~~~~~~~~~~
revocations.c:189:75: error: invalid use of undefined type 'struct sshbuf'
  189 |                 debug3("hibagrl_decode: bitmap section content @%zu", blob->off);
      |                                                                           ^~
../openssh-portable/log.h:88:100: note: in definition of macro 'debug3'
   88 | #define debug3(...)             sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, NULL, __VA_ARGS__)
      |                                                                                                    ^~~~~~~~~~~
make[1]: *** [Makefile:609: libhiba_la-revocations.lo] Error 1
make[1]: Leaving directory '/home/ryanshea/git/hiba'
make: *** [Makefile:394: all] Error 2

hiba-ca.sh

hiba-ca.sh script does not accept '-m' option but prints it if called with '--help'

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.