@@ -774,6 +774,23 @@ information separate from tool definitions. Multiple credentials sets can be def
774774within a single ``requirements`` block, each with a unique name. Before executing a tool
775775that requires credentials, users must provide the necessary credentials through the Galaxy UI.
776776
777+ Security considerations:
778+
779+ - Credentials are stored in the jobs "job script" (the script that sets up the job's environment
780+ and starts the tool script which contains the generated command line). The job script may be
781+ accessible to Galaxy admins during execution of the job (and depending on the configuration
782+ of Galaxy, after execution too).
783+ - Credentials are not available as Cheetah variables, because they could be used in the ``command``
784+ block which would expose their content in the generated command line which is stored in the
785+ job's metadata (which is stored plain text in Galaxy's DB and can be shared with other users).
786+ - Also, credentials should not be passed to the command line through environment variables:
787+ - They will be expanded by the executing shell before execution, i.e. they will be visible on the
788+ process list which can be a problem when jobs are executed on shared systems.
789+ - Values of credentials are not sanitized, i.e. users could abuse them for code injection.
790+ - If values/secrets can be supplied via a file, then a helper script that takes the variables from the
791+ environment and writes them to a file can be used.
792+ - For transparency, it is good to document the extent to which credentials are exposed in the tool help / credential help.
793+
777794### Example
778795
779796```xml
@@ -784,9 +801,9 @@ that requires credentials, users must provide the necessary credentials through
784801 <secret name="secret_key" inject_as_env="AWS_SECRET_ACCESS_KEY" optional="false" label="Secret Access Key" description="Your AWS secret access key" />
785802 </credentials>
786803 <credentials name="database" version="2.1" label="Database Connection" description="Database connection credentials">
787- <variable name="host" inject_as_env="DB_HOST " optional="false" label="Database Host" description="The hostname or IP address of the database server" />
788- <variable name="port" inject_as_env="DB_PORT " optional="true" label="Database Port" description="The port number (default: 5432)" />
789- <secret name="password" inject_as_env="DB_PASSWORD " optional="false" label="Database Password" description="The password for database authentication" />
804+ <variable name="host" inject_as_env="PGHOST " optional="false" label="Database Host" description="The hostname or IP address of the database server" />
805+ <variable name="port" inject_as_env="PGPORT " optional="true" label="Database Port" description="The port number (default: 5432)" />
806+ <secret name="password" inject_as_env="PGPASSWORD " optional="false" label="Database Password" description="The password for database authentication" />
790807 </credentials>
791808</requirements>
792809```
@@ -796,12 +813,19 @@ that requires credentials, users must provide the necessary credentials through
796813Within your tool, access the injected credentials using the specified environment variable names:
797814
798815```bash
799- # Access AWS credentials
800- aws s3 ls s3://my-bucket --region $AWS_REGION --access-key $AWS_ACCESS_KEY_ID --secret-key $AWS_SECRET_ACCESS_KEY
816+ # Access AWS credentials (insecure)
817+ aws s3 ls s3://my-bucket --region "\ $AWS_REGION" --access-key "\ $AWS_ACCESS_KEY_ID" --secret-key "\ $AWS_SECRET_ACCESS_KEY"
801818
802- # Access database credentials
803- psql -h $DB_HOST -p $DB_PORT - U myuser -d mydb -W $DB_PASSWORD
819+ # Access database credentials (the secure way, i.e. not use environment variables on the CLI)
820+ psql -U myuser -d mydb
804821```
822+
823+ In the ``aws`` example, the content of the environment variables would be exposed in the process list of the
824+ machine that is executing the job. Additionally, users could supply characters that are harmful on the CLI (see security considerations).
825+ In modern versions of the ``aws`` interface credentials can only be supplied via a file.
826+
827+ In the postgres example we deliberately used environment variables that are picked up automatically by ``psql``,
828+ i.e. we do not need to set it on the command line (which would expose them on the process list).
805829]]> </xs : documentation >
806830 </xs : annotation >
807831 <xs : sequence >
0 commit comments