Code Monkey home page Code Monkey logo

vlad's Introduction

Vlad the validator ๐Ÿง›

โš ๏ธ Super early days, we live in master. Vlad is still young and subject to change.

Vlad forces client interactions to be limited to the resources prefixed with the same OU= as the user TLS certificate. With OU=tst I could interact with service tst_thing and tstthing but not different_service. The same principle holds for networks, volumes and every other resource type. A public OU is automatically added for all clients.

Because we can't mutate the response to the client, global indexing is allowed, but deletion, inspection, update, etc is restricted to the client OU prefix.

Installation | Development | Docker Hub

Certificate requirements

Following along with https://docs.docker.com/engine/security/https/ we need to make a slight modification to the client certificate signing request.

The line

openssl req -subj '/CN=client' -new -key key.pem -out client.csr

Becomes the following (where groupname is set)

openssl req -subj '/CN=client/OU=groupname' -new -key key.pem -out client.csr

Installation

docker plugin install c45y/vlad --alias vlad

To complete, add vlad to your authorization-plugins configuration in daemon.json.

A small number of plugin configuration options can be toggled:

  • VLAD_BIND_MOUNT sets the ability to perform host bind mounts, default false
  • VLAD_BIND_PORTS toggles port binding outside the 30000-61000 range, default false

Current configuration can be seen using:

docker plugin inspect -f {{.Settings.Env}} vlad

Development Installation

From your command line:

docker build -t rootfsimage .
docker create --name vlad_container rootfsimage true
mkdir -p rootfs
docker export vlad_container | tar -x -C rootfs
docker plugin create vlad .
docker plugin enable vlad:latest  # Enable our dev plugin
sudo ./scripts/deploy.sh  # Generate docker CA/Node/Client certificates and deploy daemon.json
sudo ./scripts/docker.sh info  # Uses the client certificate via TLS + vlad authz
sudo docker info  # Uses existing unix socket (which is blanket allowed by vlad)

Tests

A small test harness based on the docker-bench-security setup to run through known valid/invalid operations. Runs a docker daemon with vlad under a mktemp directory which is destroyed at the end of testing.

systemctl stop docker  # Can't have another one running
cd test && sudo ./test

Output looks something like

Calling check_tls_volume_bad_bind
> docker volume create --opt=type=bind --opt=device=/tmp testgroup_4711accf0672
Error response from daemon: authorization denied by plugin c45y/vlad:latest: You cannot bind mount.
[PASS][check_tls_volume_bad_bind]

Calling check_tls_volume_bad_ou
> docker volume create badgroup_29d63f46fa7f
Error response from daemon: authorization denied by plugin c45y/vlad:latest: That volume is outside your OU prefix. ('public', 'testgroup')
[PASS][check_tls_volume_bad_ou]

Calling check_tls_volume_ou
> docker volume create testgroup_3c2739947c82
testgroup_3c2739947c82
[PASS][check_tls_volume_ou]


===================
Completed tests: 11
Passed tests:    11

Todo

  • work more vampire jokes into readme
  • echo OUs back to clients when bad prefix

    standardize response messages

  • certificate revocation for clients

    decline via CN= & OU= as docker doesn't handle revocation?

  • configuration options

    enable port binding / bind mounts / toggle random allow/block features

Validators

Default Request/Response vladidators all come from vlad.validators, though the list can be mutated at startup if required.

To implemnent custom functionality you can override/append async functions to the list of handlers indexed by make_app.

app = make_app()
app['validators']['request'] = [my_custom_async_func]

Validators have the choice of:

  • explicitly allowing a request with a True value
  • explicitly denying a request with a str denial message to be passed to the client
  • doing absolutely nothing (None)

Requests are default deny, Response is default allow.

Each validator implements either/both the following function templates

@handles.post('configs', 'create')
async def validate_request(req: DockerRequest) -> Union[None, str, bool]:
    pass

async def validate_response(res: DockerResponse) -> Union[None, str]:
    pass

The handles decorator implements structured filtering to the validation functions. Check vlad/validators/ for extensive usage examples.

Handler Index:

We are missing handlers for:

  • get:/events
  • post:/networks/*/connect
  • post:/session
  • get:/system/df
  • get:/distribution/*/json
  • post:/networks/*/disconnect
  • get:/tasks/*/logs

vlad's People

Contributors

stevommmm avatar

Watchers

 avatar  avatar

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.