Skip to content

Unsafe use of echo (may set empty password) #1023

@maffe

Description

@maffe

eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"'

If $POSTGRES_PASSWORD matches the regular expression ^-[neE]+$, the password will be set to an empty string because echo will interpret it as options. (Different shells allow different options for echo, scripts using echo with unknown/variable arguments are therefore not portable.)

printf %s "$POSTGRES_PASSWORD" should be used instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions