Credential Store

A command line carries parameters that must not be read by everyone: the keys of an object store, a password, the address of an internal service. Writing them into the command makes them visible in a job log and in a process list, and writing them into a plain parameter file moves the problem to the file system.

The CLP reads an object, an overlay or a string from a parameter file -- KEYWORD='file' for an object or an overlay, KEYWORD=f'file' for a string. That file may be a member of a FLAM5 archive, and the archive may be encrypted. The archive is then a credential store: the secrets are encrypted at rest, the command names a member, and nothing in the command, the job log or the process list shows the content.

Nothing at the CLP has to be extended for this. The member is addressed with the member syntax FLAM5 URLs already have.

The mechanism sits below the CLP, in the layer that reads a file into a string. A parameter file is the case this appendix is written for, but a copybook, a row list or a conversion table is read the same way and can come out of the same store.

Addressing a member

A member is named after the path, introduced by a marker:

 my.fl5/?s3.provider              the member "s3.provider", by name
 my.fl5/:1                        the first member, by index
 my.fl5/#1                        the same, written with a number sign

The archive may be remote or lie in a folder store:

 ssh://user@server/my.fl5/?s3.provider   over SSH
 my.dir//?s3.provider                    a folder store (two slashes)

The second slash is what tells a folder store from a file: the path keeps it, and the member begins after it.

A CCSID cannot be given for a member, and the reason is that it is already known. The /&ccsid part of a URL says in which character set the stored data is held -- a file can be anything, so it has to be told. The elements of an archive are neutral, and neutral is always UTF-8, so any other value is simply wrong and UTF-8 itself adds nothing. The specification is refused rather than ignored.

The member specification is the decision. A name without a member is an ordinary file and is read as one. A name with a member is a FLAM5 archive, and if it cannot be opened, the member is not there or the decryption fails, the command fails -- it does not fall back to reading the archive as a file. That is deliberate: the bytes of an encrypted archive handed to the parser as a parameter string would end in a syntax error somewhere inside binary data, instead of saying that the member was not found or the password was wrong.

Decryption

How to decrypt the archive is taken from the environment variable FL_ARCHIVE_DECRYPT. It carries the DECRYPT specification and nothing else:

 FL_ARCHIVE_DECRYPT="PWD(PASSWORD='secret')"
 FL_ARCHIVE_DECRYPT="PGP()"

PWD and PGP are the two forms, and nothing else is accepted. That is a security property rather than a restriction: the parameter object around DECRYPT also holds PREPROCESS and POSTPROCESS, which execute commands, and a variable that could reach them would turn every parameter file read into a way of running programs.

Inside PGP the FKM5(LIBRARY=) option is refused as well, for the same reason one step down: a crypto engine is a module that would be loaded and executed. A job that needs a different engine names it in the command, where it is as visible as the rest of the command -- not in an environment variable.

The password does not have to stand in the variable either. The CLP reads a string from a file, so the secret can live in a file with its own permissions:

 FL_ARCHIVE_DECRYPT="PWD(PASSWORD=f'/etc/flam/store.pwd')"

If FL_ARCHIVE_DECRYPT is not set, no DECRYPT is given at all. Either the archive is not encrypted, or the key is found by its id -- which is how an archive encrypted for an OpenPGP key is read on z/OS, where ICSF holds the private key and no password is involved.

The variable is also a z/OS system symbol, &FLARCDC.

Setting up a store

One archive, one member per parameter file.

*On UNIX and Windows, pipe the specification in; do not write it to a file first.* FILE=STREAM reads standard input, so the secret never reaches a disk in the clear and there is nothing to delete afterwards -- and nothing that survives if the command is interrupted between writing the file and removing it. On z/OS this does not apply; see the section below.

 printf "ENDPOINT='https://s3.example.com' REGION='eu-west-1'\nACCESSKEY='AKIA...' SECRETKEY='...'\n" |
 flcl archive comp "from.text(file=STREAM) to.new(store.file(name='cred.fl5') flam(member='s3.provider' encrypt.pwd(data(password='secret'))))"

An empty file name means the same thing: FILE='' reads standard input too.

Better still, let the source produce it, so the secret exists only in the pipe -- a password manager, aws configure export-credentials, a key vault client:

 pass show flam/s3-provider | flcl archive comp "from.text(file=STREAM) to.new(store.file(name='cred.fl5') flam(member='s3.provider' encrypt.pwd(data(password='secret'))))"

A second member is added with to.mod, which keeps what the archive already holds. to.old would write a new VERSION containing only the new member:

 printf "ENDPOINT='https://az.example.com'\n" | flcl archive comp "from.text(file=STREAM) to.mod(store.file(name='cred.fl5') flam(member='azure.provider' decrypt.pwd(password='secret')))"

The DECRYPT here is the archive's own, not FL_ARCHIVE_DECRYPT: the variable is read where a PARAMETER file is opened, and this command is writing the store, not using it.

If a specification does come from a file -- because it was delivered that way -- delete it afterwards. An archive beside the files it was made from protects nothing.

Filling the store from a program

flcl is not the only way in, and on a platform without a pipe it is not the best one. Two programming interfaces write the same archive:

FLMREC is the right answer whenever the credential comes from somewhere a program can reach directly: a key vault, a password manager, an operator prompt. Everything else is a copy of it, and every copy is a place it can be read.

On z/OS

There is no pipe. FILE=STREAM reads DD:SYSIN, and a command without a file name reads the default DD name FLAMIN -- so the input is a DD, and coding it in stream puts the credential into the JCL itself, where the job library and the spool can be read by more people than the data set would have been. In-stream is therefore the worst of the available choices on this platform, not the equivalent of a pipe.

What to do instead, in order of preference:

Using it

PROVIDER of an object store is an OBJECT, so the member is addressed with '...' and the object is read out of it:

 export FL_ARCHIVE_DECRYPT="PWD(PASSWORD=f'/etc/flam/store.pwd')"
 flcl archive comp "from.text(file='data.txt') to.new(store.s3(PROVIDER='cred.fl5/?s3.provider' BUCKET='mybucket') flam(member='data'))"

PROVIDER of store.ibmcda() is a STRING -- the name of a provider definition the system programmer created -- and a string is read from a file with f'...':

 flcl archive comp "from.text(file='data.txt') to.new(store.ibmcda(PROVIDER=f'cred.fl5/?cda.name' BUCKET='mybucket') flam(member='data'))"

The same applies everywhere the CLP reads a parameter file, not only to a store: an overlay, an object or a string may come out of a member.

What it does not do

A member may be used wherever FL5 reads a text input as a string: a parameter file of the CLP, but also a COBOL copybook, a PL/I include, an assembler structure, a row list or a conversion table. It is not a data file: read.text(file='cred.fl5/?member') names the input of a conversion, and that is opened by the file layer, which does not read archives. The member specification is valid there and the command still fails.

FL_ARCHIVE_DECRYPT is not the decryption of an archive a command processes. A DECO of an encrypted archive takes its DECRYPT() from the command; this variable is only about an archive that an input is read from.

FL_ARCHIVE_DECRYPT may not take its own value out of an archive member -- PWD(PASSWORD=f'cred.fl5/?pw') is refused. The member would have to be read by the very parse that is reading the variable.

Recommendations