Giter Club home page Giter Club logo

bash-pipe3's Introduction

Advanced Pipelining in Bash

This code explores the concept of injecting information into a command pipeline by way of auxiliary file descriptors. It's a bit of an odd situation, so here's the "why":

SHIELD is introducing encryption of backups into its wheelhouse. Currently, the mechanism for driving the SHIELD plugin pipeline is currently implemented in bash, and uses the environment for passing information like store and target endpoint configurations, what plugins to compose, the operation to perform, etc.

Environment variables leak information. Before, we accepted this as a necessity, and leaked credentials embedded in target / store endpoint JSON configurations. With the introduction of encryption, we need to tighten up this security. This means we cannot pass the encryption initialization vectors and keys via the environment - too many (unrelated) things would have access, including:

  • target plugins
  • the compression program (bzip2 / bunzip2)
  • the storage plugin
  • /proc/$pid/environ

For this reason, we want to inject the iv+key into the pipeline at just the right moment, and we are going to try to do it via an auxiliary input file descriptor.

Our pipeline looks like this (for backup ops):

             +----------+        generates the raw backup archive data
(stderr) <-- |  target  |        and streams it to standard output.
             +----------+
                  |
             +----------+        compresses the raw backup archive data
(stderr) <-- | compress |        so that it takes less space in the
             +----------+        storage system
                  |
             +----------+        encrypts the compressed backup archive
(stderr) <-- | encrypt  |        data to secure the backups
             +----------+
                  |
             +----------+        places the encrypted + compressed
(stderr) <-- |  store   |        backup archive data into the remote
             +----------+        storage system

Only box 3, encrypt needs to know about the initialization vector and encryption key, so we want to inject our auxiliary input file descriptor ("fd 3") there. Our pipeline now looks like this:

<iv+key> --------------------.
                             |
             +----------+    |   generates the raw backup archive data
(stderr) <-- |  target  |    |   and streams it to standard output.
             +----------+    |
                  |          |
             +----------+    |   compresses the raw backup archive data
(stderr) <-- | compress |    |   so that it takes less space in the
             +----------+    |   storage system
                  |          |
             +----------+    |   encrypts the compressed backup archive
(stderr) <-- | encrypt  | <--'   data to secure the backups
             +----------+
                  |
             +----------+        places the encrypted + compressed
(stderr) <-- |  store   |        backup archive data into the remote
             +----------+        storage system

To play with the example implementation:

./RUN 3< <(echo "some init vector"; echo "some encryption key")

bash-pipe3's People

Contributors

jhunt avatar

Stargazers

 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.